babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4961. /**
  4962. * Class used to evalaute queries containing `and` and `or` operators
  4963. */
  4964. export class AndOrNotEvaluator {
  4965. /**
  4966. * Evaluate a query
  4967. * @param query defines the query to evaluate
  4968. * @param evaluateCallback defines the callback used to filter result
  4969. * @returns true if the query matches
  4970. */
  4971. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4972. private static _HandleParenthesisContent;
  4973. private static _SimplifyNegation;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/tags" {
  4977. /**
  4978. * Class used to store custom tags
  4979. */
  4980. export class Tags {
  4981. /**
  4982. * Adds support for tags on the given object
  4983. * @param obj defines the object to use
  4984. */
  4985. static EnableFor(obj: any): void;
  4986. /**
  4987. * Removes tags support
  4988. * @param obj defines the object to use
  4989. */
  4990. static DisableFor(obj: any): void;
  4991. /**
  4992. * Gets a boolean indicating if the given object has tags
  4993. * @param obj defines the object to use
  4994. * @returns a boolean
  4995. */
  4996. static HasTags(obj: any): boolean;
  4997. /**
  4998. * Gets the tags available on a given object
  4999. * @param obj defines the object to use
  5000. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5001. * @returns the tags
  5002. */
  5003. static GetTags(obj: any, asString?: boolean): any;
  5004. /**
  5005. * Adds tags to an object
  5006. * @param obj defines the object to use
  5007. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5008. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5009. */
  5010. static AddTagsTo(obj: any, tagsString: string): void;
  5011. /**
  5012. * @hidden
  5013. */
  5014. static _AddTagTo(obj: any, tag: string): void;
  5015. /**
  5016. * Removes specific tags from a specific object
  5017. * @param obj defines the object to use
  5018. * @param tagsString defines the tags to remove
  5019. */
  5020. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5021. /**
  5022. * @hidden
  5023. */
  5024. static _RemoveTagFrom(obj: any, tag: string): void;
  5025. /**
  5026. * Defines if tags hosted on an object match a given query
  5027. * @param obj defines the object to use
  5028. * @param tagsQuery defines the tag query
  5029. * @returns a boolean
  5030. */
  5031. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5032. }
  5033. }
  5034. declare module "babylonjs/Materials/materialDefines" {
  5035. /**
  5036. * Manages the defines for the Material
  5037. */
  5038. export class MaterialDefines {
  5039. private _keys;
  5040. private _isDirty;
  5041. /** @hidden */
  5042. _renderId: number;
  5043. /** @hidden */
  5044. _areLightsDirty: boolean;
  5045. /** @hidden */
  5046. _areAttributesDirty: boolean;
  5047. /** @hidden */
  5048. _areTexturesDirty: boolean;
  5049. /** @hidden */
  5050. _areFresnelDirty: boolean;
  5051. /** @hidden */
  5052. _areMiscDirty: boolean;
  5053. /** @hidden */
  5054. _areImageProcessingDirty: boolean;
  5055. /** @hidden */
  5056. _normals: boolean;
  5057. /** @hidden */
  5058. _uvs: boolean;
  5059. /** @hidden */
  5060. _needNormals: boolean;
  5061. /** @hidden */
  5062. _needUVs: boolean;
  5063. /**
  5064. * Specifies if the material needs to be re-calculated
  5065. */
  5066. readonly isDirty: boolean;
  5067. /**
  5068. * Marks the material to indicate that it has been re-calculated
  5069. */
  5070. markAsProcessed(): void;
  5071. /**
  5072. * Marks the material to indicate that it needs to be re-calculated
  5073. */
  5074. markAsUnprocessed(): void;
  5075. /**
  5076. * Marks the material to indicate all of its defines need to be re-calculated
  5077. */
  5078. markAllAsDirty(): void;
  5079. /**
  5080. * Marks the material to indicate that image processing needs to be re-calculated
  5081. */
  5082. markAsImageProcessingDirty(): void;
  5083. /**
  5084. * Marks the material to indicate the lights need to be re-calculated
  5085. */
  5086. markAsLightDirty(): void;
  5087. /**
  5088. * Marks the attribute state as changed
  5089. */
  5090. markAsAttributesDirty(): void;
  5091. /**
  5092. * Marks the texture state as changed
  5093. */
  5094. markAsTexturesDirty(): void;
  5095. /**
  5096. * Marks the fresnel state as changed
  5097. */
  5098. markAsFresnelDirty(): void;
  5099. /**
  5100. * Marks the misc state as changed
  5101. */
  5102. markAsMiscDirty(): void;
  5103. /**
  5104. * Rebuilds the material defines
  5105. */
  5106. rebuild(): void;
  5107. /**
  5108. * Specifies if two material defines are equal
  5109. * @param other - A material define instance to compare to
  5110. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5111. */
  5112. isEqual(other: MaterialDefines): boolean;
  5113. /**
  5114. * Clones this instance's defines to another instance
  5115. * @param other - material defines to clone values to
  5116. */
  5117. cloneTo(other: MaterialDefines): void;
  5118. /**
  5119. * Resets the material define values
  5120. */
  5121. reset(): void;
  5122. /**
  5123. * Converts the material define values to a string
  5124. * @returns - String of material define information
  5125. */
  5126. toString(): string;
  5127. }
  5128. }
  5129. declare module "babylonjs/Misc/performanceMonitor" {
  5130. /**
  5131. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5132. */
  5133. export class PerformanceMonitor {
  5134. private _enabled;
  5135. private _rollingFrameTime;
  5136. private _lastFrameTimeMs;
  5137. /**
  5138. * constructor
  5139. * @param frameSampleSize The number of samples required to saturate the sliding window
  5140. */
  5141. constructor(frameSampleSize?: number);
  5142. /**
  5143. * Samples current frame
  5144. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5145. */
  5146. sampleFrame(timeMs?: number): void;
  5147. /**
  5148. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5149. */
  5150. readonly averageFrameTime: number;
  5151. /**
  5152. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5153. */
  5154. readonly averageFrameTimeVariance: number;
  5155. /**
  5156. * Returns the frame time of the most recent frame
  5157. */
  5158. readonly instantaneousFrameTime: number;
  5159. /**
  5160. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5161. */
  5162. readonly averageFPS: number;
  5163. /**
  5164. * Returns the average framerate in frames per second using the most recent frame time
  5165. */
  5166. readonly instantaneousFPS: number;
  5167. /**
  5168. * Returns true if enough samples have been taken to completely fill the sliding window
  5169. */
  5170. readonly isSaturated: boolean;
  5171. /**
  5172. * Enables contributions to the sliding window sample set
  5173. */
  5174. enable(): void;
  5175. /**
  5176. * Disables contributions to the sliding window sample set
  5177. * Samples will not be interpolated over the disabled period
  5178. */
  5179. disable(): void;
  5180. /**
  5181. * Returns true if sampling is enabled
  5182. */
  5183. readonly isEnabled: boolean;
  5184. /**
  5185. * Resets performance monitor
  5186. */
  5187. reset(): void;
  5188. }
  5189. /**
  5190. * RollingAverage
  5191. *
  5192. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5193. */
  5194. export class RollingAverage {
  5195. /**
  5196. * Current average
  5197. */
  5198. average: number;
  5199. /**
  5200. * Current variance
  5201. */
  5202. variance: number;
  5203. protected _samples: Array<number>;
  5204. protected _sampleCount: number;
  5205. protected _pos: number;
  5206. protected _m2: number;
  5207. /**
  5208. * constructor
  5209. * @param length The number of samples required to saturate the sliding window
  5210. */
  5211. constructor(length: number);
  5212. /**
  5213. * Adds a sample to the sample set
  5214. * @param v The sample value
  5215. */
  5216. add(v: number): void;
  5217. /**
  5218. * Returns previously added values or null if outside of history or outside the sliding window domain
  5219. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5220. * @return Value previously recorded with add() or null if outside of range
  5221. */
  5222. history(i: number): number;
  5223. /**
  5224. * Returns true if enough samples have been taken to completely fill the sliding window
  5225. * @return true if sample-set saturated
  5226. */
  5227. isSaturated(): boolean;
  5228. /**
  5229. * Resets the rolling average (equivalent to 0 samples taken so far)
  5230. */
  5231. reset(): void;
  5232. /**
  5233. * Wraps a value around the sample range boundaries
  5234. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5235. * @return Wrapped position in sample range
  5236. */
  5237. protected _wrapPosition(i: number): number;
  5238. }
  5239. }
  5240. declare module "babylonjs/Misc/stringDictionary" {
  5241. import { Nullable } from "babylonjs/types";
  5242. /**
  5243. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5244. * The underlying implementation relies on an associative array to ensure the best performances.
  5245. * The value can be anything including 'null' but except 'undefined'
  5246. */
  5247. export class StringDictionary<T> {
  5248. /**
  5249. * This will clear this dictionary and copy the content from the 'source' one.
  5250. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5251. * @param source the dictionary to take the content from and copy to this dictionary
  5252. */
  5253. copyFrom(source: StringDictionary<T>): void;
  5254. /**
  5255. * Get a value based from its key
  5256. * @param key the given key to get the matching value from
  5257. * @return the value if found, otherwise undefined is returned
  5258. */
  5259. get(key: string): T | undefined;
  5260. /**
  5261. * Get a value from its key or add it if it doesn't exist.
  5262. * This method will ensure you that a given key/data will be present in the dictionary.
  5263. * @param key the given key to get the matching value from
  5264. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5265. * The factory will only be invoked if there's no data for the given key.
  5266. * @return the value corresponding to the key.
  5267. */
  5268. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5269. /**
  5270. * Get a value from its key if present in the dictionary otherwise add it
  5271. * @param key the key to get the value from
  5272. * @param val if there's no such key/value pair in the dictionary add it with this value
  5273. * @return the value corresponding to the key
  5274. */
  5275. getOrAdd(key: string, val: T): T;
  5276. /**
  5277. * Check if there's a given key in the dictionary
  5278. * @param key the key to check for
  5279. * @return true if the key is present, false otherwise
  5280. */
  5281. contains(key: string): boolean;
  5282. /**
  5283. * Add a new key and its corresponding value
  5284. * @param key the key to add
  5285. * @param value the value corresponding to the key
  5286. * @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
  5287. */
  5288. add(key: string, value: T): boolean;
  5289. /**
  5290. * Update a specific value associated to a key
  5291. * @param key defines the key to use
  5292. * @param value defines the value to store
  5293. * @returns true if the value was updated (or false if the key was not found)
  5294. */
  5295. set(key: string, value: T): boolean;
  5296. /**
  5297. * Get the element of the given key and remove it from the dictionary
  5298. * @param key defines the key to search
  5299. * @returns the value associated with the key or null if not found
  5300. */
  5301. getAndRemove(key: string): Nullable<T>;
  5302. /**
  5303. * Remove a key/value from the dictionary.
  5304. * @param key the key to remove
  5305. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5306. */
  5307. remove(key: string): boolean;
  5308. /**
  5309. * Clear the whole content of the dictionary
  5310. */
  5311. clear(): void;
  5312. /**
  5313. * Gets the current count
  5314. */
  5315. readonly count: number;
  5316. /**
  5317. * Execute a callback on each key/val of the dictionary.
  5318. * Note that you can remove any element in this dictionary in the callback implementation
  5319. * @param callback the callback to execute on a given key/value pair
  5320. */
  5321. forEach(callback: (key: string, val: T) => void): void;
  5322. /**
  5323. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5324. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5325. * Note that you can remove any element in this dictionary in the callback implementation
  5326. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5327. * @returns the first item
  5328. */
  5329. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5330. private _count;
  5331. private _data;
  5332. }
  5333. }
  5334. declare module "babylonjs/Misc/promise" {
  5335. /**
  5336. * Helper class that provides a small promise polyfill
  5337. */
  5338. export class PromisePolyfill {
  5339. /**
  5340. * Static function used to check if the polyfill is required
  5341. * If this is the case then the function will inject the polyfill to window.Promise
  5342. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5343. */
  5344. static Apply(force?: boolean): void;
  5345. }
  5346. }
  5347. declare module "babylonjs/Meshes/buffer" {
  5348. import { Nullable, DataArray } from "babylonjs/types";
  5349. /**
  5350. * Class used to store data that will be store in GPU memory
  5351. */
  5352. export class Buffer {
  5353. private _engine;
  5354. private _buffer;
  5355. /** @hidden */
  5356. _data: Nullable<DataArray>;
  5357. private _updatable;
  5358. private _instanced;
  5359. /**
  5360. * Gets the byte stride.
  5361. */
  5362. readonly byteStride: number;
  5363. /**
  5364. * Constructor
  5365. * @param engine the engine
  5366. * @param data the data to use for this buffer
  5367. * @param updatable whether the data is updatable
  5368. * @param stride the stride (optional)
  5369. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5370. * @param instanced whether the buffer is instanced (optional)
  5371. * @param useBytes set to true if the stride in in bytes (optional)
  5372. */
  5373. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5374. /**
  5375. * Create a new VertexBuffer based on the current buffer
  5376. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5377. * @param offset defines offset in the buffer (0 by default)
  5378. * @param size defines the size in floats of attributes (position is 3 for instance)
  5379. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5380. * @param instanced defines if the vertex buffer contains indexed data
  5381. * @param useBytes defines if the offset and stride are in bytes
  5382. * @returns the new vertex buffer
  5383. */
  5384. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5385. /**
  5386. * Gets a boolean indicating if the Buffer is updatable?
  5387. * @returns true if the buffer is updatable
  5388. */
  5389. isUpdatable(): boolean;
  5390. /**
  5391. * Gets current buffer's data
  5392. * @returns a DataArray or null
  5393. */
  5394. getData(): Nullable<DataArray>;
  5395. /**
  5396. * Gets underlying native buffer
  5397. * @returns underlying native buffer
  5398. */
  5399. getBuffer(): Nullable<WebGLBuffer>;
  5400. /**
  5401. * Gets the stride in float32 units (i.e. byte stride / 4).
  5402. * May not be an integer if the byte stride is not divisible by 4.
  5403. * DEPRECATED. Use byteStride instead.
  5404. * @returns the stride in float32 units
  5405. */
  5406. getStrideSize(): number;
  5407. /**
  5408. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5409. * @param data defines the data to store
  5410. */
  5411. create(data?: Nullable<DataArray>): void;
  5412. /** @hidden */
  5413. _rebuild(): void;
  5414. /**
  5415. * Update current buffer data
  5416. * @param data defines the data to store
  5417. */
  5418. update(data: DataArray): void;
  5419. /**
  5420. * Updates the data directly.
  5421. * @param data the new data
  5422. * @param offset the new offset
  5423. * @param vertexCount the vertex count (optional)
  5424. * @param useBytes set to true if the offset is in bytes
  5425. */
  5426. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5427. /**
  5428. * Release all resources
  5429. */
  5430. dispose(): void;
  5431. }
  5432. /**
  5433. * Specialized buffer used to store vertex data
  5434. */
  5435. export class VertexBuffer {
  5436. /** @hidden */
  5437. _buffer: Buffer;
  5438. private _kind;
  5439. private _size;
  5440. private _ownsBuffer;
  5441. private _instanced;
  5442. private _instanceDivisor;
  5443. /**
  5444. * The byte type.
  5445. */
  5446. static readonly BYTE: number;
  5447. /**
  5448. * The unsigned byte type.
  5449. */
  5450. static readonly UNSIGNED_BYTE: number;
  5451. /**
  5452. * The short type.
  5453. */
  5454. static readonly SHORT: number;
  5455. /**
  5456. * The unsigned short type.
  5457. */
  5458. static readonly UNSIGNED_SHORT: number;
  5459. /**
  5460. * The integer type.
  5461. */
  5462. static readonly INT: number;
  5463. /**
  5464. * The unsigned integer type.
  5465. */
  5466. static readonly UNSIGNED_INT: number;
  5467. /**
  5468. * The float type.
  5469. */
  5470. static readonly FLOAT: number;
  5471. /**
  5472. * Gets or sets the instance divisor when in instanced mode
  5473. */
  5474. instanceDivisor: number;
  5475. /**
  5476. * Gets the byte stride.
  5477. */
  5478. readonly byteStride: number;
  5479. /**
  5480. * Gets the byte offset.
  5481. */
  5482. readonly byteOffset: number;
  5483. /**
  5484. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5485. */
  5486. readonly normalized: boolean;
  5487. /**
  5488. * Gets the data type of each component in the array.
  5489. */
  5490. readonly type: number;
  5491. /**
  5492. * Constructor
  5493. * @param engine the engine
  5494. * @param data the data to use for this vertex buffer
  5495. * @param kind the vertex buffer kind
  5496. * @param updatable whether the data is updatable
  5497. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5498. * @param stride the stride (optional)
  5499. * @param instanced whether the buffer is instanced (optional)
  5500. * @param offset the offset of the data (optional)
  5501. * @param size the number of components (optional)
  5502. * @param type the type of the component (optional)
  5503. * @param normalized whether the data contains normalized data (optional)
  5504. * @param useBytes set to true if stride and offset are in bytes (optional)
  5505. */
  5506. 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);
  5507. /** @hidden */
  5508. _rebuild(): void;
  5509. /**
  5510. * Returns the kind of the VertexBuffer (string)
  5511. * @returns a string
  5512. */
  5513. getKind(): string;
  5514. /**
  5515. * Gets a boolean indicating if the VertexBuffer is updatable?
  5516. * @returns true if the buffer is updatable
  5517. */
  5518. isUpdatable(): boolean;
  5519. /**
  5520. * Gets current buffer's data
  5521. * @returns a DataArray or null
  5522. */
  5523. getData(): Nullable<DataArray>;
  5524. /**
  5525. * Gets underlying native buffer
  5526. * @returns underlying native buffer
  5527. */
  5528. getBuffer(): Nullable<WebGLBuffer>;
  5529. /**
  5530. * Gets the stride in float32 units (i.e. byte stride / 4).
  5531. * May not be an integer if the byte stride is not divisible by 4.
  5532. * DEPRECATED. Use byteStride instead.
  5533. * @returns the stride in float32 units
  5534. */
  5535. getStrideSize(): number;
  5536. /**
  5537. * Returns the offset as a multiple of the type byte length.
  5538. * DEPRECATED. Use byteOffset instead.
  5539. * @returns the offset in bytes
  5540. */
  5541. getOffset(): number;
  5542. /**
  5543. * Returns the number of components per vertex attribute (integer)
  5544. * @returns the size in float
  5545. */
  5546. getSize(): number;
  5547. /**
  5548. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5549. * @returns true if this buffer is instanced
  5550. */
  5551. getIsInstanced(): boolean;
  5552. /**
  5553. * Returns the instancing divisor, zero for non-instanced (integer).
  5554. * @returns a number
  5555. */
  5556. getInstanceDivisor(): number;
  5557. /**
  5558. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5559. * @param data defines the data to store
  5560. */
  5561. create(data?: DataArray): void;
  5562. /**
  5563. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5564. * This function will create a new buffer if the current one is not updatable
  5565. * @param data defines the data to store
  5566. */
  5567. update(data: DataArray): void;
  5568. /**
  5569. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5570. * Returns the directly updated WebGLBuffer.
  5571. * @param data the new data
  5572. * @param offset the new offset
  5573. * @param useBytes set to true if the offset is in bytes
  5574. */
  5575. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5576. /**
  5577. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5578. */
  5579. dispose(): void;
  5580. /**
  5581. * Enumerates each value of this vertex buffer as numbers.
  5582. * @param count the number of values to enumerate
  5583. * @param callback the callback function called for each value
  5584. */
  5585. forEach(count: number, callback: (value: number, index: number) => void): void;
  5586. /**
  5587. * Positions
  5588. */
  5589. static readonly PositionKind: string;
  5590. /**
  5591. * Normals
  5592. */
  5593. static readonly NormalKind: string;
  5594. /**
  5595. * Tangents
  5596. */
  5597. static readonly TangentKind: string;
  5598. /**
  5599. * Texture coordinates
  5600. */
  5601. static readonly UVKind: string;
  5602. /**
  5603. * Texture coordinates 2
  5604. */
  5605. static readonly UV2Kind: string;
  5606. /**
  5607. * Texture coordinates 3
  5608. */
  5609. static readonly UV3Kind: string;
  5610. /**
  5611. * Texture coordinates 4
  5612. */
  5613. static readonly UV4Kind: string;
  5614. /**
  5615. * Texture coordinates 5
  5616. */
  5617. static readonly UV5Kind: string;
  5618. /**
  5619. * Texture coordinates 6
  5620. */
  5621. static readonly UV6Kind: string;
  5622. /**
  5623. * Colors
  5624. */
  5625. static readonly ColorKind: string;
  5626. /**
  5627. * Matrix indices (for bones)
  5628. */
  5629. static readonly MatricesIndicesKind: string;
  5630. /**
  5631. * Matrix weights (for bones)
  5632. */
  5633. static readonly MatricesWeightsKind: string;
  5634. /**
  5635. * Additional matrix indices (for bones)
  5636. */
  5637. static readonly MatricesIndicesExtraKind: string;
  5638. /**
  5639. * Additional matrix weights (for bones)
  5640. */
  5641. static readonly MatricesWeightsExtraKind: string;
  5642. /**
  5643. * Deduces the stride given a kind.
  5644. * @param kind The kind string to deduce
  5645. * @returns The deduced stride
  5646. */
  5647. static DeduceStride(kind: string): number;
  5648. /**
  5649. * Gets the byte length of the given type.
  5650. * @param type the type
  5651. * @returns the number of bytes
  5652. */
  5653. static GetTypeByteLength(type: number): number;
  5654. /**
  5655. * Enumerates each value of the given parameters as numbers.
  5656. * @param data the data to enumerate
  5657. * @param byteOffset the byte offset of the data
  5658. * @param byteStride the byte stride of the data
  5659. * @param componentCount the number of components per element
  5660. * @param componentType the type of the component
  5661. * @param count the total number of components
  5662. * @param normalized whether the data is normalized
  5663. * @param callback the callback function called for each value
  5664. */
  5665. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5666. private static _GetFloatValue;
  5667. }
  5668. }
  5669. declare module "babylonjs/Maths/sphericalPolynomial" {
  5670. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5671. /**
  5672. * Class representing spherical polynomial coefficients to the 3rd degree
  5673. */
  5674. export class SphericalPolynomial {
  5675. /**
  5676. * The x coefficients of the spherical polynomial
  5677. */
  5678. x: Vector3;
  5679. /**
  5680. * The y coefficients of the spherical polynomial
  5681. */
  5682. y: Vector3;
  5683. /**
  5684. * The z coefficients of the spherical polynomial
  5685. */
  5686. z: Vector3;
  5687. /**
  5688. * The xx coefficients of the spherical polynomial
  5689. */
  5690. xx: Vector3;
  5691. /**
  5692. * The yy coefficients of the spherical polynomial
  5693. */
  5694. yy: Vector3;
  5695. /**
  5696. * The zz coefficients of the spherical polynomial
  5697. */
  5698. zz: Vector3;
  5699. /**
  5700. * The xy coefficients of the spherical polynomial
  5701. */
  5702. xy: Vector3;
  5703. /**
  5704. * The yz coefficients of the spherical polynomial
  5705. */
  5706. yz: Vector3;
  5707. /**
  5708. * The zx coefficients of the spherical polynomial
  5709. */
  5710. zx: Vector3;
  5711. /**
  5712. * Adds an ambient color to the spherical polynomial
  5713. * @param color the color to add
  5714. */
  5715. addAmbient(color: Color3): void;
  5716. /**
  5717. * Scales the spherical polynomial by the given amount
  5718. * @param scale the amount to scale
  5719. */
  5720. scale(scale: number): void;
  5721. /**
  5722. * Gets the spherical polynomial from harmonics
  5723. * @param harmonics the spherical harmonics
  5724. * @returns the spherical polynomial
  5725. */
  5726. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5727. /**
  5728. * Constructs a spherical polynomial from an array.
  5729. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5733. }
  5734. /**
  5735. * Class representing spherical harmonics coefficients to the 3rd degree
  5736. */
  5737. export class SphericalHarmonics {
  5738. /**
  5739. * The l0,0 coefficients of the spherical harmonics
  5740. */
  5741. l00: Vector3;
  5742. /**
  5743. * The l1,-1 coefficients of the spherical harmonics
  5744. */
  5745. l1_1: Vector3;
  5746. /**
  5747. * The l1,0 coefficients of the spherical harmonics
  5748. */
  5749. l10: Vector3;
  5750. /**
  5751. * The l1,1 coefficients of the spherical harmonics
  5752. */
  5753. l11: Vector3;
  5754. /**
  5755. * The l2,-2 coefficients of the spherical harmonics
  5756. */
  5757. l2_2: Vector3;
  5758. /**
  5759. * The l2,-1 coefficients of the spherical harmonics
  5760. */
  5761. l2_1: Vector3;
  5762. /**
  5763. * The l2,0 coefficients of the spherical harmonics
  5764. */
  5765. l20: Vector3;
  5766. /**
  5767. * The l2,1 coefficients of the spherical harmonics
  5768. */
  5769. l21: Vector3;
  5770. /**
  5771. * The l2,2 coefficients of the spherical harmonics
  5772. */
  5773. lL22: Vector3;
  5774. /**
  5775. * Adds a light to the spherical harmonics
  5776. * @param direction the direction of the light
  5777. * @param color the color of the light
  5778. * @param deltaSolidAngle the delta solid angle of the light
  5779. */
  5780. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5781. /**
  5782. * Scales the spherical harmonics by the given amount
  5783. * @param scale the amount to scale
  5784. */
  5785. scale(scale: number): void;
  5786. /**
  5787. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5788. *
  5789. * ```
  5790. * E_lm = A_l * L_lm
  5791. * ```
  5792. *
  5793. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5794. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5795. * the scaling factors are given in equation 9.
  5796. */
  5797. convertIncidentRadianceToIrradiance(): void;
  5798. /**
  5799. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5800. *
  5801. * ```
  5802. * L = (1/pi) * E * rho
  5803. * ```
  5804. *
  5805. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5806. */
  5807. convertIrradianceToLambertianRadiance(): void;
  5808. /**
  5809. * Gets the spherical harmonics from polynomial
  5810. * @param polynomial the spherical polynomial
  5811. * @returns the spherical harmonics
  5812. */
  5813. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5814. /**
  5815. * Constructs a spherical harmonics from an array.
  5816. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5820. }
  5821. }
  5822. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5823. import { Nullable } from "babylonjs/types";
  5824. /**
  5825. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5826. */
  5827. export interface CubeMapInfo {
  5828. /**
  5829. * The pixel array for the front face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. front: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the back face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. back: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The pixel array for the left face.
  5840. * This is stored in format, left to right, up to down format.
  5841. */
  5842. left: Nullable<ArrayBufferView>;
  5843. /**
  5844. * The pixel array for the right face.
  5845. * This is stored in format, left to right, up to down format.
  5846. */
  5847. right: Nullable<ArrayBufferView>;
  5848. /**
  5849. * The pixel array for the up face.
  5850. * This is stored in format, left to right, up to down format.
  5851. */
  5852. up: Nullable<ArrayBufferView>;
  5853. /**
  5854. * The pixel array for the down face.
  5855. * This is stored in format, left to right, up to down format.
  5856. */
  5857. down: Nullable<ArrayBufferView>;
  5858. /**
  5859. * The size of the cubemap stored.
  5860. *
  5861. * Each faces will be size * size pixels.
  5862. */
  5863. size: number;
  5864. /**
  5865. * The format of the texture.
  5866. *
  5867. * RGBA, RGB.
  5868. */
  5869. format: number;
  5870. /**
  5871. * The type of the texture data.
  5872. *
  5873. * UNSIGNED_INT, FLOAT.
  5874. */
  5875. type: number;
  5876. /**
  5877. * Specifies whether the texture is in gamma space.
  5878. */
  5879. gammaSpace: boolean;
  5880. }
  5881. /**
  5882. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5883. */
  5884. export class PanoramaToCubeMapTools {
  5885. private static FACE_FRONT;
  5886. private static FACE_BACK;
  5887. private static FACE_RIGHT;
  5888. private static FACE_LEFT;
  5889. private static FACE_DOWN;
  5890. private static FACE_UP;
  5891. /**
  5892. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5893. *
  5894. * @param float32Array The source data.
  5895. * @param inputWidth The width of the input panorama.
  5896. * @param inputHeight The height of the input panorama.
  5897. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5898. * @return The cubemap data
  5899. */
  5900. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5901. private static CreateCubemapTexture;
  5902. private static CalcProjectionSpherical;
  5903. }
  5904. }
  5905. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5906. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5908. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5909. /**
  5910. * Helper class dealing with the extraction of spherical polynomial dataArray
  5911. * from a cube map.
  5912. */
  5913. export class CubeMapToSphericalPolynomialTools {
  5914. private static FileFaces;
  5915. /**
  5916. * Converts a texture to the according Spherical Polynomial data.
  5917. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5918. *
  5919. * @param texture The texture to extract the information from.
  5920. * @return The Spherical Polynomial data.
  5921. */
  5922. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5923. /**
  5924. * Converts a cubemap to the according Spherical Polynomial data.
  5925. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5926. *
  5927. * @param cubeInfo The Cube map to extract the information from.
  5928. * @return The Spherical Polynomial data.
  5929. */
  5930. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5931. }
  5932. }
  5933. declare module "babylonjs/Engines/engineStore" {
  5934. import { Nullable } from "babylonjs/types";
  5935. import { Engine } from "babylonjs/Engines/engine";
  5936. import { Scene } from "babylonjs/scene";
  5937. /**
  5938. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5939. * during the life time of the application.
  5940. */
  5941. export class EngineStore {
  5942. /** Gets the list of created engines */
  5943. static Instances: import("babylonjs/Engines/engine").Engine[];
  5944. /**
  5945. * Gets the latest created engine
  5946. */
  5947. static readonly LastCreatedEngine: Nullable<Engine>;
  5948. /**
  5949. * Gets the latest created scene
  5950. */
  5951. static readonly LastCreatedScene: Nullable<Scene>;
  5952. }
  5953. }
  5954. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5955. /**
  5956. * Define options used to create a render target texture
  5957. */
  5958. export class RenderTargetCreationOptions {
  5959. /**
  5960. * Specifies is mipmaps must be generated
  5961. */
  5962. generateMipMaps?: boolean;
  5963. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5964. generateDepthBuffer?: boolean;
  5965. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5966. generateStencilBuffer?: boolean;
  5967. /** Defines texture type (int by default) */
  5968. type?: number;
  5969. /** Defines sampling mode (trilinear by default) */
  5970. samplingMode?: number;
  5971. /** Defines format (RGBA by default) */
  5972. format?: number;
  5973. }
  5974. }
  5975. declare module "babylonjs/States/alphaCullingState" {
  5976. /**
  5977. * @hidden
  5978. **/
  5979. export class _AlphaState {
  5980. private _isAlphaBlendDirty;
  5981. private _isBlendFunctionParametersDirty;
  5982. private _isBlendEquationParametersDirty;
  5983. private _isBlendConstantsDirty;
  5984. private _alphaBlend;
  5985. private _blendFunctionParameters;
  5986. private _blendEquationParameters;
  5987. private _blendConstants;
  5988. /**
  5989. * Initializes the state.
  5990. */
  5991. constructor();
  5992. readonly isDirty: boolean;
  5993. alphaBlend: boolean;
  5994. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5995. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5996. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5997. reset(): void;
  5998. apply(gl: WebGLRenderingContext): void;
  5999. }
  6000. }
  6001. declare module "babylonjs/States/depthCullingState" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * @hidden
  6005. **/
  6006. export class _DepthCullingState {
  6007. private _isDepthTestDirty;
  6008. private _isDepthMaskDirty;
  6009. private _isDepthFuncDirty;
  6010. private _isCullFaceDirty;
  6011. private _isCullDirty;
  6012. private _isZOffsetDirty;
  6013. private _isFrontFaceDirty;
  6014. private _depthTest;
  6015. private _depthMask;
  6016. private _depthFunc;
  6017. private _cull;
  6018. private _cullFace;
  6019. private _zOffset;
  6020. private _frontFace;
  6021. /**
  6022. * Initializes the state.
  6023. */
  6024. constructor();
  6025. readonly isDirty: boolean;
  6026. zOffset: number;
  6027. cullFace: Nullable<number>;
  6028. cull: Nullable<boolean>;
  6029. depthFunc: Nullable<number>;
  6030. depthMask: boolean;
  6031. depthTest: boolean;
  6032. frontFace: Nullable<number>;
  6033. reset(): void;
  6034. apply(gl: WebGLRenderingContext): void;
  6035. }
  6036. }
  6037. declare module "babylonjs/States/stencilState" {
  6038. /**
  6039. * @hidden
  6040. **/
  6041. export class _StencilState {
  6042. /** 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 */
  6043. static readonly ALWAYS: number;
  6044. /** Passed to stencilOperation to specify that stencil value must be kept */
  6045. static readonly KEEP: number;
  6046. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6047. static readonly REPLACE: number;
  6048. private _isStencilTestDirty;
  6049. private _isStencilMaskDirty;
  6050. private _isStencilFuncDirty;
  6051. private _isStencilOpDirty;
  6052. private _stencilTest;
  6053. private _stencilMask;
  6054. private _stencilFunc;
  6055. private _stencilFuncRef;
  6056. private _stencilFuncMask;
  6057. private _stencilOpStencilFail;
  6058. private _stencilOpDepthFail;
  6059. private _stencilOpStencilDepthPass;
  6060. readonly isDirty: boolean;
  6061. stencilFunc: number;
  6062. stencilFuncRef: number;
  6063. stencilFuncMask: number;
  6064. stencilOpStencilFail: number;
  6065. stencilOpDepthFail: number;
  6066. stencilOpStencilDepthPass: number;
  6067. stencilMask: number;
  6068. stencilTest: boolean;
  6069. constructor();
  6070. reset(): void;
  6071. apply(gl: WebGLRenderingContext): void;
  6072. }
  6073. }
  6074. declare module "babylonjs/States/index" {
  6075. export * from "babylonjs/States/alphaCullingState";
  6076. export * from "babylonjs/States/depthCullingState";
  6077. export * from "babylonjs/States/stencilState";
  6078. }
  6079. declare module "babylonjs/Instrumentation/timeToken" {
  6080. import { Nullable } from "babylonjs/types";
  6081. /**
  6082. * @hidden
  6083. **/
  6084. export class _TimeToken {
  6085. _startTimeQuery: Nullable<WebGLQuery>;
  6086. _endTimeQuery: Nullable<WebGLQuery>;
  6087. _timeElapsedQuery: Nullable<WebGLQuery>;
  6088. _timeElapsedQueryEnded: boolean;
  6089. }
  6090. }
  6091. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6092. import { Nullable } from "babylonjs/types";
  6093. /**
  6094. * Internal interface used to track InternalTexture already bound to the GL context
  6095. */
  6096. export interface IInternalTextureTracker {
  6097. /**
  6098. * Gets or set the previous tracker in the list
  6099. */
  6100. previous: Nullable<IInternalTextureTracker>;
  6101. /**
  6102. * Gets or set the next tracker in the list
  6103. */
  6104. next: Nullable<IInternalTextureTracker>;
  6105. }
  6106. /**
  6107. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6108. */
  6109. export class DummyInternalTextureTracker {
  6110. /**
  6111. * Gets or set the previous tracker in the list
  6112. */
  6113. previous: Nullable<IInternalTextureTracker>;
  6114. /**
  6115. * Gets or set the next tracker in the list
  6116. */
  6117. next: Nullable<IInternalTextureTracker>;
  6118. }
  6119. }
  6120. declare module "babylonjs/Materials/Textures/internalTexture" {
  6121. import { Observable } from "babylonjs/Misc/observable";
  6122. import { Nullable, int } from "babylonjs/types";
  6123. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6124. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6125. import { Engine } from "babylonjs/Engines/engine";
  6126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6127. /**
  6128. * Class used to store data associated with WebGL texture data for the engine
  6129. * This class should not be used directly
  6130. */
  6131. export class InternalTexture implements IInternalTextureTracker {
  6132. /** hidden */
  6133. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6134. /**
  6135. * The source of the texture data is unknown
  6136. */
  6137. static DATASOURCE_UNKNOWN: number;
  6138. /**
  6139. * Texture data comes from an URL
  6140. */
  6141. static DATASOURCE_URL: number;
  6142. /**
  6143. * Texture data is only used for temporary storage
  6144. */
  6145. static DATASOURCE_TEMP: number;
  6146. /**
  6147. * Texture data comes from raw data (ArrayBuffer)
  6148. */
  6149. static DATASOURCE_RAW: number;
  6150. /**
  6151. * Texture content is dynamic (video or dynamic texture)
  6152. */
  6153. static DATASOURCE_DYNAMIC: number;
  6154. /**
  6155. * Texture content is generated by rendering to it
  6156. */
  6157. static DATASOURCE_RENDERTARGET: number;
  6158. /**
  6159. * Texture content is part of a multi render target process
  6160. */
  6161. static DATASOURCE_MULTIRENDERTARGET: number;
  6162. /**
  6163. * Texture data comes from a cube data file
  6164. */
  6165. static DATASOURCE_CUBE: number;
  6166. /**
  6167. * Texture data comes from a raw cube data
  6168. */
  6169. static DATASOURCE_CUBERAW: number;
  6170. /**
  6171. * Texture data come from a prefiltered cube data file
  6172. */
  6173. static DATASOURCE_CUBEPREFILTERED: number;
  6174. /**
  6175. * Texture content is raw 3D data
  6176. */
  6177. static DATASOURCE_RAW3D: number;
  6178. /**
  6179. * Texture content is a depth texture
  6180. */
  6181. static DATASOURCE_DEPTHTEXTURE: number;
  6182. /**
  6183. * Texture data comes from a raw cube data encoded with RGBD
  6184. */
  6185. static DATASOURCE_CUBERAW_RGBD: number;
  6186. /**
  6187. * Defines if the texture is ready
  6188. */
  6189. isReady: boolean;
  6190. /**
  6191. * Defines if the texture is a cube texture
  6192. */
  6193. isCube: boolean;
  6194. /**
  6195. * Defines if the texture contains 3D data
  6196. */
  6197. is3D: boolean;
  6198. /**
  6199. * Gets the URL used to load this texture
  6200. */
  6201. url: string;
  6202. /**
  6203. * Gets the sampling mode of the texture
  6204. */
  6205. samplingMode: number;
  6206. /**
  6207. * Gets a boolean indicating if the texture needs mipmaps generation
  6208. */
  6209. generateMipMaps: boolean;
  6210. /**
  6211. * Gets the number of samples used by the texture (WebGL2+ only)
  6212. */
  6213. samples: number;
  6214. /**
  6215. * Gets the type of the texture (int, float...)
  6216. */
  6217. type: number;
  6218. /**
  6219. * Gets the format of the texture (RGB, RGBA...)
  6220. */
  6221. format: number;
  6222. /**
  6223. * Observable called when the texture is loaded
  6224. */
  6225. onLoadedObservable: Observable<InternalTexture>;
  6226. /**
  6227. * Gets the width of the texture
  6228. */
  6229. width: number;
  6230. /**
  6231. * Gets the height of the texture
  6232. */
  6233. height: number;
  6234. /**
  6235. * Gets the depth of the texture
  6236. */
  6237. depth: number;
  6238. /**
  6239. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6240. */
  6241. baseWidth: number;
  6242. /**
  6243. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6244. */
  6245. baseHeight: number;
  6246. /**
  6247. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6248. */
  6249. baseDepth: number;
  6250. /**
  6251. * Gets a boolean indicating if the texture is inverted on Y axis
  6252. */
  6253. invertY: boolean;
  6254. /**
  6255. * Gets or set the previous tracker in the list
  6256. */
  6257. previous: Nullable<IInternalTextureTracker>;
  6258. /**
  6259. * Gets or set the next tracker in the list
  6260. */
  6261. next: Nullable<IInternalTextureTracker>;
  6262. /** @hidden */
  6263. _invertVScale: boolean;
  6264. /** @hidden */
  6265. _initialSlot: number;
  6266. /** @hidden */
  6267. _designatedSlot: number;
  6268. /** @hidden */
  6269. _dataSource: number;
  6270. /** @hidden */
  6271. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6272. /** @hidden */
  6273. _bufferView: Nullable<ArrayBufferView>;
  6274. /** @hidden */
  6275. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6276. /** @hidden */
  6277. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6278. /** @hidden */
  6279. _size: number;
  6280. /** @hidden */
  6281. _extension: string;
  6282. /** @hidden */
  6283. _files: Nullable<string[]>;
  6284. /** @hidden */
  6285. _workingCanvas: HTMLCanvasElement;
  6286. /** @hidden */
  6287. _workingContext: CanvasRenderingContext2D;
  6288. /** @hidden */
  6289. _framebuffer: Nullable<WebGLFramebuffer>;
  6290. /** @hidden */
  6291. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6292. /** @hidden */
  6293. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6294. /** @hidden */
  6295. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6296. /** @hidden */
  6297. _attachments: Nullable<number[]>;
  6298. /** @hidden */
  6299. _cachedCoordinatesMode: Nullable<number>;
  6300. /** @hidden */
  6301. _cachedWrapU: Nullable<number>;
  6302. /** @hidden */
  6303. _cachedWrapV: Nullable<number>;
  6304. /** @hidden */
  6305. _cachedWrapR: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6308. /** @hidden */
  6309. _isDisabled: boolean;
  6310. /** @hidden */
  6311. _compression: Nullable<string>;
  6312. /** @hidden */
  6313. _generateStencilBuffer: boolean;
  6314. /** @hidden */
  6315. _generateDepthBuffer: boolean;
  6316. /** @hidden */
  6317. _comparisonFunction: number;
  6318. /** @hidden */
  6319. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6320. /** @hidden */
  6321. _lodGenerationScale: number;
  6322. /** @hidden */
  6323. _lodGenerationOffset: number;
  6324. /** @hidden */
  6325. _lodTextureHigh: BaseTexture;
  6326. /** @hidden */
  6327. _lodTextureMid: BaseTexture;
  6328. /** @hidden */
  6329. _lodTextureLow: BaseTexture;
  6330. /** @hidden */
  6331. _isRGBD: boolean;
  6332. /** @hidden */
  6333. _webGLTexture: Nullable<WebGLTexture>;
  6334. /** @hidden */
  6335. _references: number;
  6336. private _engine;
  6337. /**
  6338. * Gets the Engine the texture belongs to.
  6339. * @returns The babylon engine
  6340. */
  6341. getEngine(): Engine;
  6342. /**
  6343. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6344. */
  6345. readonly dataSource: number;
  6346. /**
  6347. * Creates a new InternalTexture
  6348. * @param engine defines the engine to use
  6349. * @param dataSource defines the type of data that will be used
  6350. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6351. */
  6352. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6353. /**
  6354. * Increments the number of references (ie. the number of Texture that point to it)
  6355. */
  6356. incrementReferences(): void;
  6357. /**
  6358. * Change the size of the texture (not the size of the content)
  6359. * @param width defines the new width
  6360. * @param height defines the new height
  6361. * @param depth defines the new depth (1 by default)
  6362. */
  6363. updateSize(width: int, height: int, depth?: int): void;
  6364. /** @hidden */
  6365. _rebuild(): void;
  6366. /** @hidden */
  6367. _swapAndDie(target: InternalTexture): void;
  6368. /**
  6369. * Dispose the current allocated resources
  6370. */
  6371. dispose(): void;
  6372. }
  6373. }
  6374. declare module "babylonjs/Animations/easing" {
  6375. /**
  6376. * This represents the main contract an easing function should follow.
  6377. * Easing functions are used throughout the animation system.
  6378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6379. */
  6380. export interface IEasingFunction {
  6381. /**
  6382. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6383. * of the easing function.
  6384. * The link below provides some of the most common examples of easing functions.
  6385. * @see https://easings.net/
  6386. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6387. * @returns the corresponding value on the curve defined by the easing function
  6388. */
  6389. ease(gradient: number): number;
  6390. }
  6391. /**
  6392. * Base class used for every default easing function.
  6393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6394. */
  6395. export class EasingFunction implements IEasingFunction {
  6396. /**
  6397. * Interpolation follows the mathematical formula associated with the easing function.
  6398. */
  6399. static readonly EASINGMODE_EASEIN: number;
  6400. /**
  6401. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6402. */
  6403. static readonly EASINGMODE_EASEOUT: number;
  6404. /**
  6405. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6406. */
  6407. static readonly EASINGMODE_EASEINOUT: number;
  6408. private _easingMode;
  6409. /**
  6410. * Sets the easing mode of the current function.
  6411. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6412. */
  6413. setEasingMode(easingMode: number): void;
  6414. /**
  6415. * Gets the current easing mode.
  6416. * @returns the easing mode
  6417. */
  6418. getEasingMode(): number;
  6419. /**
  6420. * @hidden
  6421. */
  6422. easeInCore(gradient: number): number;
  6423. /**
  6424. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6425. * of the easing function.
  6426. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6427. * @returns the corresponding value on the curve defined by the easing function
  6428. */
  6429. ease(gradient: number): number;
  6430. }
  6431. /**
  6432. * Easing function with a circle shape (see link below).
  6433. * @see https://easings.net/#easeInCirc
  6434. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6435. */
  6436. export class CircleEase extends EasingFunction implements IEasingFunction {
  6437. /** @hidden */
  6438. easeInCore(gradient: number): number;
  6439. }
  6440. /**
  6441. * Easing function with a ease back shape (see link below).
  6442. * @see https://easings.net/#easeInBack
  6443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6444. */
  6445. export class BackEase extends EasingFunction implements IEasingFunction {
  6446. /** Defines the amplitude of the function */
  6447. amplitude: number;
  6448. /**
  6449. * Instantiates a back ease easing
  6450. * @see https://easings.net/#easeInBack
  6451. * @param amplitude Defines the amplitude of the function
  6452. */
  6453. constructor(
  6454. /** Defines the amplitude of the function */
  6455. amplitude?: number);
  6456. /** @hidden */
  6457. easeInCore(gradient: number): number;
  6458. }
  6459. /**
  6460. * Easing function with a bouncing shape (see link below).
  6461. * @see https://easings.net/#easeInBounce
  6462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6463. */
  6464. export class BounceEase extends EasingFunction implements IEasingFunction {
  6465. /** Defines the number of bounces */
  6466. bounces: number;
  6467. /** Defines the amplitude of the bounce */
  6468. bounciness: number;
  6469. /**
  6470. * Instantiates a bounce easing
  6471. * @see https://easings.net/#easeInBounce
  6472. * @param bounces Defines the number of bounces
  6473. * @param bounciness Defines the amplitude of the bounce
  6474. */
  6475. constructor(
  6476. /** Defines the number of bounces */
  6477. bounces?: number,
  6478. /** Defines the amplitude of the bounce */
  6479. bounciness?: number);
  6480. /** @hidden */
  6481. easeInCore(gradient: number): number;
  6482. }
  6483. /**
  6484. * Easing function with a power of 3 shape (see link below).
  6485. * @see https://easings.net/#easeInCubic
  6486. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6487. */
  6488. export class CubicEase extends EasingFunction implements IEasingFunction {
  6489. /** @hidden */
  6490. easeInCore(gradient: number): number;
  6491. }
  6492. /**
  6493. * Easing function with an elastic shape (see link below).
  6494. * @see https://easings.net/#easeInElastic
  6495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6496. */
  6497. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6498. /** Defines the number of oscillations*/
  6499. oscillations: number;
  6500. /** Defines the amplitude of the oscillations*/
  6501. springiness: number;
  6502. /**
  6503. * Instantiates an elastic easing function
  6504. * @see https://easings.net/#easeInElastic
  6505. * @param oscillations Defines the number of oscillations
  6506. * @param springiness Defines the amplitude of the oscillations
  6507. */
  6508. constructor(
  6509. /** Defines the number of oscillations*/
  6510. oscillations?: number,
  6511. /** Defines the amplitude of the oscillations*/
  6512. springiness?: number);
  6513. /** @hidden */
  6514. easeInCore(gradient: number): number;
  6515. }
  6516. /**
  6517. * Easing function with an exponential shape (see link below).
  6518. * @see https://easings.net/#easeInExpo
  6519. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6520. */
  6521. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6522. /** Defines the exponent of the function */
  6523. exponent: number;
  6524. /**
  6525. * Instantiates an exponential easing function
  6526. * @see https://easings.net/#easeInExpo
  6527. * @param exponent Defines the exponent of the function
  6528. */
  6529. constructor(
  6530. /** Defines the exponent of the function */
  6531. exponent?: number);
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a power shape (see link below).
  6537. * @see https://easings.net/#easeInQuad
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class PowerEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the power of the function */
  6542. power: number;
  6543. /**
  6544. * Instantiates an power base easing function
  6545. * @see https://easings.net/#easeInQuad
  6546. * @param power Defines the power of the function
  6547. */
  6548. constructor(
  6549. /** Defines the power of the function */
  6550. power?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a power of 2 shape (see link below).
  6556. * @see https://easings.net/#easeInQuad
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a power of 4 shape (see link below).
  6565. * @see https://easings.net/#easeInQuart
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6569. /** @hidden */
  6570. easeInCore(gradient: number): number;
  6571. }
  6572. /**
  6573. * Easing function with a power of 5 shape (see link below).
  6574. * @see https://easings.net/#easeInQuint
  6575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6576. */
  6577. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6578. /** @hidden */
  6579. easeInCore(gradient: number): number;
  6580. }
  6581. /**
  6582. * Easing function with a sin shape (see link below).
  6583. * @see https://easings.net/#easeInSine
  6584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6585. */
  6586. export class SineEase extends EasingFunction implements IEasingFunction {
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a bezier shape (see link below).
  6592. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6596. /** Defines the x component of the start tangent in the bezier curve */
  6597. x1: number;
  6598. /** Defines the y component of the start tangent in the bezier curve */
  6599. y1: number;
  6600. /** Defines the x component of the end tangent in the bezier curve */
  6601. x2: number;
  6602. /** Defines the y component of the end tangent in the bezier curve */
  6603. y2: number;
  6604. /**
  6605. * Instantiates a bezier function
  6606. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6607. * @param x1 Defines the x component of the start tangent in the bezier curve
  6608. * @param y1 Defines the y component of the start tangent in the bezier curve
  6609. * @param x2 Defines the x component of the end tangent in the bezier curve
  6610. * @param y2 Defines the y component of the end tangent in the bezier curve
  6611. */
  6612. constructor(
  6613. /** Defines the x component of the start tangent in the bezier curve */
  6614. x1?: number,
  6615. /** Defines the y component of the start tangent in the bezier curve */
  6616. y1?: number,
  6617. /** Defines the x component of the end tangent in the bezier curve */
  6618. x2?: number,
  6619. /** Defines the y component of the end tangent in the bezier curve */
  6620. y2?: number);
  6621. /** @hidden */
  6622. easeInCore(gradient: number): number;
  6623. }
  6624. }
  6625. declare module "babylonjs/Behaviors/behavior" {
  6626. import { Nullable } from "babylonjs/types";
  6627. /**
  6628. * Interface used to define a behavior
  6629. */
  6630. export interface Behavior<T> {
  6631. /** gets or sets behavior's name */
  6632. name: string;
  6633. /**
  6634. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6635. */
  6636. init(): void;
  6637. /**
  6638. * Called when the behavior is attached to a target
  6639. * @param target defines the target where the behavior is attached to
  6640. */
  6641. attach(target: T): void;
  6642. /**
  6643. * Called when the behavior is detached from its target
  6644. */
  6645. detach(): void;
  6646. }
  6647. /**
  6648. * Interface implemented by classes supporting behaviors
  6649. */
  6650. export interface IBehaviorAware<T> {
  6651. /**
  6652. * Attach a behavior
  6653. * @param behavior defines the behavior to attach
  6654. * @returns the current host
  6655. */
  6656. addBehavior(behavior: Behavior<T>): T;
  6657. /**
  6658. * Remove a behavior from the current object
  6659. * @param behavior defines the behavior to detach
  6660. * @returns the current host
  6661. */
  6662. removeBehavior(behavior: Behavior<T>): T;
  6663. /**
  6664. * Gets a behavior using its name to search
  6665. * @param name defines the name to search
  6666. * @returns the behavior or null if not found
  6667. */
  6668. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6669. }
  6670. }
  6671. declare module "babylonjs/Animations/runtimeAnimation" {
  6672. import { Animation } from "babylonjs/Animations/animation";
  6673. import { Animatable } from "babylonjs/Animations/animatable";
  6674. import { Scene } from "babylonjs/scene";
  6675. /**
  6676. * Defines a runtime animation
  6677. */
  6678. export class RuntimeAnimation {
  6679. private _events;
  6680. /**
  6681. * The current frame of the runtime animation
  6682. */
  6683. private _currentFrame;
  6684. /**
  6685. * The animation used by the runtime animation
  6686. */
  6687. private _animation;
  6688. /**
  6689. * The target of the runtime animation
  6690. */
  6691. private _target;
  6692. /**
  6693. * The initiating animatable
  6694. */
  6695. private _host;
  6696. /**
  6697. * The original value of the runtime animation
  6698. */
  6699. private _originalValue;
  6700. /**
  6701. * The original blend value of the runtime animation
  6702. */
  6703. private _originalBlendValue;
  6704. /**
  6705. * The offsets cache of the runtime animation
  6706. */
  6707. private _offsetsCache;
  6708. /**
  6709. * The high limits cache of the runtime animation
  6710. */
  6711. private _highLimitsCache;
  6712. /**
  6713. * Specifies if the runtime animation has been stopped
  6714. */
  6715. private _stopped;
  6716. /**
  6717. * The blending factor of the runtime animation
  6718. */
  6719. private _blendingFactor;
  6720. /**
  6721. * The BabylonJS scene
  6722. */
  6723. private _scene;
  6724. /**
  6725. * The current value of the runtime animation
  6726. */
  6727. private _currentValue;
  6728. /** @hidden */
  6729. _workValue: any;
  6730. /**
  6731. * The active target of the runtime animation
  6732. */
  6733. private _activeTarget;
  6734. /**
  6735. * The target path of the runtime animation
  6736. */
  6737. private _targetPath;
  6738. /**
  6739. * The weight of the runtime animation
  6740. */
  6741. private _weight;
  6742. /**
  6743. * The ratio offset of the runtime animation
  6744. */
  6745. private _ratioOffset;
  6746. /**
  6747. * The previous delay of the runtime animation
  6748. */
  6749. private _previousDelay;
  6750. /**
  6751. * The previous ratio of the runtime animation
  6752. */
  6753. private _previousRatio;
  6754. /**
  6755. * Gets the current frame of the runtime animation
  6756. */
  6757. readonly currentFrame: number;
  6758. /**
  6759. * Gets the weight of the runtime animation
  6760. */
  6761. readonly weight: number;
  6762. /**
  6763. * Gets the current value of the runtime animation
  6764. */
  6765. readonly currentValue: any;
  6766. /**
  6767. * Gets the target path of the runtime animation
  6768. */
  6769. readonly targetPath: string;
  6770. /**
  6771. * Gets the actual target of the runtime animation
  6772. */
  6773. readonly target: any;
  6774. /**
  6775. * Create a new RuntimeAnimation object
  6776. * @param target defines the target of the animation
  6777. * @param animation defines the source animation object
  6778. * @param scene defines the hosting scene
  6779. * @param host defines the initiating Animatable
  6780. */
  6781. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6782. /**
  6783. * Gets the animation from the runtime animation
  6784. */
  6785. readonly animation: Animation;
  6786. /**
  6787. * Resets the runtime animation to the beginning
  6788. * @param restoreOriginal defines whether to restore the target property to the original value
  6789. */
  6790. reset(restoreOriginal?: boolean): void;
  6791. /**
  6792. * Specifies if the runtime animation is stopped
  6793. * @returns Boolean specifying if the runtime animation is stopped
  6794. */
  6795. isStopped(): boolean;
  6796. /**
  6797. * Disposes of the runtime animation
  6798. */
  6799. dispose(): void;
  6800. /**
  6801. * Interpolates the animation from the current frame
  6802. * @param currentFrame The frame to interpolate the animation to
  6803. * @param repeatCount The number of times that the animation should loop
  6804. * @param loopMode The type of looping mode to use
  6805. * @param offsetValue Animation offset value
  6806. * @param highLimitValue The high limit value
  6807. * @returns The interpolated value
  6808. */
  6809. private _interpolate;
  6810. /**
  6811. * Apply the interpolated value to the target
  6812. * @param currentValue defines the value computed by the animation
  6813. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6814. */
  6815. setValue(currentValue: any, weight?: number): void;
  6816. private _setValue;
  6817. /**
  6818. * Gets the loop pmode of the runtime animation
  6819. * @returns Loop Mode
  6820. */
  6821. private _getCorrectLoopMode;
  6822. /**
  6823. * Move the current animation to a given frame
  6824. * @param frame defines the frame to move to
  6825. */
  6826. goToFrame(frame: number): void;
  6827. /**
  6828. * @hidden Internal use only
  6829. */
  6830. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6831. /**
  6832. * Execute the current animation
  6833. * @param delay defines the delay to add to the current frame
  6834. * @param from defines the lower bound of the animation range
  6835. * @param to defines the upper bound of the animation range
  6836. * @param loop defines if the current animation must loop
  6837. * @param speedRatio defines the current speed ratio
  6838. * @param weight defines the weight of the animation (default is -1 so no weight)
  6839. * @param onLoop optional callback called when animation loops
  6840. * @returns a boolean indicating if the animation is running
  6841. */
  6842. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Animations/animatable" {
  6846. import { Animation } from "babylonjs/Animations/animation";
  6847. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  6848. import { Nullable } from "babylonjs/types";
  6849. import { Observable } from "babylonjs/Misc/observable";
  6850. import { Scene } from "babylonjs/scene";
  6851. /**
  6852. * Class used to store an actual running animation
  6853. */
  6854. export class Animatable {
  6855. /** defines the target object */
  6856. target: any;
  6857. /** defines the starting frame number (default is 0) */
  6858. fromFrame: number;
  6859. /** defines the ending frame number (default is 100) */
  6860. toFrame: number;
  6861. /** defines if the animation must loop (default is false) */
  6862. loopAnimation: boolean;
  6863. /** defines a callback to call when animation ends if it is not looping */
  6864. onAnimationEnd?: (() => void) | null | undefined;
  6865. /** defines a callback to call when animation loops */
  6866. onAnimationLoop?: (() => void) | null | undefined;
  6867. private _localDelayOffset;
  6868. private _pausedDelay;
  6869. private _runtimeAnimations;
  6870. private _paused;
  6871. private _scene;
  6872. private _speedRatio;
  6873. private _weight;
  6874. private _syncRoot;
  6875. /**
  6876. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  6877. * This will only apply for non looping animation (default is true)
  6878. */
  6879. disposeOnEnd: boolean;
  6880. /**
  6881. * Gets a boolean indicating if the animation has started
  6882. */
  6883. animationStarted: boolean;
  6884. /**
  6885. * Observer raised when the animation ends
  6886. */
  6887. onAnimationEndObservable: Observable<Animatable>;
  6888. /**
  6889. * Observer raised when the animation loops
  6890. */
  6891. onAnimationLoopObservable: Observable<Animatable>;
  6892. /**
  6893. * Gets the root Animatable used to synchronize and normalize animations
  6894. */
  6895. readonly syncRoot: Animatable;
  6896. /**
  6897. * Gets the current frame of the first RuntimeAnimation
  6898. * Used to synchronize Animatables
  6899. */
  6900. readonly masterFrame: number;
  6901. /**
  6902. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  6903. */
  6904. weight: number;
  6905. /**
  6906. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  6907. */
  6908. speedRatio: number;
  6909. /**
  6910. * Creates a new Animatable
  6911. * @param scene defines the hosting scene
  6912. * @param target defines the target object
  6913. * @param fromFrame defines the starting frame number (default is 0)
  6914. * @param toFrame defines the ending frame number (default is 100)
  6915. * @param loopAnimation defines if the animation must loop (default is false)
  6916. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  6917. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  6918. * @param animations defines a group of animation to add to the new Animatable
  6919. * @param onAnimationLoop defines a callback to call when animation loops
  6920. */
  6921. constructor(scene: Scene,
  6922. /** defines the target object */
  6923. target: any,
  6924. /** defines the starting frame number (default is 0) */
  6925. fromFrame?: number,
  6926. /** defines the ending frame number (default is 100) */
  6927. toFrame?: number,
  6928. /** defines if the animation must loop (default is false) */
  6929. loopAnimation?: boolean, speedRatio?: number,
  6930. /** defines a callback to call when animation ends if it is not looping */
  6931. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  6932. /** defines a callback to call when animation loops */
  6933. onAnimationLoop?: (() => void) | null | undefined);
  6934. /**
  6935. * Synchronize and normalize current Animatable with a source Animatable
  6936. * This is useful when using animation weights and when animations are not of the same length
  6937. * @param root defines the root Animatable to synchronize with
  6938. * @returns the current Animatable
  6939. */
  6940. syncWith(root: Animatable): Animatable;
  6941. /**
  6942. * Gets the list of runtime animations
  6943. * @returns an array of RuntimeAnimation
  6944. */
  6945. getAnimations(): RuntimeAnimation[];
  6946. /**
  6947. * Adds more animations to the current animatable
  6948. * @param target defines the target of the animations
  6949. * @param animations defines the new animations to add
  6950. */
  6951. appendAnimations(target: any, animations: Animation[]): void;
  6952. /**
  6953. * Gets the source animation for a specific property
  6954. * @param property defines the propertyu to look for
  6955. * @returns null or the source animation for the given property
  6956. */
  6957. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  6958. /**
  6959. * Gets the runtime animation for a specific property
  6960. * @param property defines the propertyu to look for
  6961. * @returns null or the runtime animation for the given property
  6962. */
  6963. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  6964. /**
  6965. * Resets the animatable to its original state
  6966. */
  6967. reset(): void;
  6968. /**
  6969. * Allows the animatable to blend with current running animations
  6970. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6971. * @param blendingSpeed defines the blending speed to use
  6972. */
  6973. enableBlending(blendingSpeed: number): void;
  6974. /**
  6975. * Disable animation blending
  6976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6977. */
  6978. disableBlending(): void;
  6979. /**
  6980. * Jump directly to a given frame
  6981. * @param frame defines the frame to jump to
  6982. */
  6983. goToFrame(frame: number): void;
  6984. /**
  6985. * Pause the animation
  6986. */
  6987. pause(): void;
  6988. /**
  6989. * Restart the animation
  6990. */
  6991. restart(): void;
  6992. private _raiseOnAnimationEnd;
  6993. /**
  6994. * Stop and delete the current animation
  6995. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  6996. * @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)
  6997. */
  6998. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  6999. /**
  7000. * Wait asynchronously for the animation to end
  7001. * @returns a promise which will be fullfilled when the animation ends
  7002. */
  7003. waitAsync(): Promise<Animatable>;
  7004. /** @hidden */
  7005. _animate(delay: number): boolean;
  7006. }
  7007. }
  7008. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7009. /**
  7010. * Class used to override all child animations of a given target
  7011. */
  7012. export class AnimationPropertiesOverride {
  7013. /**
  7014. * Gets or sets a value indicating if animation blending must be used
  7015. */
  7016. enableBlending: boolean;
  7017. /**
  7018. * Gets or sets the blending speed to use when enableBlending is true
  7019. */
  7020. blendingSpeed: number;
  7021. /**
  7022. * Gets or sets the default loop mode to use
  7023. */
  7024. loopMode: number;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/intersectionInfo" {
  7028. import { Nullable } from "babylonjs/types";
  7029. /**
  7030. * @hidden
  7031. */
  7032. export class IntersectionInfo {
  7033. bu: Nullable<number>;
  7034. bv: Nullable<number>;
  7035. distance: number;
  7036. faceId: number;
  7037. subMeshId: number;
  7038. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7039. }
  7040. }
  7041. declare module "babylonjs/Actions/actionEvent" {
  7042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7043. import { Nullable } from "babylonjs/types";
  7044. import { Sprite } from "babylonjs/Sprites/sprite";
  7045. import { Scene } from "babylonjs/scene";
  7046. import { Vector2 } from "babylonjs/Maths/math";
  7047. /**
  7048. * Interface used to define ActionEvent
  7049. */
  7050. export interface IActionEvent {
  7051. /** The mesh or sprite that triggered the action */
  7052. source: any;
  7053. /** The X mouse cursor position at the time of the event */
  7054. pointerX: number;
  7055. /** The Y mouse cursor position at the time of the event */
  7056. pointerY: number;
  7057. /** The mesh that is currently pointed at (can be null) */
  7058. meshUnderPointer: Nullable<AbstractMesh>;
  7059. /** the original (browser) event that triggered the ActionEvent */
  7060. sourceEvent?: any;
  7061. /** additional data for the event */
  7062. additionalData?: any;
  7063. }
  7064. /**
  7065. * ActionEvent is the event being sent when an action is triggered.
  7066. */
  7067. export class ActionEvent implements IActionEvent {
  7068. /** The mesh or sprite that triggered the action */
  7069. source: any;
  7070. /** The X mouse cursor position at the time of the event */
  7071. pointerX: number;
  7072. /** The Y mouse cursor position at the time of the event */
  7073. pointerY: number;
  7074. /** The mesh that is currently pointed at (can be null) */
  7075. meshUnderPointer: Nullable<AbstractMesh>;
  7076. /** the original (browser) event that triggered the ActionEvent */
  7077. sourceEvent?: any;
  7078. /** additional data for the event */
  7079. additionalData?: any;
  7080. /**
  7081. * Creates a new ActionEvent
  7082. * @param source The mesh or sprite that triggered the action
  7083. * @param pointerX The X mouse cursor position at the time of the event
  7084. * @param pointerY The Y mouse cursor position at the time of the event
  7085. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7086. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7087. * @param additionalData additional data for the event
  7088. */
  7089. constructor(
  7090. /** The mesh or sprite that triggered the action */
  7091. source: any,
  7092. /** The X mouse cursor position at the time of the event */
  7093. pointerX: number,
  7094. /** The Y mouse cursor position at the time of the event */
  7095. pointerY: number,
  7096. /** The mesh that is currently pointed at (can be null) */
  7097. meshUnderPointer: Nullable<AbstractMesh>,
  7098. /** the original (browser) event that triggered the ActionEvent */
  7099. sourceEvent?: any,
  7100. /** additional data for the event */
  7101. additionalData?: any);
  7102. /**
  7103. * Helper function to auto-create an ActionEvent from a source mesh.
  7104. * @param source The source mesh that triggered the event
  7105. * @param evt The original (browser) event
  7106. * @param additionalData additional data for the event
  7107. * @returns the new ActionEvent
  7108. */
  7109. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7110. /**
  7111. * Helper function to auto-create an ActionEvent from a source sprite
  7112. * @param source The source sprite that triggered the event
  7113. * @param scene Scene associated with the sprite
  7114. * @param evt The original (browser) event
  7115. * @param additionalData additional data for the event
  7116. * @returns the new ActionEvent
  7117. */
  7118. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7119. /**
  7120. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7121. * @param scene the scene where the event occurred
  7122. * @param evt The original (browser) event
  7123. * @returns the new ActionEvent
  7124. */
  7125. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7126. /**
  7127. * Helper function to auto-create an ActionEvent from a primitive
  7128. * @param prim defines the target primitive
  7129. * @param pointerPos defines the pointer position
  7130. * @param evt The original (browser) event
  7131. * @param additionalData additional data for the event
  7132. * @returns the new ActionEvent
  7133. */
  7134. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7135. }
  7136. }
  7137. declare module "babylonjs/Culling/boundingSphere" {
  7138. import { DeepImmutable } from "babylonjs/types";
  7139. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7140. /**
  7141. * Class used to store bounding sphere information
  7142. */
  7143. export class BoundingSphere {
  7144. /**
  7145. * Gets the center of the bounding sphere in local space
  7146. */
  7147. readonly center: Vector3;
  7148. /**
  7149. * Radius of the bounding sphere in local space
  7150. */
  7151. radius: number;
  7152. /**
  7153. * Gets the center of the bounding sphere in world space
  7154. */
  7155. readonly centerWorld: Vector3;
  7156. /**
  7157. * Radius of the bounding sphere in world space
  7158. */
  7159. radiusWorld: number;
  7160. /**
  7161. * Gets the minimum vector in local space
  7162. */
  7163. readonly minimum: Vector3;
  7164. /**
  7165. * Gets the maximum vector in local space
  7166. */
  7167. readonly maximum: Vector3;
  7168. private _worldMatrix;
  7169. private static readonly TmpVector3;
  7170. /**
  7171. * Creates a new bounding sphere
  7172. * @param min defines the minimum vector (in local space)
  7173. * @param max defines the maximum vector (in local space)
  7174. * @param worldMatrix defines the new world matrix
  7175. */
  7176. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7177. /**
  7178. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7179. * @param min defines the new minimum vector (in local space)
  7180. * @param max defines the new maximum vector (in local space)
  7181. * @param worldMatrix defines the new world matrix
  7182. */
  7183. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7184. /**
  7185. * Scale the current bounding sphere by applying a scale factor
  7186. * @param factor defines the scale factor to apply
  7187. * @returns the current bounding box
  7188. */
  7189. scale(factor: number): BoundingSphere;
  7190. /**
  7191. * Gets the world matrix of the bounding box
  7192. * @returns a matrix
  7193. */
  7194. getWorldMatrix(): DeepImmutable<Matrix>;
  7195. /** @hidden */
  7196. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7197. /**
  7198. * Tests if the bounding sphere is intersecting the frustum planes
  7199. * @param frustumPlanes defines the frustum planes to test
  7200. * @returns true if there is an intersection
  7201. */
  7202. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7203. /**
  7204. * Tests if the bounding sphere center is in between the frustum planes.
  7205. * Used for optimistic fast inclusion.
  7206. * @param frustumPlanes defines the frustum planes to test
  7207. * @returns true if the sphere center is in between the frustum planes
  7208. */
  7209. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7210. /**
  7211. * Tests if a point is inside the bounding sphere
  7212. * @param point defines the point to test
  7213. * @returns true if the point is inside the bounding sphere
  7214. */
  7215. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7216. /**
  7217. * Checks if two sphere intersct
  7218. * @param sphere0 sphere 0
  7219. * @param sphere1 sphere 1
  7220. * @returns true if the speres intersect
  7221. */
  7222. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7223. }
  7224. }
  7225. declare module "babylonjs/Culling/boundingBox" {
  7226. import { DeepImmutable } from "babylonjs/types";
  7227. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7228. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7229. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7230. /**
  7231. * Class used to store bounding box information
  7232. */
  7233. export class BoundingBox implements ICullable {
  7234. /**
  7235. * Gets the 8 vectors representing the bounding box in local space
  7236. */
  7237. readonly vectors: Vector3[];
  7238. /**
  7239. * Gets the center of the bounding box in local space
  7240. */
  7241. readonly center: Vector3;
  7242. /**
  7243. * Gets the center of the bounding box in world space
  7244. */
  7245. readonly centerWorld: Vector3;
  7246. /**
  7247. * Gets the extend size in local space
  7248. */
  7249. readonly extendSize: Vector3;
  7250. /**
  7251. * Gets the extend size in world space
  7252. */
  7253. readonly extendSizeWorld: Vector3;
  7254. /**
  7255. * Gets the OBB (object bounding box) directions
  7256. */
  7257. readonly directions: Vector3[];
  7258. /**
  7259. * Gets the 8 vectors representing the bounding box in world space
  7260. */
  7261. readonly vectorsWorld: Vector3[];
  7262. /**
  7263. * Gets the minimum vector in world space
  7264. */
  7265. readonly minimumWorld: Vector3;
  7266. /**
  7267. * Gets the maximum vector in world space
  7268. */
  7269. readonly maximumWorld: Vector3;
  7270. /**
  7271. * Gets the minimum vector in local space
  7272. */
  7273. readonly minimum: Vector3;
  7274. /**
  7275. * Gets the maximum vector in local space
  7276. */
  7277. readonly maximum: Vector3;
  7278. private _worldMatrix;
  7279. private static readonly TmpVector3;
  7280. /**
  7281. * @hidden
  7282. */
  7283. _tag: number;
  7284. /**
  7285. * Creates a new bounding box
  7286. * @param min defines the minimum vector (in local space)
  7287. * @param max defines the maximum vector (in local space)
  7288. * @param worldMatrix defines the new world matrix
  7289. */
  7290. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7291. /**
  7292. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7293. * @param min defines the new minimum vector (in local space)
  7294. * @param max defines the new maximum vector (in local space)
  7295. * @param worldMatrix defines the new world matrix
  7296. */
  7297. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7298. /**
  7299. * Scale the current bounding box by applying a scale factor
  7300. * @param factor defines the scale factor to apply
  7301. * @returns the current bounding box
  7302. */
  7303. scale(factor: number): BoundingBox;
  7304. /**
  7305. * Gets the world matrix of the bounding box
  7306. * @returns a matrix
  7307. */
  7308. getWorldMatrix(): DeepImmutable<Matrix>;
  7309. /** @hidden */
  7310. _update(world: DeepImmutable<Matrix>): void;
  7311. /**
  7312. * Tests if the bounding box is intersecting the frustum planes
  7313. * @param frustumPlanes defines the frustum planes to test
  7314. * @returns true if there is an intersection
  7315. */
  7316. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7317. /**
  7318. * Tests if the bounding box is entirely inside the frustum planes
  7319. * @param frustumPlanes defines the frustum planes to test
  7320. * @returns true if there is an inclusion
  7321. */
  7322. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7323. /**
  7324. * Tests if a point is inside the bounding box
  7325. * @param point defines the point to test
  7326. * @returns true if the point is inside the bounding box
  7327. */
  7328. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7329. /**
  7330. * Tests if the bounding box intersects with a bounding sphere
  7331. * @param sphere defines the sphere to test
  7332. * @returns true if there is an intersection
  7333. */
  7334. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7335. /**
  7336. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7337. * @param min defines the min vector to use
  7338. * @param max defines the max vector to use
  7339. * @returns true if there is an intersection
  7340. */
  7341. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7342. /**
  7343. * Tests if two bounding boxes are intersections
  7344. * @param box0 defines the first box to test
  7345. * @param box1 defines the second box to test
  7346. * @returns true if there is an intersection
  7347. */
  7348. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7349. /**
  7350. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7351. * @param minPoint defines the minimum vector of the bounding box
  7352. * @param maxPoint defines the maximum vector of the bounding box
  7353. * @param sphereCenter defines the sphere center
  7354. * @param sphereRadius defines the sphere radius
  7355. * @returns true if there is an intersection
  7356. */
  7357. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7358. /**
  7359. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7360. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7361. * @param frustumPlanes defines the frustum planes to test
  7362. * @return true if there is an inclusion
  7363. */
  7364. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7365. /**
  7366. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7367. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7368. * @param frustumPlanes defines the frustum planes to test
  7369. * @return true if there is an intersection
  7370. */
  7371. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7372. }
  7373. }
  7374. declare module "babylonjs/Collisions/collider" {
  7375. import { Nullable, IndicesArray } from "babylonjs/types";
  7376. import { Vector3, Plane } from "babylonjs/Maths/math";
  7377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7378. /** @hidden */
  7379. export class Collider {
  7380. /** Define if a collision was found */
  7381. collisionFound: boolean;
  7382. /**
  7383. * Define last intersection point in local space
  7384. */
  7385. intersectionPoint: Vector3;
  7386. /**
  7387. * Define last collided mesh
  7388. */
  7389. collidedMesh: Nullable<AbstractMesh>;
  7390. private _collisionPoint;
  7391. private _planeIntersectionPoint;
  7392. private _tempVector;
  7393. private _tempVector2;
  7394. private _tempVector3;
  7395. private _tempVector4;
  7396. private _edge;
  7397. private _baseToVertex;
  7398. private _destinationPoint;
  7399. private _slidePlaneNormal;
  7400. private _displacementVector;
  7401. /** @hidden */
  7402. _radius: Vector3;
  7403. /** @hidden */
  7404. _retry: number;
  7405. private _velocity;
  7406. private _basePoint;
  7407. private _epsilon;
  7408. /** @hidden */
  7409. _velocityWorldLength: number;
  7410. /** @hidden */
  7411. _basePointWorld: Vector3;
  7412. private _velocityWorld;
  7413. private _normalizedVelocity;
  7414. /** @hidden */
  7415. _initialVelocity: Vector3;
  7416. /** @hidden */
  7417. _initialPosition: Vector3;
  7418. private _nearestDistance;
  7419. private _collisionMask;
  7420. collisionMask: number;
  7421. /**
  7422. * Gets the plane normal used to compute the sliding response (in local space)
  7423. */
  7424. readonly slidePlaneNormal: Vector3;
  7425. /** @hidden */
  7426. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7427. /** @hidden */
  7428. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7429. /** @hidden */
  7430. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7431. /** @hidden */
  7432. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7433. /** @hidden */
  7434. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7435. /** @hidden */
  7436. _getResponse(pos: Vector3, vel: Vector3): void;
  7437. }
  7438. }
  7439. declare module "babylonjs/Culling/boundingInfo" {
  7440. import { DeepImmutable } from "babylonjs/types";
  7441. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7442. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7443. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7444. import { Collider } from "babylonjs/Collisions/collider";
  7445. /**
  7446. * Interface for cullable objects
  7447. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7448. */
  7449. export interface ICullable {
  7450. /**
  7451. * Checks if the object or part of the object is in the frustum
  7452. * @param frustumPlanes Camera near/planes
  7453. * @returns true if the object is in frustum otherwise false
  7454. */
  7455. isInFrustum(frustumPlanes: Plane[]): boolean;
  7456. /**
  7457. * Checks if a cullable object (mesh...) is in the camera frustum
  7458. * Unlike isInFrustum this cheks the full bounding box
  7459. * @param frustumPlanes Camera near/planes
  7460. * @returns true if the object is in frustum otherwise false
  7461. */
  7462. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7463. }
  7464. /**
  7465. * Info for a bounding data of a mesh
  7466. */
  7467. export class BoundingInfo implements ICullable {
  7468. /**
  7469. * Bounding box for the mesh
  7470. */
  7471. readonly boundingBox: BoundingBox;
  7472. /**
  7473. * Bounding sphere for the mesh
  7474. */
  7475. readonly boundingSphere: BoundingSphere;
  7476. private _isLocked;
  7477. private static readonly TmpVector3;
  7478. /**
  7479. * Constructs bounding info
  7480. * @param minimum min vector of the bounding box/sphere
  7481. * @param maximum max vector of the bounding box/sphere
  7482. * @param worldMatrix defines the new world matrix
  7483. */
  7484. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7485. /**
  7486. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7487. * @param min defines the new minimum vector (in local space)
  7488. * @param max defines the new maximum vector (in local space)
  7489. * @param worldMatrix defines the new world matrix
  7490. */
  7491. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7492. /**
  7493. * min vector of the bounding box/sphere
  7494. */
  7495. readonly minimum: Vector3;
  7496. /**
  7497. * max vector of the bounding box/sphere
  7498. */
  7499. readonly maximum: Vector3;
  7500. /**
  7501. * If the info is locked and won't be updated to avoid perf overhead
  7502. */
  7503. isLocked: boolean;
  7504. /**
  7505. * Updates the bounding sphere and box
  7506. * @param world world matrix to be used to update
  7507. */
  7508. update(world: DeepImmutable<Matrix>): void;
  7509. /**
  7510. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7511. * @param center New center of the bounding info
  7512. * @param extend New extend of the bounding info
  7513. * @returns the current bounding info
  7514. */
  7515. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7516. /**
  7517. * Scale the current bounding info by applying a scale factor
  7518. * @param factor defines the scale factor to apply
  7519. * @returns the current bounding info
  7520. */
  7521. scale(factor: number): BoundingInfo;
  7522. /**
  7523. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7524. * @param frustumPlanes defines the frustum to test
  7525. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7526. * @returns true if the bounding info is in the frustum planes
  7527. */
  7528. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7529. /**
  7530. * Gets the world distance between the min and max points of the bounding box
  7531. */
  7532. readonly diagonalLength: number;
  7533. /**
  7534. * Checks if a cullable object (mesh...) is in the camera frustum
  7535. * Unlike isInFrustum this cheks the full bounding box
  7536. * @param frustumPlanes Camera near/planes
  7537. * @returns true if the object is in frustum otherwise false
  7538. */
  7539. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7540. /** @hidden */
  7541. _checkCollision(collider: Collider): boolean;
  7542. /**
  7543. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7544. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7545. * @param point the point to check intersection with
  7546. * @returns if the point intersects
  7547. */
  7548. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7549. /**
  7550. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7551. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7552. * @param boundingInfo the bounding info to check intersection with
  7553. * @param precise if the intersection should be done using OBB
  7554. * @returns if the bounding info intersects
  7555. */
  7556. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7557. }
  7558. }
  7559. declare module "babylonjs/Misc/smartArray" {
  7560. /**
  7561. * Defines an array and its length.
  7562. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7563. */
  7564. export interface ISmartArrayLike<T> {
  7565. /**
  7566. * The data of the array.
  7567. */
  7568. data: Array<T>;
  7569. /**
  7570. * The active length of the array.
  7571. */
  7572. length: number;
  7573. }
  7574. /**
  7575. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7576. */
  7577. export class SmartArray<T> implements ISmartArrayLike<T> {
  7578. /**
  7579. * The full set of data from the array.
  7580. */
  7581. data: Array<T>;
  7582. /**
  7583. * The active length of the array.
  7584. */
  7585. length: number;
  7586. protected _id: number;
  7587. /**
  7588. * Instantiates a Smart Array.
  7589. * @param capacity defines the default capacity of the array.
  7590. */
  7591. constructor(capacity: number);
  7592. /**
  7593. * Pushes a value at the end of the active data.
  7594. * @param value defines the object to push in the array.
  7595. */
  7596. push(value: T): void;
  7597. /**
  7598. * Iterates over the active data and apply the lambda to them.
  7599. * @param func defines the action to apply on each value.
  7600. */
  7601. forEach(func: (content: T) => void): void;
  7602. /**
  7603. * Sorts the full sets of data.
  7604. * @param compareFn defines the comparison function to apply.
  7605. */
  7606. sort(compareFn: (a: T, b: T) => number): void;
  7607. /**
  7608. * Resets the active data to an empty array.
  7609. */
  7610. reset(): void;
  7611. /**
  7612. * Releases all the data from the array as well as the array.
  7613. */
  7614. dispose(): void;
  7615. /**
  7616. * Concats the active data with a given array.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concat(array: any): void;
  7620. /**
  7621. * Returns the position of a value in the active data.
  7622. * @param value defines the value to find the index for
  7623. * @returns the index if found in the active data otherwise -1
  7624. */
  7625. indexOf(value: T): number;
  7626. /**
  7627. * Returns whether an element is part of the active data.
  7628. * @param value defines the value to look for
  7629. * @returns true if found in the active data otherwise false
  7630. */
  7631. contains(value: T): boolean;
  7632. private static _GlobalId;
  7633. }
  7634. /**
  7635. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7636. * The data in this array can only be present once
  7637. */
  7638. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7639. private _duplicateId;
  7640. /**
  7641. * Pushes a value at the end of the active data.
  7642. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7643. * @param value defines the object to push in the array.
  7644. */
  7645. push(value: T): void;
  7646. /**
  7647. * Pushes a value at the end of the active data.
  7648. * If the data is already present, it won t be added again
  7649. * @param value defines the object to push in the array.
  7650. * @returns true if added false if it was already present
  7651. */
  7652. pushNoDuplicate(value: T): boolean;
  7653. /**
  7654. * Resets the active data to an empty array.
  7655. */
  7656. reset(): void;
  7657. /**
  7658. * Concats the active data with a given array.
  7659. * This ensures no dupplicate will be present in the result.
  7660. * @param array defines the data to concatenate with.
  7661. */
  7662. concatWithNoDuplicate(array: any): void;
  7663. }
  7664. }
  7665. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7666. import { Nullable } from "babylonjs/types";
  7667. import { Scene } from "babylonjs/scene";
  7668. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7670. /**
  7671. * Class for creating a cube texture
  7672. */
  7673. export class CubeTexture extends BaseTexture {
  7674. private _delayedOnLoad;
  7675. /**
  7676. * The url of the texture
  7677. */
  7678. url: string;
  7679. /**
  7680. * Gets or sets the center of the bounding box associated with the cube texture.
  7681. * It must define where the camera used to render the texture was set
  7682. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7683. */
  7684. boundingBoxPosition: Vector3;
  7685. private _boundingBoxSize;
  7686. /**
  7687. * Gets or sets the size of the bounding box associated with the cube texture
  7688. * When defined, the cubemap will switch to local mode
  7689. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7690. * @example https://www.babylonjs-playground.com/#RNASML
  7691. */
  7692. /**
  7693. * Returns the bounding box size
  7694. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7695. */
  7696. boundingBoxSize: Vector3;
  7697. protected _rotationY: number;
  7698. /**
  7699. * Sets texture matrix rotation angle around Y axis in radians.
  7700. */
  7701. /**
  7702. * Gets texture matrix rotation angle around Y axis radians.
  7703. */
  7704. rotationY: number;
  7705. /**
  7706. * Are mip maps generated for this texture or not.
  7707. */
  7708. readonly noMipmap: boolean;
  7709. private _noMipmap;
  7710. private _files;
  7711. private _extensions;
  7712. private _textureMatrix;
  7713. private _format;
  7714. private _createPolynomials;
  7715. /** @hidden */
  7716. _prefiltered: boolean;
  7717. /**
  7718. * Creates a cube texture from an array of image urls
  7719. * @param files defines an array of image urls
  7720. * @param scene defines the hosting scene
  7721. * @param noMipmap specifies if mip maps are not used
  7722. * @returns a cube texture
  7723. */
  7724. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7725. /**
  7726. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7727. * @param url defines the url of the prefiltered texture
  7728. * @param scene defines the scene the texture is attached to
  7729. * @param forcedExtension defines the extension of the file if different from the url
  7730. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7731. * @return the prefiltered texture
  7732. */
  7733. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7734. /**
  7735. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7736. * as prefiltered data.
  7737. * @param rootUrl defines the url of the texture or the root name of the six images
  7738. * @param scene defines the scene the texture is attached to
  7739. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7740. * @param noMipmap defines if mipmaps should be created or not
  7741. * @param files defines the six files to load for the different faces
  7742. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7743. * @param onError defines a callback triggered in case of error during load
  7744. * @param format defines the internal format to use for the texture once loaded
  7745. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7746. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7749. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7750. * @return the cube texture
  7751. */
  7752. 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);
  7753. /**
  7754. * Get the current class name of the texture useful for serialization or dynamic coding.
  7755. * @returns "CubeTexture"
  7756. */
  7757. getClassName(): string;
  7758. /**
  7759. * Update the url (and optional buffer) of this texture if url was null during construction.
  7760. * @param url the url of the texture
  7761. * @param forcedExtension defines the extension to use
  7762. * @param onLoad callback called when the texture is loaded (defaults to null)
  7763. */
  7764. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7765. /**
  7766. * Delays loading of the cube texture
  7767. * @param forcedExtension defines the extension to use
  7768. */
  7769. delayLoad(forcedExtension?: string): void;
  7770. /**
  7771. * Returns the reflection texture matrix
  7772. * @returns the reflection texture matrix
  7773. */
  7774. getReflectionTextureMatrix(): Matrix;
  7775. /**
  7776. * Sets the reflection texture matrix
  7777. * @param value Reflection texture matrix
  7778. */
  7779. setReflectionTextureMatrix(value: Matrix): void;
  7780. /**
  7781. * Parses text to create a cube texture
  7782. * @param parsedTexture define the serialized text to read from
  7783. * @param scene defines the hosting scene
  7784. * @param rootUrl defines the root url of the cube texture
  7785. * @returns a cube texture
  7786. */
  7787. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7788. /**
  7789. * Makes a clone, or deep copy, of the cube texture
  7790. * @returns a new cube texture
  7791. */
  7792. clone(): CubeTexture;
  7793. }
  7794. }
  7795. declare module "babylonjs/Shaders/postprocess.vertex" {
  7796. /** @hidden */
  7797. export var postprocessVertexShader: {
  7798. name: string;
  7799. shader: string;
  7800. };
  7801. }
  7802. declare module "babylonjs/Cameras/targetCamera" {
  7803. import { Nullable } from "babylonjs/types";
  7804. import { Camera } from "babylonjs/Cameras/camera";
  7805. import { Scene } from "babylonjs/scene";
  7806. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7807. /**
  7808. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7809. * This is the base of the follow, arc rotate cameras and Free camera
  7810. * @see http://doc.babylonjs.com/features/cameras
  7811. */
  7812. export class TargetCamera extends Camera {
  7813. private static _RigCamTransformMatrix;
  7814. private static _TargetTransformMatrix;
  7815. private static _TargetFocalPoint;
  7816. /**
  7817. * Define the current direction the camera is moving to
  7818. */
  7819. cameraDirection: Vector3;
  7820. /**
  7821. * Define the current rotation the camera is rotating to
  7822. */
  7823. cameraRotation: Vector2;
  7824. /**
  7825. * When set, the up vector of the camera will be updated by the rotation of the camera
  7826. */
  7827. updateUpVectorFromRotation: boolean;
  7828. private _tmpQuaternion;
  7829. /**
  7830. * Define the current rotation of the camera
  7831. */
  7832. rotation: Vector3;
  7833. /**
  7834. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7835. */
  7836. rotationQuaternion: Quaternion;
  7837. /**
  7838. * Define the current speed of the camera
  7839. */
  7840. speed: number;
  7841. /**
  7842. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7843. * around all axis.
  7844. */
  7845. noRotationConstraint: boolean;
  7846. /**
  7847. * Define the current target of the camera as an object or a position.
  7848. */
  7849. lockedTarget: any;
  7850. /** @hidden */
  7851. _currentTarget: Vector3;
  7852. /** @hidden */
  7853. _initialFocalDistance: number;
  7854. /** @hidden */
  7855. _viewMatrix: Matrix;
  7856. /** @hidden */
  7857. _camMatrix: Matrix;
  7858. /** @hidden */
  7859. _cameraTransformMatrix: Matrix;
  7860. /** @hidden */
  7861. _cameraRotationMatrix: Matrix;
  7862. /** @hidden */
  7863. _referencePoint: Vector3;
  7864. /** @hidden */
  7865. _transformedReferencePoint: Vector3;
  7866. protected _globalCurrentTarget: Vector3;
  7867. protected _globalCurrentUpVector: Vector3;
  7868. /** @hidden */
  7869. _reset: () => void;
  7870. private _defaultUp;
  7871. /**
  7872. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7873. * This is the base of the follow, arc rotate cameras and Free camera
  7874. * @see http://doc.babylonjs.com/features/cameras
  7875. * @param name Defines the name of the camera in the scene
  7876. * @param position Defines the start position of the camera in the scene
  7877. * @param scene Defines the scene the camera belongs to
  7878. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7879. */
  7880. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7881. /**
  7882. * Gets the position in front of the camera at a given distance.
  7883. * @param distance The distance from the camera we want the position to be
  7884. * @returns the position
  7885. */
  7886. getFrontPosition(distance: number): Vector3;
  7887. /** @hidden */
  7888. _getLockedTargetPosition(): Nullable<Vector3>;
  7889. private _storedPosition;
  7890. private _storedRotation;
  7891. private _storedRotationQuaternion;
  7892. /**
  7893. * Store current camera state of the camera (fov, position, rotation, etc..)
  7894. * @returns the camera
  7895. */
  7896. storeState(): Camera;
  7897. /**
  7898. * Restored camera state. You must call storeState() first
  7899. * @returns whether it was successful or not
  7900. * @hidden
  7901. */
  7902. _restoreStateValues(): boolean;
  7903. /** @hidden */
  7904. _initCache(): void;
  7905. /** @hidden */
  7906. _updateCache(ignoreParentClass?: boolean): void;
  7907. /** @hidden */
  7908. _isSynchronizedViewMatrix(): boolean;
  7909. /** @hidden */
  7910. _computeLocalCameraSpeed(): number;
  7911. /** @hidden */
  7912. setTarget(target: Vector3): void;
  7913. /**
  7914. * Return the current target position of the camera. This value is expressed in local space.
  7915. * @returns the target position
  7916. */
  7917. getTarget(): Vector3;
  7918. /** @hidden */
  7919. _decideIfNeedsToMove(): boolean;
  7920. /** @hidden */
  7921. _updatePosition(): void;
  7922. /** @hidden */
  7923. _checkInputs(): void;
  7924. protected _updateCameraRotationMatrix(): void;
  7925. /**
  7926. * 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)
  7927. * @returns the current camera
  7928. */
  7929. private _rotateUpVectorWithCameraRotationMatrix;
  7930. private _cachedRotationZ;
  7931. private _cachedQuaternionRotationZ;
  7932. /** @hidden */
  7933. _getViewMatrix(): Matrix;
  7934. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7935. /**
  7936. * @hidden
  7937. */
  7938. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7939. /**
  7940. * @hidden
  7941. */
  7942. _updateRigCameras(): void;
  7943. private _getRigCamPositionAndTarget;
  7944. /**
  7945. * Gets the current object class name.
  7946. * @return the class name
  7947. */
  7948. getClassName(): string;
  7949. }
  7950. }
  7951. declare module "babylonjs/Cameras/cameraInputsManager" {
  7952. import { Nullable } from "babylonjs/types";
  7953. import { Camera } from "babylonjs/Cameras/camera";
  7954. /**
  7955. * @ignore
  7956. * This is a list of all the different input types that are available in the application.
  7957. * Fo instance: ArcRotateCameraGamepadInput...
  7958. */
  7959. export var CameraInputTypes: {};
  7960. /**
  7961. * This is the contract to implement in order to create a new input class.
  7962. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7963. */
  7964. export interface ICameraInput<TCamera extends Camera> {
  7965. /**
  7966. * Defines the camera the input is attached to.
  7967. */
  7968. camera: Nullable<TCamera>;
  7969. /**
  7970. * Gets the class name of the current intput.
  7971. * @returns the class name
  7972. */
  7973. getClassName(): string;
  7974. /**
  7975. * Get the friendly name associated with the input class.
  7976. * @returns the input friendly name
  7977. */
  7978. getSimpleName(): string;
  7979. /**
  7980. * Attach the input controls to a specific dom element to get the input from.
  7981. * @param element Defines the element the controls should be listened from
  7982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7983. */
  7984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7985. /**
  7986. * Detach the current controls from the specified dom element.
  7987. * @param element Defines the element to stop listening the inputs from
  7988. */
  7989. detachControl(element: Nullable<HTMLElement>): void;
  7990. /**
  7991. * Update the current camera state depending on the inputs that have been used this frame.
  7992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7993. */
  7994. checkInputs?: () => void;
  7995. }
  7996. /**
  7997. * Represents a map of input types to input instance or input index to input instance.
  7998. */
  7999. export interface CameraInputsMap<TCamera extends Camera> {
  8000. /**
  8001. * Accessor to the input by input type.
  8002. */
  8003. [name: string]: ICameraInput<TCamera>;
  8004. /**
  8005. * Accessor to the input by input index.
  8006. */
  8007. [idx: number]: ICameraInput<TCamera>;
  8008. }
  8009. /**
  8010. * This represents the input manager used within a camera.
  8011. * It helps dealing with all the different kind of input attached to a camera.
  8012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8013. */
  8014. export class CameraInputsManager<TCamera extends Camera> {
  8015. /**
  8016. * Defines the list of inputs attahed to the camera.
  8017. */
  8018. attached: CameraInputsMap<TCamera>;
  8019. /**
  8020. * Defines the dom element the camera is collecting inputs from.
  8021. * This is null if the controls have not been attached.
  8022. */
  8023. attachedElement: Nullable<HTMLElement>;
  8024. /**
  8025. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8026. */
  8027. noPreventDefault: boolean;
  8028. /**
  8029. * Defined the camera the input manager belongs to.
  8030. */
  8031. camera: TCamera;
  8032. /**
  8033. * Update the current camera state depending on the inputs that have been used this frame.
  8034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8035. */
  8036. checkInputs: () => void;
  8037. /**
  8038. * Instantiate a new Camera Input Manager.
  8039. * @param camera Defines the camera the input manager blongs to
  8040. */
  8041. constructor(camera: TCamera);
  8042. /**
  8043. * Add an input method to a camera
  8044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8045. * @param input camera input method
  8046. */
  8047. add(input: ICameraInput<TCamera>): void;
  8048. /**
  8049. * Remove a specific input method from a camera
  8050. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8051. * @param inputToRemove camera input method
  8052. */
  8053. remove(inputToRemove: ICameraInput<TCamera>): void;
  8054. /**
  8055. * Remove a specific input type from a camera
  8056. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8057. * @param inputType the type of the input to remove
  8058. */
  8059. removeByType(inputType: string): void;
  8060. private _addCheckInputs;
  8061. /**
  8062. * Attach the input controls to the currently attached dom element to listen the events from.
  8063. * @param input Defines the input to attach
  8064. */
  8065. attachInput(input: ICameraInput<TCamera>): void;
  8066. /**
  8067. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8068. * @param element Defines the dom element to collect the events from
  8069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8070. */
  8071. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8072. /**
  8073. * Detach the current manager inputs controls from a specific dom element.
  8074. * @param element Defines the dom element to collect the events from
  8075. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8076. */
  8077. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8078. /**
  8079. * Rebuild the dynamic inputCheck function from the current list of
  8080. * defined inputs in the manager.
  8081. */
  8082. rebuildInputCheck(): void;
  8083. /**
  8084. * Remove all attached input methods from a camera
  8085. */
  8086. clear(): void;
  8087. /**
  8088. * Serialize the current input manager attached to a camera.
  8089. * This ensures than once parsed,
  8090. * the input associated to the camera will be identical to the current ones
  8091. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8092. */
  8093. serialize(serializedCamera: any): void;
  8094. /**
  8095. * Parses an input manager serialized JSON to restore the previous list of inputs
  8096. * and states associated to a camera.
  8097. * @param parsedCamera Defines the JSON to parse
  8098. */
  8099. parse(parsedCamera: any): void;
  8100. }
  8101. }
  8102. declare module "babylonjs/Events/keyboardEvents" {
  8103. /**
  8104. * Gather the list of keyboard event types as constants.
  8105. */
  8106. export class KeyboardEventTypes {
  8107. /**
  8108. * The keydown event is fired when a key becomes active (pressed).
  8109. */
  8110. static readonly KEYDOWN: number;
  8111. /**
  8112. * The keyup event is fired when a key has been released.
  8113. */
  8114. static readonly KEYUP: number;
  8115. }
  8116. /**
  8117. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8118. */
  8119. export class KeyboardInfo {
  8120. /**
  8121. * Defines the type of event (KeyboardEventTypes)
  8122. */
  8123. type: number;
  8124. /**
  8125. * Defines the related dom event
  8126. */
  8127. event: KeyboardEvent;
  8128. /**
  8129. * Instantiates a new keyboard info.
  8130. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8131. * @param type Defines the type of event (KeyboardEventTypes)
  8132. * @param event Defines the related dom event
  8133. */
  8134. constructor(
  8135. /**
  8136. * Defines the type of event (KeyboardEventTypes)
  8137. */
  8138. type: number,
  8139. /**
  8140. * Defines the related dom event
  8141. */
  8142. event: KeyboardEvent);
  8143. }
  8144. /**
  8145. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8146. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8147. */
  8148. export class KeyboardInfoPre extends KeyboardInfo {
  8149. /**
  8150. * Defines the type of event (KeyboardEventTypes)
  8151. */
  8152. type: number;
  8153. /**
  8154. * Defines the related dom event
  8155. */
  8156. event: KeyboardEvent;
  8157. /**
  8158. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8159. */
  8160. skipOnPointerObservable: boolean;
  8161. /**
  8162. * Instantiates a new keyboard pre info.
  8163. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8164. * @param type Defines the type of event (KeyboardEventTypes)
  8165. * @param event Defines the related dom event
  8166. */
  8167. constructor(
  8168. /**
  8169. * Defines the type of event (KeyboardEventTypes)
  8170. */
  8171. type: number,
  8172. /**
  8173. * Defines the related dom event
  8174. */
  8175. event: KeyboardEvent);
  8176. }
  8177. }
  8178. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8179. import { Nullable } from "babylonjs/types";
  8180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8181. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8182. /**
  8183. * Manage the keyboard inputs to control the movement of a free camera.
  8184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8185. */
  8186. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8187. /**
  8188. * Defines the camera the input is attached to.
  8189. */
  8190. camera: FreeCamera;
  8191. /**
  8192. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8193. */
  8194. keysUp: number[];
  8195. /**
  8196. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8197. */
  8198. keysDown: number[];
  8199. /**
  8200. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8201. */
  8202. keysLeft: number[];
  8203. /**
  8204. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8205. */
  8206. keysRight: number[];
  8207. private _keys;
  8208. private _onCanvasBlurObserver;
  8209. private _onKeyboardObserver;
  8210. private _engine;
  8211. private _scene;
  8212. /**
  8213. * Attach the input controls to a specific dom element to get the input from.
  8214. * @param element Defines the element the controls should be listened from
  8215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8216. */
  8217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8218. /**
  8219. * Detach the current controls from the specified dom element.
  8220. * @param element Defines the element to stop listening the inputs from
  8221. */
  8222. detachControl(element: Nullable<HTMLElement>): void;
  8223. /**
  8224. * Update the current camera state depending on the inputs that have been used this frame.
  8225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8226. */
  8227. checkInputs(): void;
  8228. /**
  8229. * Gets the class name of the current intput.
  8230. * @returns the class name
  8231. */
  8232. getClassName(): string;
  8233. /** @hidden */
  8234. _onLostFocus(): void;
  8235. /**
  8236. * Get the friendly name associated with the input class.
  8237. * @returns the input friendly name
  8238. */
  8239. getSimpleName(): string;
  8240. }
  8241. }
  8242. declare module "babylonjs/Events/pointerEvents" {
  8243. import { Nullable } from "babylonjs/types";
  8244. import { Vector2 } from "babylonjs/Maths/math";
  8245. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  8246. import { Ray } from "babylonjs/Culling/ray";
  8247. /**
  8248. * Gather the list of pointer event types as constants.
  8249. */
  8250. export class PointerEventTypes {
  8251. /**
  8252. * 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.
  8253. */
  8254. static readonly POINTERDOWN: number;
  8255. /**
  8256. * The pointerup event is fired when a pointer is no longer active.
  8257. */
  8258. static readonly POINTERUP: number;
  8259. /**
  8260. * The pointermove event is fired when a pointer changes coordinates.
  8261. */
  8262. static readonly POINTERMOVE: number;
  8263. /**
  8264. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8265. */
  8266. static readonly POINTERWHEEL: number;
  8267. /**
  8268. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8269. */
  8270. static readonly POINTERPICK: number;
  8271. /**
  8272. * The pointertap event is fired when a the object has been touched and released without drag.
  8273. */
  8274. static readonly POINTERTAP: number;
  8275. /**
  8276. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8277. */
  8278. static readonly POINTERDOUBLETAP: number;
  8279. }
  8280. /**
  8281. * Base class of pointer info types.
  8282. */
  8283. export class PointerInfoBase {
  8284. /**
  8285. * Defines the type of event (PointerEventTypes)
  8286. */
  8287. type: number;
  8288. /**
  8289. * Defines the related dom event
  8290. */
  8291. event: PointerEvent | MouseWheelEvent;
  8292. /**
  8293. * Instantiates the base class of pointers info.
  8294. * @param type Defines the type of event (PointerEventTypes)
  8295. * @param event Defines the related dom event
  8296. */
  8297. constructor(
  8298. /**
  8299. * Defines the type of event (PointerEventTypes)
  8300. */
  8301. type: number,
  8302. /**
  8303. * Defines the related dom event
  8304. */
  8305. event: PointerEvent | MouseWheelEvent);
  8306. }
  8307. /**
  8308. * This class is used to store pointer related info for the onPrePointerObservable event.
  8309. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8310. */
  8311. export class PointerInfoPre extends PointerInfoBase {
  8312. /**
  8313. * Ray from a pointer if availible (eg. 6dof controller)
  8314. */
  8315. ray: Nullable<Ray>;
  8316. /**
  8317. * Defines the local position of the pointer on the canvas.
  8318. */
  8319. localPosition: Vector2;
  8320. /**
  8321. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8322. */
  8323. skipOnPointerObservable: boolean;
  8324. /**
  8325. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8326. * @param type Defines the type of event (PointerEventTypes)
  8327. * @param event Defines the related dom event
  8328. * @param localX Defines the local x coordinates of the pointer when the event occured
  8329. * @param localY Defines the local y coordinates of the pointer when the event occured
  8330. */
  8331. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8332. }
  8333. /**
  8334. * This type contains all the data related to a pointer event in Babylon.js.
  8335. * 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.
  8336. */
  8337. export class PointerInfo extends PointerInfoBase {
  8338. /**
  8339. * Defines the picking info associated to the info (if any)\
  8340. */
  8341. pickInfo: Nullable<PickingInfo>;
  8342. /**
  8343. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8344. * @param type Defines the type of event (PointerEventTypes)
  8345. * @param event Defines the related dom event
  8346. * @param pickInfo Defines the picking info associated to the info (if any)\
  8347. */
  8348. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8349. /**
  8350. * Defines the picking info associated to the info (if any)\
  8351. */
  8352. pickInfo: Nullable<PickingInfo>);
  8353. }
  8354. }
  8355. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  8356. import { Nullable } from "babylonjs/types";
  8357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8359. /**
  8360. * Manage the mouse inputs to control the movement of a free camera.
  8361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8362. */
  8363. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8364. /**
  8365. * Define if touch is enabled in the mouse input
  8366. */
  8367. touchEnabled: boolean;
  8368. /**
  8369. * Defines the camera the input is attached to.
  8370. */
  8371. camera: FreeCamera;
  8372. /**
  8373. * Defines the buttons associated with the input to handle camera move.
  8374. */
  8375. buttons: number[];
  8376. /**
  8377. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8378. */
  8379. angularSensibility: number;
  8380. private _pointerInput;
  8381. private _onMouseMove;
  8382. private _observer;
  8383. private previousPosition;
  8384. /**
  8385. * Manage the mouse inputs to control the movement of a free camera.
  8386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8387. * @param touchEnabled Defines if touch is enabled or not
  8388. */
  8389. constructor(
  8390. /**
  8391. * Define if touch is enabled in the mouse input
  8392. */
  8393. touchEnabled?: boolean);
  8394. /**
  8395. * Attach the input controls to a specific dom element to get the input from.
  8396. * @param element Defines the element the controls should be listened from
  8397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8398. */
  8399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8400. /**
  8401. * Detach the current controls from the specified dom element.
  8402. * @param element Defines the element to stop listening the inputs from
  8403. */
  8404. detachControl(element: Nullable<HTMLElement>): void;
  8405. /**
  8406. * Gets the class name of the current intput.
  8407. * @returns the class name
  8408. */
  8409. getClassName(): string;
  8410. /**
  8411. * Get the friendly name associated with the input class.
  8412. * @returns the input friendly name
  8413. */
  8414. getSimpleName(): string;
  8415. }
  8416. }
  8417. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  8418. import { Nullable } from "babylonjs/types";
  8419. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8420. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8421. /**
  8422. * Manage the touch inputs to control the movement of a free camera.
  8423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8424. */
  8425. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8426. /**
  8427. * Defines the camera the input is attached to.
  8428. */
  8429. camera: FreeCamera;
  8430. /**
  8431. * Defines the touch sensibility for rotation.
  8432. * The higher the faster.
  8433. */
  8434. touchAngularSensibility: number;
  8435. /**
  8436. * Defines the touch sensibility for move.
  8437. * The higher the faster.
  8438. */
  8439. touchMoveSensibility: number;
  8440. private _offsetX;
  8441. private _offsetY;
  8442. private _pointerPressed;
  8443. private _pointerInput;
  8444. private _observer;
  8445. private _onLostFocus;
  8446. /**
  8447. * Attach the input controls to a specific dom element to get the input from.
  8448. * @param element Defines the element the controls should be listened from
  8449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8450. */
  8451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8452. /**
  8453. * Detach the current controls from the specified dom element.
  8454. * @param element Defines the element to stop listening the inputs from
  8455. */
  8456. detachControl(element: Nullable<HTMLElement>): void;
  8457. /**
  8458. * Update the current camera state depending on the inputs that have been used this frame.
  8459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8460. */
  8461. checkInputs(): void;
  8462. /**
  8463. * Gets the class name of the current intput.
  8464. * @returns the class name
  8465. */
  8466. getClassName(): string;
  8467. /**
  8468. * Get the friendly name associated with the input class.
  8469. * @returns the input friendly name
  8470. */
  8471. getSimpleName(): string;
  8472. }
  8473. }
  8474. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  8475. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8476. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  8477. /**
  8478. * Default Inputs manager for the FreeCamera.
  8479. * It groups all the default supported inputs for ease of use.
  8480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8481. */
  8482. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8483. /**
  8484. * Instantiates a new FreeCameraInputsManager.
  8485. * @param camera Defines the camera the inputs belong to
  8486. */
  8487. constructor(camera: FreeCamera);
  8488. /**
  8489. * Add keyboard input support to the input manager.
  8490. * @returns the current input manager
  8491. */
  8492. addKeyboard(): FreeCameraInputsManager;
  8493. /**
  8494. * Add mouse input support to the input manager.
  8495. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8496. * @returns the current input manager
  8497. */
  8498. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8499. /**
  8500. * Add touch input support to the input manager.
  8501. * @returns the current input manager
  8502. */
  8503. addTouch(): FreeCameraInputsManager;
  8504. }
  8505. }
  8506. declare module "babylonjs/Cameras/freeCamera" {
  8507. import { Vector3 } from "babylonjs/Maths/math";
  8508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8509. import { Scene } from "babylonjs/scene";
  8510. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  8511. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  8512. /**
  8513. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8514. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8515. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8516. */
  8517. export class FreeCamera extends TargetCamera {
  8518. /**
  8519. * Define the collision ellipsoid of the camera.
  8520. * This is helpful to simulate a camera body like the player body around the camera
  8521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8522. */
  8523. ellipsoid: Vector3;
  8524. /**
  8525. * Define an offset for the position of the ellipsoid around the camera.
  8526. * This can be helpful to determine the center of the body near the gravity center of the body
  8527. * instead of its head.
  8528. */
  8529. ellipsoidOffset: Vector3;
  8530. /**
  8531. * Enable or disable collisions of the camera with the rest of the scene objects.
  8532. */
  8533. checkCollisions: boolean;
  8534. /**
  8535. * Enable or disable gravity on the camera.
  8536. */
  8537. applyGravity: boolean;
  8538. /**
  8539. * Define the input manager associated to the camera.
  8540. */
  8541. inputs: FreeCameraInputsManager;
  8542. /**
  8543. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8544. * Higher values reduce sensitivity.
  8545. */
  8546. /**
  8547. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8548. * Higher values reduce sensitivity.
  8549. */
  8550. angularSensibility: number;
  8551. /**
  8552. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8553. */
  8554. keysUp: number[];
  8555. /**
  8556. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8557. */
  8558. keysDown: number[];
  8559. /**
  8560. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8561. */
  8562. keysLeft: number[];
  8563. /**
  8564. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8565. */
  8566. keysRight: number[];
  8567. /**
  8568. * Event raised when the camera collide with a mesh in the scene.
  8569. */
  8570. onCollide: (collidedMesh: AbstractMesh) => void;
  8571. private _collider;
  8572. private _needMoveForGravity;
  8573. private _oldPosition;
  8574. private _diffPosition;
  8575. private _newPosition;
  8576. /** @hidden */
  8577. _localDirection: Vector3;
  8578. /** @hidden */
  8579. _transformedDirection: Vector3;
  8580. /**
  8581. * Instantiates a Free Camera.
  8582. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8583. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8584. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8585. * @param name Define the name of the camera in the scene
  8586. * @param position Define the start position of the camera in the scene
  8587. * @param scene Define the scene the camera belongs to
  8588. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8589. */
  8590. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8591. /**
  8592. * Attached controls to the current camera.
  8593. * @param element Defines the element the controls should be listened from
  8594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8595. */
  8596. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8597. /**
  8598. * Detach the current controls from the camera.
  8599. * The camera will stop reacting to inputs.
  8600. * @param element Defines the element to stop listening the inputs from
  8601. */
  8602. detachControl(element: HTMLElement): void;
  8603. private _collisionMask;
  8604. /**
  8605. * Define a collision mask to limit the list of object the camera can collide with
  8606. */
  8607. collisionMask: number;
  8608. /** @hidden */
  8609. _collideWithWorld(displacement: Vector3): void;
  8610. private _onCollisionPositionChange;
  8611. /** @hidden */
  8612. _checkInputs(): void;
  8613. /** @hidden */
  8614. _decideIfNeedsToMove(): boolean;
  8615. /** @hidden */
  8616. _updatePosition(): void;
  8617. /**
  8618. * Destroy the camera and release the current resources hold by it.
  8619. */
  8620. dispose(): void;
  8621. /**
  8622. * Gets the current object class name.
  8623. * @return the class name
  8624. */
  8625. getClassName(): string;
  8626. }
  8627. }
  8628. declare module "babylonjs/Gamepads/gamepad" {
  8629. import { Observable } from "babylonjs/Misc/observable";
  8630. /**
  8631. * Represents a gamepad control stick position
  8632. */
  8633. export class StickValues {
  8634. /**
  8635. * The x component of the control stick
  8636. */
  8637. x: number;
  8638. /**
  8639. * The y component of the control stick
  8640. */
  8641. y: number;
  8642. /**
  8643. * Initializes the gamepad x and y control stick values
  8644. * @param x The x component of the gamepad control stick value
  8645. * @param y The y component of the gamepad control stick value
  8646. */
  8647. constructor(
  8648. /**
  8649. * The x component of the control stick
  8650. */
  8651. x: number,
  8652. /**
  8653. * The y component of the control stick
  8654. */
  8655. y: number);
  8656. }
  8657. /**
  8658. * An interface which manages callbacks for gamepad button changes
  8659. */
  8660. export interface GamepadButtonChanges {
  8661. /**
  8662. * Called when a gamepad has been changed
  8663. */
  8664. changed: boolean;
  8665. /**
  8666. * Called when a gamepad press event has been triggered
  8667. */
  8668. pressChanged: boolean;
  8669. /**
  8670. * Called when a touch event has been triggered
  8671. */
  8672. touchChanged: boolean;
  8673. /**
  8674. * Called when a value has changed
  8675. */
  8676. valueChanged: boolean;
  8677. }
  8678. /**
  8679. * Represents a gamepad
  8680. */
  8681. export class Gamepad {
  8682. /**
  8683. * The id of the gamepad
  8684. */
  8685. id: string;
  8686. /**
  8687. * The index of the gamepad
  8688. */
  8689. index: number;
  8690. /**
  8691. * The browser gamepad
  8692. */
  8693. browserGamepad: any;
  8694. /**
  8695. * Specifies what type of gamepad this represents
  8696. */
  8697. type: number;
  8698. private _leftStick;
  8699. private _rightStick;
  8700. /** @hidden */
  8701. _isConnected: boolean;
  8702. private _leftStickAxisX;
  8703. private _leftStickAxisY;
  8704. private _rightStickAxisX;
  8705. private _rightStickAxisY;
  8706. /**
  8707. * Triggered when the left control stick has been changed
  8708. */
  8709. private _onleftstickchanged;
  8710. /**
  8711. * Triggered when the right control stick has been changed
  8712. */
  8713. private _onrightstickchanged;
  8714. /**
  8715. * Represents a gamepad controller
  8716. */
  8717. static GAMEPAD: number;
  8718. /**
  8719. * Represents a generic controller
  8720. */
  8721. static GENERIC: number;
  8722. /**
  8723. * Represents an XBox controller
  8724. */
  8725. static XBOX: number;
  8726. /**
  8727. * Represents a pose-enabled controller
  8728. */
  8729. static POSE_ENABLED: number;
  8730. /**
  8731. * Specifies whether the left control stick should be Y-inverted
  8732. */
  8733. protected _invertLeftStickY: boolean;
  8734. /**
  8735. * Specifies if the gamepad has been connected
  8736. */
  8737. readonly isConnected: boolean;
  8738. /**
  8739. * Initializes the gamepad
  8740. * @param id The id of the gamepad
  8741. * @param index The index of the gamepad
  8742. * @param browserGamepad The browser gamepad
  8743. * @param leftStickX The x component of the left joystick
  8744. * @param leftStickY The y component of the left joystick
  8745. * @param rightStickX The x component of the right joystick
  8746. * @param rightStickY The y component of the right joystick
  8747. */
  8748. constructor(
  8749. /**
  8750. * The id of the gamepad
  8751. */
  8752. id: string,
  8753. /**
  8754. * The index of the gamepad
  8755. */
  8756. index: number,
  8757. /**
  8758. * The browser gamepad
  8759. */
  8760. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8761. /**
  8762. * Callback triggered when the left joystick has changed
  8763. * @param callback
  8764. */
  8765. onleftstickchanged(callback: (values: StickValues) => void): void;
  8766. /**
  8767. * Callback triggered when the right joystick has changed
  8768. * @param callback
  8769. */
  8770. onrightstickchanged(callback: (values: StickValues) => void): void;
  8771. /**
  8772. * Gets the left joystick
  8773. */
  8774. /**
  8775. * Sets the left joystick values
  8776. */
  8777. leftStick: StickValues;
  8778. /**
  8779. * Gets the right joystick
  8780. */
  8781. /**
  8782. * Sets the right joystick value
  8783. */
  8784. rightStick: StickValues;
  8785. /**
  8786. * Updates the gamepad joystick positions
  8787. */
  8788. update(): void;
  8789. /**
  8790. * Disposes the gamepad
  8791. */
  8792. dispose(): void;
  8793. }
  8794. /**
  8795. * Represents a generic gamepad
  8796. */
  8797. export class GenericPad extends Gamepad {
  8798. private _buttons;
  8799. private _onbuttondown;
  8800. private _onbuttonup;
  8801. /**
  8802. * Observable triggered when a button has been pressed
  8803. */
  8804. onButtonDownObservable: Observable<number>;
  8805. /**
  8806. * Observable triggered when a button has been released
  8807. */
  8808. onButtonUpObservable: Observable<number>;
  8809. /**
  8810. * Callback triggered when a button has been pressed
  8811. * @param callback Called when a button has been pressed
  8812. */
  8813. onbuttondown(callback: (buttonPressed: number) => void): void;
  8814. /**
  8815. * Callback triggered when a button has been released
  8816. * @param callback Called when a button has been released
  8817. */
  8818. onbuttonup(callback: (buttonReleased: number) => void): void;
  8819. /**
  8820. * Initializes the generic gamepad
  8821. * @param id The id of the generic gamepad
  8822. * @param index The index of the generic gamepad
  8823. * @param browserGamepad The browser gamepad
  8824. */
  8825. constructor(id: string, index: number, browserGamepad: any);
  8826. private _setButtonValue;
  8827. /**
  8828. * Updates the generic gamepad
  8829. */
  8830. update(): void;
  8831. /**
  8832. * Disposes the generic gamepad
  8833. */
  8834. dispose(): void;
  8835. }
  8836. }
  8837. declare module "babylonjs/Materials/Textures/rawTexture" {
  8838. import { Scene } from "babylonjs/scene";
  8839. import { Texture } from "babylonjs/Materials/Textures/texture";
  8840. /**
  8841. * Raw texture can help creating a texture directly from an array of data.
  8842. * This can be super useful if you either get the data from an uncompressed source or
  8843. * if you wish to create your texture pixel by pixel.
  8844. */
  8845. export class RawTexture extends Texture {
  8846. /**
  8847. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8848. */
  8849. format: number;
  8850. private _engine;
  8851. /**
  8852. * Instantiates a new RawTexture.
  8853. * Raw texture can help creating a texture directly from an array of data.
  8854. * This can be super useful if you either get the data from an uncompressed source or
  8855. * if you wish to create your texture pixel by pixel.
  8856. * @param data define the array of data to use to create the texture
  8857. * @param width define the width of the texture
  8858. * @param height define the height of the texture
  8859. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8860. * @param scene define the scene the texture belongs to
  8861. * @param generateMipMaps define whether mip maps should be generated or not
  8862. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8863. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8864. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8865. */
  8866. constructor(data: ArrayBufferView, width: number, height: number,
  8867. /**
  8868. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  8869. */
  8870. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  8871. /**
  8872. * Updates the texture underlying data.
  8873. * @param data Define the new data of the texture
  8874. */
  8875. update(data: ArrayBufferView): void;
  8876. /**
  8877. * Creates a luminance texture from some data.
  8878. * @param data Define the texture data
  8879. * @param width Define the width of the texture
  8880. * @param height Define the height of the texture
  8881. * @param scene Define the scene the texture belongs to
  8882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8885. * @returns the luminance texture
  8886. */
  8887. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8888. /**
  8889. * Creates a luminance alpha texture from some data.
  8890. * @param data Define the texture data
  8891. * @param width Define the width of the texture
  8892. * @param height Define the height of the texture
  8893. * @param scene Define the scene the texture belongs to
  8894. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8895. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8896. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8897. * @returns the luminance alpha texture
  8898. */
  8899. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8900. /**
  8901. * Creates an alpha texture from some data.
  8902. * @param data Define the texture data
  8903. * @param width Define the width of the texture
  8904. * @param height Define the height of the texture
  8905. * @param scene Define the scene the texture belongs to
  8906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8909. * @returns the alpha texture
  8910. */
  8911. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  8912. /**
  8913. * Creates a RGB texture from some data.
  8914. * @param data Define the texture data
  8915. * @param width Define the width of the texture
  8916. * @param height Define the height of the texture
  8917. * @param scene Define the scene the texture belongs to
  8918. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8922. * @returns the RGB alpha texture
  8923. */
  8924. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8925. /**
  8926. * Creates a RGBA texture from some data.
  8927. * @param data Define the texture data
  8928. * @param width Define the width of the texture
  8929. * @param height Define the height of the texture
  8930. * @param scene Define the scene the texture belongs to
  8931. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8932. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8933. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8934. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8935. * @returns the RGBA texture
  8936. */
  8937. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8938. /**
  8939. * Creates a R texture from some data.
  8940. * @param data Define the texture data
  8941. * @param width Define the width of the texture
  8942. * @param height Define the height of the texture
  8943. * @param scene Define the scene the texture belongs to
  8944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  8945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  8946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  8947. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  8948. * @returns the R texture
  8949. */
  8950. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  8951. }
  8952. }
  8953. declare module "babylonjs/Bones/skeleton" {
  8954. import { Bone } from "babylonjs/Bones/bone";
  8955. import { IAnimatable } from "babylonjs/Misc/tools";
  8956. import { Observable } from "babylonjs/Misc/observable";
  8957. import { Vector3, Matrix } from "babylonjs/Maths/math";
  8958. import { Scene } from "babylonjs/scene";
  8959. import { Nullable } from "babylonjs/types";
  8960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8961. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  8962. import { Animatable } from "babylonjs/Animations/animatable";
  8963. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8964. import { AnimationRange, Animation } from "babylonjs/Animations/animation";
  8965. /**
  8966. * Class used to handle skinning animations
  8967. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8968. */
  8969. export class Skeleton implements IAnimatable {
  8970. /** defines the skeleton name */
  8971. name: string;
  8972. /** defines the skeleton Id */
  8973. id: string;
  8974. /**
  8975. * Defines the list of child bones
  8976. */
  8977. bones: Bone[];
  8978. /**
  8979. * Defines an estimate of the dimension of the skeleton at rest
  8980. */
  8981. dimensionsAtRest: Vector3;
  8982. /**
  8983. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  8984. */
  8985. needInitialSkinMatrix: boolean;
  8986. /**
  8987. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  8988. */
  8989. overrideMesh: Nullable<AbstractMesh>;
  8990. /**
  8991. * Gets the list of animations attached to this skeleton
  8992. */
  8993. animations: Array<Animation>;
  8994. private _scene;
  8995. private _isDirty;
  8996. private _transformMatrices;
  8997. private _transformMatrixTexture;
  8998. private _meshesWithPoseMatrix;
  8999. private _animatables;
  9000. private _identity;
  9001. private _synchronizedWithMesh;
  9002. private _ranges;
  9003. private _lastAbsoluteTransformsUpdateId;
  9004. private _canUseTextureForBones;
  9005. /** @hidden */
  9006. _numBonesWithLinkedTransformNode: number;
  9007. /**
  9008. * Specifies if the skeleton should be serialized
  9009. */
  9010. doNotSerialize: boolean;
  9011. /**
  9012. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  9013. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  9014. */
  9015. useTextureToStoreBoneMatrices: boolean;
  9016. private _animationPropertiesOverride;
  9017. /**
  9018. * Gets or sets the animation properties override
  9019. */
  9020. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9021. /**
  9022. * An observable triggered before computing the skeleton's matrices
  9023. */
  9024. onBeforeComputeObservable: Observable<Skeleton>;
  9025. /**
  9026. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  9027. */
  9028. readonly isUsingTextureForMatrices: boolean;
  9029. /**
  9030. * Creates a new skeleton
  9031. * @param name defines the skeleton name
  9032. * @param id defines the skeleton Id
  9033. * @param scene defines the hosting scene
  9034. */
  9035. constructor(
  9036. /** defines the skeleton name */
  9037. name: string,
  9038. /** defines the skeleton Id */
  9039. id: string, scene: Scene);
  9040. /**
  9041. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  9042. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  9043. * @returns a Float32Array containing matrices data
  9044. */
  9045. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  9046. /**
  9047. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  9048. * @returns a raw texture containing the data
  9049. */
  9050. getTransformMatrixTexture(): Nullable<RawTexture>;
  9051. /**
  9052. * Gets the current hosting scene
  9053. * @returns a scene object
  9054. */
  9055. getScene(): Scene;
  9056. /**
  9057. * Gets a string representing the current skeleton data
  9058. * @param fullDetails defines a boolean indicating if we want a verbose version
  9059. * @returns a string representing the current skeleton data
  9060. */
  9061. toString(fullDetails?: boolean): string;
  9062. /**
  9063. * Get bone's index searching by name
  9064. * @param name defines bone's name to search for
  9065. * @return the indice of the bone. Returns -1 if not found
  9066. */
  9067. getBoneIndexByName(name: string): number;
  9068. /**
  9069. * Creater a new animation range
  9070. * @param name defines the name of the range
  9071. * @param from defines the start key
  9072. * @param to defines the end key
  9073. */
  9074. createAnimationRange(name: string, from: number, to: number): void;
  9075. /**
  9076. * Delete a specific animation range
  9077. * @param name defines the name of the range
  9078. * @param deleteFrames defines if frames must be removed as well
  9079. */
  9080. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  9081. /**
  9082. * Gets a specific animation range
  9083. * @param name defines the name of the range to look for
  9084. * @returns the requested animation range or null if not found
  9085. */
  9086. getAnimationRange(name: string): Nullable<AnimationRange>;
  9087. /**
  9088. * Gets the list of all animation ranges defined on this skeleton
  9089. * @returns an array
  9090. */
  9091. getAnimationRanges(): Nullable<AnimationRange>[];
  9092. /**
  9093. * Copy animation range from a source skeleton.
  9094. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  9095. * @param source defines the source skeleton
  9096. * @param name defines the name of the range to copy
  9097. * @param rescaleAsRequired defines if rescaling must be applied if required
  9098. * @returns true if operation was successful
  9099. */
  9100. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  9101. /**
  9102. * Forces the skeleton to go to rest pose
  9103. */
  9104. returnToRest(): void;
  9105. private _getHighestAnimationFrame;
  9106. /**
  9107. * Begin a specific animation range
  9108. * @param name defines the name of the range to start
  9109. * @param loop defines if looping must be turned on (false by default)
  9110. * @param speedRatio defines the speed ratio to apply (1 by default)
  9111. * @param onAnimationEnd defines a callback which will be called when animation will end
  9112. * @returns a new animatable
  9113. */
  9114. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  9115. /** @hidden */
  9116. _markAsDirty(): void;
  9117. /** @hidden */
  9118. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9119. /** @hidden */
  9120. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  9121. private _computeTransformMatrices;
  9122. /**
  9123. * Build all resources required to render a skeleton
  9124. */
  9125. prepare(): void;
  9126. /**
  9127. * Gets the list of animatables currently running for this skeleton
  9128. * @returns an array of animatables
  9129. */
  9130. getAnimatables(): IAnimatable[];
  9131. /**
  9132. * Clone the current skeleton
  9133. * @param name defines the name of the new skeleton
  9134. * @param id defines the id of the enw skeleton
  9135. * @returns the new skeleton
  9136. */
  9137. clone(name: string, id: string): Skeleton;
  9138. /**
  9139. * Enable animation blending for this skeleton
  9140. * @param blendingSpeed defines the blending speed to apply
  9141. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9142. */
  9143. enableBlending(blendingSpeed?: number): void;
  9144. /**
  9145. * Releases all resources associated with the current skeleton
  9146. */
  9147. dispose(): void;
  9148. /**
  9149. * Serialize the skeleton in a JSON object
  9150. * @returns a JSON object
  9151. */
  9152. serialize(): any;
  9153. /**
  9154. * Creates a new skeleton from serialized data
  9155. * @param parsedSkeleton defines the serialized data
  9156. * @param scene defines the hosting scene
  9157. * @returns a new skeleton
  9158. */
  9159. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  9160. /**
  9161. * Compute all node absolute transforms
  9162. * @param forceUpdate defines if computation must be done even if cache is up to date
  9163. */
  9164. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  9165. /**
  9166. * Gets the root pose matrix
  9167. * @returns a matrix
  9168. */
  9169. getPoseMatrix(): Nullable<Matrix>;
  9170. /**
  9171. * Sorts bones per internal index
  9172. */
  9173. sortBones(): void;
  9174. private _sortBones;
  9175. }
  9176. }
  9177. declare module "babylonjs/Bones/bone" {
  9178. import { Skeleton } from "babylonjs/Bones/skeleton";
  9179. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  9180. import { Nullable } from "babylonjs/types";
  9181. import { Animation } from "babylonjs/Animations/animation";
  9182. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  9183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9184. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9185. import { Node } from "babylonjs/node";
  9186. /**
  9187. * Class used to store bone information
  9188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9189. */
  9190. export class Bone extends Node {
  9191. /**
  9192. * defines the bone name
  9193. */
  9194. name: string;
  9195. private static _tmpVecs;
  9196. private static _tmpQuat;
  9197. private static _tmpMats;
  9198. /**
  9199. * Gets the list of child bones
  9200. */
  9201. children: Bone[];
  9202. /** Gets the animations associated with this bone */
  9203. animations: Animation[];
  9204. /**
  9205. * Gets or sets bone length
  9206. */
  9207. length: number;
  9208. /**
  9209. * @hidden Internal only
  9210. * Set this value to map this bone to a different index in the transform matrices
  9211. * Set this value to -1 to exclude the bone from the transform matrices
  9212. */
  9213. _index: Nullable<number>;
  9214. private _skeleton;
  9215. private _localMatrix;
  9216. private _restPose;
  9217. private _baseMatrix;
  9218. private _absoluteTransform;
  9219. private _invertedAbsoluteTransform;
  9220. private _parent;
  9221. private _scalingDeterminant;
  9222. private _worldTransform;
  9223. private _localScaling;
  9224. private _localRotation;
  9225. private _localPosition;
  9226. private _needToDecompose;
  9227. private _needToCompose;
  9228. /** @hidden */
  9229. _linkedTransformNode: Nullable<TransformNode>;
  9230. /** @hidden */
  9231. /** @hidden */
  9232. _matrix: Matrix;
  9233. /**
  9234. * Create a new bone
  9235. * @param name defines the bone name
  9236. * @param skeleton defines the parent skeleton
  9237. * @param parentBone defines the parent (can be null if the bone is the root)
  9238. * @param localMatrix defines the local matrix
  9239. * @param restPose defines the rest pose matrix
  9240. * @param baseMatrix defines the base matrix
  9241. * @param index defines index of the bone in the hiearchy
  9242. */
  9243. constructor(
  9244. /**
  9245. * defines the bone name
  9246. */
  9247. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9248. /**
  9249. * Gets the parent skeleton
  9250. * @returns a skeleton
  9251. */
  9252. getSkeleton(): Skeleton;
  9253. /**
  9254. * Gets parent bone
  9255. * @returns a bone or null if the bone is the root of the bone hierarchy
  9256. */
  9257. getParent(): Nullable<Bone>;
  9258. /**
  9259. * Sets the parent bone
  9260. * @param parent defines the parent (can be null if the bone is the root)
  9261. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9262. */
  9263. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9264. /**
  9265. * Gets the local matrix
  9266. * @returns a matrix
  9267. */
  9268. getLocalMatrix(): Matrix;
  9269. /**
  9270. * Gets the base matrix (initial matrix which remains unchanged)
  9271. * @returns a matrix
  9272. */
  9273. getBaseMatrix(): Matrix;
  9274. /**
  9275. * Gets the rest pose matrix
  9276. * @returns a matrix
  9277. */
  9278. getRestPose(): Matrix;
  9279. /**
  9280. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9281. */
  9282. getWorldMatrix(): Matrix;
  9283. /**
  9284. * Sets the local matrix to rest pose matrix
  9285. */
  9286. returnToRest(): void;
  9287. /**
  9288. * Gets the inverse of the absolute transform matrix.
  9289. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9290. * @returns a matrix
  9291. */
  9292. getInvertedAbsoluteTransform(): Matrix;
  9293. /**
  9294. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9295. * @returns a matrix
  9296. */
  9297. getAbsoluteTransform(): Matrix;
  9298. /**
  9299. * Links with the given transform node.
  9300. * The local matrix of this bone is copied from the transform node every frame.
  9301. * @param transformNode defines the transform node to link to
  9302. */
  9303. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9304. /** Gets or sets current position (in local space) */
  9305. position: Vector3;
  9306. /** Gets or sets current rotation (in local space) */
  9307. rotation: Vector3;
  9308. /** Gets or sets current rotation quaternion (in local space) */
  9309. rotationQuaternion: Quaternion;
  9310. /** Gets or sets current scaling (in local space) */
  9311. scaling: Vector3;
  9312. /**
  9313. * Gets the animation properties override
  9314. */
  9315. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9316. private _decompose;
  9317. private _compose;
  9318. /**
  9319. * Update the base and local matrices
  9320. * @param matrix defines the new base or local matrix
  9321. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9322. * @param updateLocalMatrix defines if the local matrix should be updated
  9323. */
  9324. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9325. /** @hidden */
  9326. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9327. /**
  9328. * Flag the bone as dirty (Forcing it to update everything)
  9329. */
  9330. markAsDirty(): void;
  9331. private _markAsDirtyAndCompose;
  9332. private _markAsDirtyAndDecompose;
  9333. /**
  9334. * Copy an animation range from another bone
  9335. * @param source defines the source bone
  9336. * @param rangeName defines the range name to copy
  9337. * @param frameOffset defines the frame offset
  9338. * @param rescaleAsRequired defines if rescaling must be applied if required
  9339. * @param skelDimensionsRatio defines the scaling ratio
  9340. * @returns true if operation was successful
  9341. */
  9342. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  9343. /**
  9344. * Translate the bone in local or world space
  9345. * @param vec The amount to translate the bone
  9346. * @param space The space that the translation is in
  9347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9348. */
  9349. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9350. /**
  9351. * Set the postion of the bone in local or world space
  9352. * @param position The position to set the bone
  9353. * @param space The space that the position is in
  9354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9355. */
  9356. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9357. /**
  9358. * Set the absolute position of the bone (world space)
  9359. * @param position The position to set the bone
  9360. * @param mesh The mesh that this bone is attached to
  9361. */
  9362. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9363. /**
  9364. * Scale the bone on the x, y and z axes (in local space)
  9365. * @param x The amount to scale the bone on the x axis
  9366. * @param y The amount to scale the bone on the y axis
  9367. * @param z The amount to scale the bone on the z axis
  9368. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9369. */
  9370. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9371. /**
  9372. * Set the bone scaling in local space
  9373. * @param scale defines the scaling vector
  9374. */
  9375. setScale(scale: Vector3): void;
  9376. /**
  9377. * Gets the current scaling in local space
  9378. * @returns the current scaling vector
  9379. */
  9380. getScale(): Vector3;
  9381. /**
  9382. * Gets the current scaling in local space and stores it in a target vector
  9383. * @param result defines the target vector
  9384. */
  9385. getScaleToRef(result: Vector3): void;
  9386. /**
  9387. * Set the yaw, pitch, and roll of the bone in local or world space
  9388. * @param yaw The rotation of the bone on the y axis
  9389. * @param pitch The rotation of the bone on the x axis
  9390. * @param roll The rotation of the bone on the z axis
  9391. * @param space The space that the axes of rotation are in
  9392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9393. */
  9394. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9395. /**
  9396. * Add a rotation to the bone on an axis in local or world space
  9397. * @param axis The axis to rotate the bone on
  9398. * @param amount The amount to rotate the bone
  9399. * @param space The space that the axis is in
  9400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9401. */
  9402. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9403. /**
  9404. * Set the rotation of the bone to a particular axis angle in local or world space
  9405. * @param axis The axis to rotate the bone on
  9406. * @param angle The angle that the bone should be rotated to
  9407. * @param space The space that the axis is in
  9408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9409. */
  9410. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9411. /**
  9412. * Set the euler rotation of the bone in local of world space
  9413. * @param rotation The euler rotation that the bone should be set to
  9414. * @param space The space that the rotation is in
  9415. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9416. */
  9417. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9418. /**
  9419. * Set the quaternion rotation of the bone in local of world space
  9420. * @param quat The quaternion rotation that the bone should be set to
  9421. * @param space The space that the rotation is in
  9422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9423. */
  9424. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9425. /**
  9426. * Set the rotation matrix of the bone in local of world space
  9427. * @param rotMat The rotation matrix that the bone should be set to
  9428. * @param space The space that the rotation is in
  9429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9430. */
  9431. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9432. private _rotateWithMatrix;
  9433. private _getNegativeRotationToRef;
  9434. /**
  9435. * Get the position of the bone in local or world space
  9436. * @param space The space that the returned position is in
  9437. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9438. * @returns The position of the bone
  9439. */
  9440. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9441. /**
  9442. * Copy the position of the bone to a vector3 in local or world space
  9443. * @param space The space that the returned position is in
  9444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9445. * @param result The vector3 to copy the position to
  9446. */
  9447. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9448. /**
  9449. * Get the absolute position of the bone (world space)
  9450. * @param mesh The mesh that this bone is attached to
  9451. * @returns The absolute position of the bone
  9452. */
  9453. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9454. /**
  9455. * Copy the absolute position of the bone (world space) to the result param
  9456. * @param mesh The mesh that this bone is attached to
  9457. * @param result The vector3 to copy the absolute position to
  9458. */
  9459. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9460. /**
  9461. * Compute the absolute transforms of this bone and its children
  9462. */
  9463. computeAbsoluteTransforms(): void;
  9464. /**
  9465. * Get the world direction from an axis that is in the local space of the bone
  9466. * @param localAxis The local direction that is used to compute the world direction
  9467. * @param mesh The mesh that this bone is attached to
  9468. * @returns The world direction
  9469. */
  9470. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9471. /**
  9472. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9473. * @param localAxis The local direction that is used to compute the world direction
  9474. * @param mesh The mesh that this bone is attached to
  9475. * @param result The vector3 that the world direction will be copied to
  9476. */
  9477. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9478. /**
  9479. * Get the euler rotation of the bone in local or world space
  9480. * @param space The space that the rotation should be in
  9481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9482. * @returns The euler rotation
  9483. */
  9484. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9485. /**
  9486. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9487. * @param space The space that the rotation should be in
  9488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9489. * @param result The vector3 that the rotation should be copied to
  9490. */
  9491. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9492. /**
  9493. * Get the quaternion rotation of the bone in either local or world space
  9494. * @param space The space that the rotation should be in
  9495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9496. * @returns The quaternion rotation
  9497. */
  9498. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9499. /**
  9500. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9501. * @param space The space that the rotation should be in
  9502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9503. * @param result The quaternion that the rotation should be copied to
  9504. */
  9505. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9506. /**
  9507. * Get the rotation matrix of the bone in local or world space
  9508. * @param space The space that the rotation should be in
  9509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9510. * @returns The rotation matrix
  9511. */
  9512. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9513. /**
  9514. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9515. * @param space The space that the rotation should be in
  9516. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9517. * @param result The quaternion that the rotation should be copied to
  9518. */
  9519. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9520. /**
  9521. * Get the world position of a point that is in the local space of the bone
  9522. * @param position The local position
  9523. * @param mesh The mesh that this bone is attached to
  9524. * @returns The world position
  9525. */
  9526. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9527. /**
  9528. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9529. * @param position The local position
  9530. * @param mesh The mesh that this bone is attached to
  9531. * @param result The vector3 that the world position should be copied to
  9532. */
  9533. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9534. /**
  9535. * Get the local position of a point that is in world space
  9536. * @param position The world position
  9537. * @param mesh The mesh that this bone is attached to
  9538. * @returns The local position
  9539. */
  9540. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9541. /**
  9542. * Get the local position of a point that is in world space and copy it to the result param
  9543. * @param position The world position
  9544. * @param mesh The mesh that this bone is attached to
  9545. * @param result The vector3 that the local position should be copied to
  9546. */
  9547. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9548. }
  9549. }
  9550. declare module "babylonjs/Meshes/transformNode" {
  9551. import { DeepImmutable } from "babylonjs/types";
  9552. import { Observable } from "babylonjs/Misc/observable";
  9553. import { Nullable } from "babylonjs/types";
  9554. import { Camera } from "babylonjs/Cameras/camera";
  9555. import { Scene } from "babylonjs/scene";
  9556. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  9557. import { Node } from "babylonjs/node";
  9558. import { Bone } from "babylonjs/Bones/bone";
  9559. /**
  9560. * 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.
  9561. * @see https://doc.babylonjs.com/how_to/transformnode
  9562. */
  9563. export class TransformNode extends Node {
  9564. /**
  9565. * Object will not rotate to face the camera
  9566. */
  9567. static BILLBOARDMODE_NONE: number;
  9568. /**
  9569. * Object will rotate to face the camera but only on the x axis
  9570. */
  9571. static BILLBOARDMODE_X: number;
  9572. /**
  9573. * Object will rotate to face the camera but only on the y axis
  9574. */
  9575. static BILLBOARDMODE_Y: number;
  9576. /**
  9577. * Object will rotate to face the camera but only on the z axis
  9578. */
  9579. static BILLBOARDMODE_Z: number;
  9580. /**
  9581. * Object will rotate to face the camera
  9582. */
  9583. static BILLBOARDMODE_ALL: number;
  9584. private _forward;
  9585. private _forwardInverted;
  9586. private _up;
  9587. private _right;
  9588. private _rightInverted;
  9589. private _position;
  9590. private _rotation;
  9591. private _rotationQuaternion;
  9592. protected _scaling: Vector3;
  9593. protected _isDirty: boolean;
  9594. private _transformToBoneReferal;
  9595. /**
  9596. * Set the billboard mode. Default is 0.
  9597. *
  9598. * | Value | Type | Description |
  9599. * | --- | --- | --- |
  9600. * | 0 | BILLBOARDMODE_NONE | |
  9601. * | 1 | BILLBOARDMODE_X | |
  9602. * | 2 | BILLBOARDMODE_Y | |
  9603. * | 4 | BILLBOARDMODE_Z | |
  9604. * | 7 | BILLBOARDMODE_ALL | |
  9605. *
  9606. */
  9607. billboardMode: number;
  9608. /**
  9609. * 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
  9610. */
  9611. scalingDeterminant: number;
  9612. /**
  9613. * Sets the distance of the object to max, often used by skybox
  9614. */
  9615. infiniteDistance: boolean;
  9616. /**
  9617. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  9618. * By default the system will update normals to compensate
  9619. */
  9620. ignoreNonUniformScaling: boolean;
  9621. /** @hidden */
  9622. _poseMatrix: Matrix;
  9623. /** @hidden */
  9624. _localMatrix: Matrix;
  9625. private _absolutePosition;
  9626. private _pivotMatrix;
  9627. private _pivotMatrixInverse;
  9628. protected _postMultiplyPivotMatrix: boolean;
  9629. protected _isWorldMatrixFrozen: boolean;
  9630. /** @hidden */
  9631. _indexInSceneTransformNodesArray: number;
  9632. /**
  9633. * An event triggered after the world matrix is updated
  9634. */
  9635. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  9636. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  9637. /**
  9638. * Gets a string identifying the name of the class
  9639. * @returns "TransformNode" string
  9640. */
  9641. getClassName(): string;
  9642. /**
  9643. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  9644. */
  9645. position: Vector3;
  9646. /**
  9647. * 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)).
  9648. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  9649. */
  9650. rotation: Vector3;
  9651. /**
  9652. * 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)).
  9653. */
  9654. scaling: Vector3;
  9655. /**
  9656. * 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).
  9657. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  9658. */
  9659. rotationQuaternion: Nullable<Quaternion>;
  9660. /**
  9661. * The forward direction of that transform in world space.
  9662. */
  9663. readonly forward: Vector3;
  9664. /**
  9665. * The up direction of that transform in world space.
  9666. */
  9667. readonly up: Vector3;
  9668. /**
  9669. * The right direction of that transform in world space.
  9670. */
  9671. readonly right: Vector3;
  9672. /**
  9673. * Copies the parameter passed Matrix into the mesh Pose matrix.
  9674. * @param matrix the matrix to copy the pose from
  9675. * @returns this TransformNode.
  9676. */
  9677. updatePoseMatrix(matrix: Matrix): TransformNode;
  9678. /**
  9679. * Returns the mesh Pose matrix.
  9680. * @returns the pose matrix
  9681. */
  9682. getPoseMatrix(): Matrix;
  9683. /** @hidden */
  9684. _isSynchronized(): boolean;
  9685. /** @hidden */
  9686. _initCache(): void;
  9687. /**
  9688. * Flag the transform node as dirty (Forcing it to update everything)
  9689. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  9690. * @returns this transform node
  9691. */
  9692. markAsDirty(property: string): TransformNode;
  9693. /**
  9694. * Returns the current mesh absolute position.
  9695. * Returns a Vector3.
  9696. */
  9697. readonly absolutePosition: Vector3;
  9698. /**
  9699. * Sets a new matrix to apply before all other transformation
  9700. * @param matrix defines the transform matrix
  9701. * @returns the current TransformNode
  9702. */
  9703. setPreTransformMatrix(matrix: Matrix): TransformNode;
  9704. /**
  9705. * Sets a new pivot matrix to the current node
  9706. * @param matrix defines the new pivot matrix to use
  9707. * @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
  9708. * @returns the current TransformNode
  9709. */
  9710. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  9711. /**
  9712. * Returns the mesh pivot matrix.
  9713. * Default : Identity.
  9714. * @returns the matrix
  9715. */
  9716. getPivotMatrix(): Matrix;
  9717. /**
  9718. * Prevents the World matrix to be computed any longer.
  9719. * @returns the TransformNode.
  9720. */
  9721. freezeWorldMatrix(): TransformNode;
  9722. /**
  9723. * Allows back the World matrix computation.
  9724. * @returns the TransformNode.
  9725. */
  9726. unfreezeWorldMatrix(): this;
  9727. /**
  9728. * True if the World matrix has been frozen.
  9729. */
  9730. readonly isWorldMatrixFrozen: boolean;
  9731. /**
  9732. * Retuns the mesh absolute position in the World.
  9733. * @returns a Vector3.
  9734. */
  9735. getAbsolutePosition(): Vector3;
  9736. /**
  9737. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  9738. * @param absolutePosition the absolute position to set
  9739. * @returns the TransformNode.
  9740. */
  9741. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  9742. /**
  9743. * Sets the mesh position in its local space.
  9744. * @param vector3 the position to set in localspace
  9745. * @returns the TransformNode.
  9746. */
  9747. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  9748. /**
  9749. * Returns the mesh position in the local space from the current World matrix values.
  9750. * @returns a new Vector3.
  9751. */
  9752. getPositionExpressedInLocalSpace(): Vector3;
  9753. /**
  9754. * Translates the mesh along the passed Vector3 in its local space.
  9755. * @param vector3 the distance to translate in localspace
  9756. * @returns the TransformNode.
  9757. */
  9758. locallyTranslate(vector3: Vector3): TransformNode;
  9759. private static _lookAtVectorCache;
  9760. /**
  9761. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  9762. * @param targetPoint the position (must be in same space as current mesh) to look at
  9763. * @param yawCor optional yaw (y-axis) correction in radians
  9764. * @param pitchCor optional pitch (x-axis) correction in radians
  9765. * @param rollCor optional roll (z-axis) correction in radians
  9766. * @param space the choosen space of the target
  9767. * @returns the TransformNode.
  9768. */
  9769. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  9770. /**
  9771. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9772. * This Vector3 is expressed in the World space.
  9773. * @param localAxis axis to rotate
  9774. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  9775. */
  9776. getDirection(localAxis: Vector3): Vector3;
  9777. /**
  9778. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  9779. * localAxis is expressed in the mesh local space.
  9780. * result is computed in the Wordl space from the mesh World matrix.
  9781. * @param localAxis axis to rotate
  9782. * @param result the resulting transformnode
  9783. * @returns this TransformNode.
  9784. */
  9785. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  9786. /**
  9787. * Sets this transform node rotation to the given local axis.
  9788. * @param localAxis the axis in local space
  9789. * @param yawCor optional yaw (y-axis) correction in radians
  9790. * @param pitchCor optional pitch (x-axis) correction in radians
  9791. * @param rollCor optional roll (z-axis) correction in radians
  9792. * @returns this TransformNode
  9793. */
  9794. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  9795. /**
  9796. * Sets a new pivot point to the current node
  9797. * @param point defines the new pivot point to use
  9798. * @param space defines if the point is in world or local space (local by default)
  9799. * @returns the current TransformNode
  9800. */
  9801. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9802. /**
  9803. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9804. * @returns the pivot point
  9805. */
  9806. getPivotPoint(): Vector3;
  9807. /**
  9808. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9809. * @param result the vector3 to store the result
  9810. * @returns this TransformNode.
  9811. */
  9812. getPivotPointToRef(result: Vector3): TransformNode;
  9813. /**
  9814. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9815. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9816. */
  9817. getAbsolutePivotPoint(): Vector3;
  9818. /**
  9819. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9820. * @param result vector3 to store the result
  9821. * @returns this TransformNode.
  9822. */
  9823. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9824. /**
  9825. * Defines the passed node as the parent of the current node.
  9826. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9827. * @param node the node ot set as the parent
  9828. * @returns this TransformNode.
  9829. */
  9830. setParent(node: Nullable<Node>): TransformNode;
  9831. private _nonUniformScaling;
  9832. /**
  9833. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9834. */
  9835. readonly nonUniformScaling: boolean;
  9836. /** @hidden */
  9837. _updateNonUniformScalingState(value: boolean): boolean;
  9838. /**
  9839. * Attach the current TransformNode to another TransformNode associated with a bone
  9840. * @param bone Bone affecting the TransformNode
  9841. * @param affectedTransformNode TransformNode associated with the bone
  9842. * @returns this object
  9843. */
  9844. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9845. /**
  9846. * Detach the transform node if its associated with a bone
  9847. * @returns this object
  9848. */
  9849. detachFromBone(): TransformNode;
  9850. private static _rotationAxisCache;
  9851. /**
  9852. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9853. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9854. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9855. * The passed axis is also normalized.
  9856. * @param axis the axis to rotate around
  9857. * @param amount the amount to rotate in radians
  9858. * @param space Space to rotate in (Default: local)
  9859. * @returns the TransformNode.
  9860. */
  9861. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9862. /**
  9863. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9864. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9865. * The passed axis is also normalized. .
  9866. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9867. * @param point the point to rotate around
  9868. * @param axis the axis to rotate around
  9869. * @param amount the amount to rotate in radians
  9870. * @returns the TransformNode
  9871. */
  9872. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9873. /**
  9874. * Translates the mesh along the axis vector for the passed distance in the given space.
  9875. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9876. * @param axis the axis to translate in
  9877. * @param distance the distance to translate
  9878. * @param space Space to rotate in (Default: local)
  9879. * @returns the TransformNode.
  9880. */
  9881. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9882. /**
  9883. * Adds a rotation step to the mesh current rotation.
  9884. * x, y, z are Euler angles expressed in radians.
  9885. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9886. * This means this rotation is made in the mesh local space only.
  9887. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9888. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9889. * ```javascript
  9890. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9891. * ```
  9892. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9893. * 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.
  9894. * @param x Rotation to add
  9895. * @param y Rotation to add
  9896. * @param z Rotation to add
  9897. * @returns the TransformNode.
  9898. */
  9899. addRotation(x: number, y: number, z: number): TransformNode;
  9900. /**
  9901. * Computes the world matrix of the node
  9902. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9903. * @returns the world matrix
  9904. */
  9905. computeWorldMatrix(force?: boolean): Matrix;
  9906. protected _afterComputeWorldMatrix(): void;
  9907. /**
  9908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9909. * @param func callback function to add
  9910. *
  9911. * @returns the TransformNode.
  9912. */
  9913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9914. /**
  9915. * Removes a registered callback function.
  9916. * @param func callback function to remove
  9917. * @returns the TransformNode.
  9918. */
  9919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9920. /**
  9921. * Gets the position of the current mesh in camera space
  9922. * @param camera defines the camera to use
  9923. * @returns a position
  9924. */
  9925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9926. /**
  9927. * Returns the distance from the mesh to the active camera
  9928. * @param camera defines the camera to use
  9929. * @returns the distance
  9930. */
  9931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9932. /**
  9933. * Clone the current transform node
  9934. * @param name Name of the new clone
  9935. * @param newParent New parent for the clone
  9936. * @param doNotCloneChildren Do not clone children hierarchy
  9937. * @returns the new transform node
  9938. */
  9939. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9940. /**
  9941. * Serializes the objects information.
  9942. * @param currentSerializationObject defines the object to serialize in
  9943. * @returns the serialized object
  9944. */
  9945. serialize(currentSerializationObject?: any): any;
  9946. /**
  9947. * Returns a new TransformNode object parsed from the source provided.
  9948. * @param parsedTransformNode is the source.
  9949. * @param scene the scne the object belongs to
  9950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9951. * @returns a new TransformNode object parsed from the source provided.
  9952. */
  9953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9954. /**
  9955. * Get all child-transformNodes of this node
  9956. * @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
  9957. * @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
  9958. * @returns an array of TransformNode
  9959. */
  9960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9961. /**
  9962. * Releases resources associated with this transform node.
  9963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9965. */
  9966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9967. }
  9968. }
  9969. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  9970. import { Observable } from "babylonjs/Misc/observable";
  9971. import { Nullable } from "babylonjs/types";
  9972. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  9973. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9975. import { Ray } from "babylonjs/Culling/ray";
  9976. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  9977. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  9978. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  9979. /**
  9980. * Defines the types of pose enabled controllers that are supported
  9981. */
  9982. export enum PoseEnabledControllerType {
  9983. /**
  9984. * HTC Vive
  9985. */
  9986. VIVE = 0,
  9987. /**
  9988. * Oculus Rift
  9989. */
  9990. OCULUS = 1,
  9991. /**
  9992. * Windows mixed reality
  9993. */
  9994. WINDOWS = 2,
  9995. /**
  9996. * Samsung gear VR
  9997. */
  9998. GEAR_VR = 3,
  9999. /**
  10000. * Google Daydream
  10001. */
  10002. DAYDREAM = 4,
  10003. /**
  10004. * Generic
  10005. */
  10006. GENERIC = 5
  10007. }
  10008. /**
  10009. * Defines the MutableGamepadButton interface for the state of a gamepad button
  10010. */
  10011. export interface MutableGamepadButton {
  10012. /**
  10013. * Value of the button/trigger
  10014. */
  10015. value: number;
  10016. /**
  10017. * If the button/trigger is currently touched
  10018. */
  10019. touched: boolean;
  10020. /**
  10021. * If the button/trigger is currently pressed
  10022. */
  10023. pressed: boolean;
  10024. }
  10025. /**
  10026. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  10027. * @hidden
  10028. */
  10029. export interface ExtendedGamepadButton extends GamepadButton {
  10030. /**
  10031. * If the button/trigger is currently pressed
  10032. */
  10033. readonly pressed: boolean;
  10034. /**
  10035. * If the button/trigger is currently touched
  10036. */
  10037. readonly touched: boolean;
  10038. /**
  10039. * Value of the button/trigger
  10040. */
  10041. readonly value: number;
  10042. }
  10043. /** @hidden */
  10044. export interface _GamePadFactory {
  10045. /**
  10046. * Returns wether or not the current gamepad can be created for this type of controller.
  10047. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10048. * @returns true if it can be created, otherwise false
  10049. */
  10050. canCreate(gamepadInfo: any): boolean;
  10051. /**
  10052. * Creates a new instance of the Gamepad.
  10053. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  10054. * @returns the new gamepad instance
  10055. */
  10056. create(gamepadInfo: any): Gamepad;
  10057. }
  10058. /**
  10059. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10060. */
  10061. export class PoseEnabledControllerHelper {
  10062. /** @hidden */
  10063. static _ControllerFactories: _GamePadFactory[];
  10064. /** @hidden */
  10065. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  10066. /**
  10067. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  10068. * @param vrGamepad the gamepad to initialized
  10069. * @returns a vr controller of the type the gamepad identified as
  10070. */
  10071. static InitiateController(vrGamepad: any): Gamepad;
  10072. }
  10073. /**
  10074. * Defines the PoseEnabledController object that contains state of a vr capable controller
  10075. */
  10076. export class PoseEnabledController extends Gamepad implements PoseControlled {
  10077. private _deviceRoomPosition;
  10078. private _deviceRoomRotationQuaternion;
  10079. /**
  10080. * The device position in babylon space
  10081. */
  10082. devicePosition: Vector3;
  10083. /**
  10084. * The device rotation in babylon space
  10085. */
  10086. deviceRotationQuaternion: Quaternion;
  10087. /**
  10088. * The scale factor of the device in babylon space
  10089. */
  10090. deviceScaleFactor: number;
  10091. /**
  10092. * (Likely devicePosition should be used instead) The device position in its room space
  10093. */
  10094. position: Vector3;
  10095. /**
  10096. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  10097. */
  10098. rotationQuaternion: Quaternion;
  10099. /**
  10100. * The type of controller (Eg. Windows mixed reality)
  10101. */
  10102. controllerType: PoseEnabledControllerType;
  10103. protected _calculatedPosition: Vector3;
  10104. private _calculatedRotation;
  10105. /**
  10106. * The raw pose from the device
  10107. */
  10108. rawPose: DevicePose;
  10109. private _trackPosition;
  10110. private _maxRotationDistFromHeadset;
  10111. private _draggedRoomRotation;
  10112. /**
  10113. * @hidden
  10114. */
  10115. _disableTrackPosition(fixedPosition: Vector3): void;
  10116. /**
  10117. * Internal, the mesh attached to the controller
  10118. * @hidden
  10119. */
  10120. _mesh: Nullable<AbstractMesh>;
  10121. private _poseControlledCamera;
  10122. private _leftHandSystemQuaternion;
  10123. /**
  10124. * Internal, matrix used to convert room space to babylon space
  10125. * @hidden
  10126. */
  10127. _deviceToWorld: Matrix;
  10128. /**
  10129. * Node to be used when casting a ray from the controller
  10130. * @hidden
  10131. */
  10132. _pointingPoseNode: Nullable<TransformNode>;
  10133. /**
  10134. * Name of the child mesh that can be used to cast a ray from the controller
  10135. */
  10136. static readonly POINTING_POSE: string;
  10137. /**
  10138. * Creates a new PoseEnabledController from a gamepad
  10139. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  10140. */
  10141. constructor(browserGamepad: any);
  10142. private _workingMatrix;
  10143. /**
  10144. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  10145. */
  10146. update(): void;
  10147. /**
  10148. * Updates only the pose device and mesh without doing any button event checking
  10149. */
  10150. protected _updatePoseAndMesh(): void;
  10151. /**
  10152. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  10153. * @param poseData raw pose fromthe device
  10154. */
  10155. updateFromDevice(poseData: DevicePose): void;
  10156. /**
  10157. * @hidden
  10158. */
  10159. _meshAttachedObservable: Observable<AbstractMesh>;
  10160. /**
  10161. * Attaches a mesh to the controller
  10162. * @param mesh the mesh to be attached
  10163. */
  10164. attachToMesh(mesh: AbstractMesh): void;
  10165. /**
  10166. * Attaches the controllers mesh to a camera
  10167. * @param camera the camera the mesh should be attached to
  10168. */
  10169. attachToPoseControlledCamera(camera: TargetCamera): void;
  10170. /**
  10171. * Disposes of the controller
  10172. */
  10173. dispose(): void;
  10174. /**
  10175. * The mesh that is attached to the controller
  10176. */
  10177. readonly mesh: Nullable<AbstractMesh>;
  10178. /**
  10179. * Gets the ray of the controller in the direction the controller is pointing
  10180. * @param length the length the resulting ray should be
  10181. * @returns a ray in the direction the controller is pointing
  10182. */
  10183. getForwardRay(length?: number): Ray;
  10184. }
  10185. }
  10186. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  10187. import { Observable } from "babylonjs/Misc/observable";
  10188. import { Scene } from "babylonjs/scene";
  10189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10190. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  10191. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  10192. /**
  10193. * Defines the WebVRController object that represents controllers tracked in 3D space
  10194. */
  10195. export abstract class WebVRController extends PoseEnabledController {
  10196. /**
  10197. * Internal, the default controller model for the controller
  10198. */
  10199. protected _defaultModel: AbstractMesh;
  10200. /**
  10201. * Fired when the trigger state has changed
  10202. */
  10203. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  10204. /**
  10205. * Fired when the main button state has changed
  10206. */
  10207. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10208. /**
  10209. * Fired when the secondary button state has changed
  10210. */
  10211. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  10212. /**
  10213. * Fired when the pad state has changed
  10214. */
  10215. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  10216. /**
  10217. * Fired when controllers stick values have changed
  10218. */
  10219. onPadValuesChangedObservable: Observable<StickValues>;
  10220. /**
  10221. * Array of button availible on the controller
  10222. */
  10223. protected _buttons: Array<MutableGamepadButton>;
  10224. private _onButtonStateChange;
  10225. /**
  10226. * Fired when a controller button's state has changed
  10227. * @param callback the callback containing the button that was modified
  10228. */
  10229. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  10230. /**
  10231. * X and Y axis corrisponding to the controllers joystick
  10232. */
  10233. pad: StickValues;
  10234. /**
  10235. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  10236. */
  10237. hand: string;
  10238. /**
  10239. * The default controller model for the controller
  10240. */
  10241. readonly defaultModel: AbstractMesh;
  10242. /**
  10243. * Creates a new WebVRController from a gamepad
  10244. * @param vrGamepad the gamepad that the WebVRController should be created from
  10245. */
  10246. constructor(vrGamepad: any);
  10247. /**
  10248. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  10249. */
  10250. update(): void;
  10251. /**
  10252. * Function to be called when a button is modified
  10253. */
  10254. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  10255. /**
  10256. * Loads a mesh and attaches it to the controller
  10257. * @param scene the scene the mesh should be added to
  10258. * @param meshLoaded callback for when the mesh has been loaded
  10259. */
  10260. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  10261. private _setButtonValue;
  10262. private _changes;
  10263. private _checkChanges;
  10264. /**
  10265. * Disposes of th webVRCOntroller
  10266. */
  10267. dispose(): void;
  10268. }
  10269. }
  10270. declare module "babylonjs/Lights/shadowLight" {
  10271. import { Camera } from "babylonjs/Cameras/camera";
  10272. import { Scene } from "babylonjs/scene";
  10273. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10275. import { Light } from "babylonjs/Lights/light";
  10276. /**
  10277. * Interface describing all the common properties and methods a shadow light needs to implement.
  10278. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10279. * as well as binding the different shadow properties to the effects.
  10280. */
  10281. export interface IShadowLight extends Light {
  10282. /**
  10283. * The light id in the scene (used in scene.findLighById for instance)
  10284. */
  10285. id: string;
  10286. /**
  10287. * The position the shdow will be casted from.
  10288. */
  10289. position: Vector3;
  10290. /**
  10291. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10292. */
  10293. direction: Vector3;
  10294. /**
  10295. * The transformed position. Position of the light in world space taking parenting in account.
  10296. */
  10297. transformedPosition: Vector3;
  10298. /**
  10299. * The transformed direction. Direction of the light in world space taking parenting in account.
  10300. */
  10301. transformedDirection: Vector3;
  10302. /**
  10303. * The friendly name of the light in the scene.
  10304. */
  10305. name: string;
  10306. /**
  10307. * Defines the shadow projection clipping minimum z value.
  10308. */
  10309. shadowMinZ: number;
  10310. /**
  10311. * Defines the shadow projection clipping maximum z value.
  10312. */
  10313. shadowMaxZ: number;
  10314. /**
  10315. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10316. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10317. */
  10318. computeTransformedInformation(): boolean;
  10319. /**
  10320. * Gets the scene the light belongs to.
  10321. * @returns The scene
  10322. */
  10323. getScene(): Scene;
  10324. /**
  10325. * Callback defining a custom Projection Matrix Builder.
  10326. * This can be used to override the default projection matrix computation.
  10327. */
  10328. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10329. /**
  10330. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10331. * @param matrix The materix to updated with the projection information
  10332. * @param viewMatrix The transform matrix of the light
  10333. * @param renderList The list of mesh to render in the map
  10334. * @returns The current light
  10335. */
  10336. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10337. /**
  10338. * Gets the current depth scale used in ESM.
  10339. * @returns The scale
  10340. */
  10341. getDepthScale(): number;
  10342. /**
  10343. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10344. * @returns true if a cube texture needs to be use
  10345. */
  10346. needCube(): boolean;
  10347. /**
  10348. * Detects if the projection matrix requires to be recomputed this frame.
  10349. * @returns true if it requires to be recomputed otherwise, false.
  10350. */
  10351. needProjectionMatrixCompute(): boolean;
  10352. /**
  10353. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10354. */
  10355. forceProjectionMatrixCompute(): void;
  10356. /**
  10357. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10360. */
  10361. getShadowDirection(faceIndex?: number): Vector3;
  10362. /**
  10363. * Gets the minZ used for shadow according to both the scene and the light.
  10364. * @param activeCamera The camera we are returning the min for
  10365. * @returns the depth min z
  10366. */
  10367. getDepthMinZ(activeCamera: Camera): number;
  10368. /**
  10369. * Gets the maxZ used for shadow according to both the scene and the light.
  10370. * @param activeCamera The camera we are returning the max for
  10371. * @returns the depth max z
  10372. */
  10373. getDepthMaxZ(activeCamera: Camera): number;
  10374. }
  10375. /**
  10376. * Base implementation IShadowLight
  10377. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10378. */
  10379. export abstract class ShadowLight extends Light implements IShadowLight {
  10380. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10381. protected _position: Vector3;
  10382. protected _setPosition(value: Vector3): void;
  10383. /**
  10384. * Sets the position the shadow will be casted from. Also use as the light position for both
  10385. * point and spot lights.
  10386. */
  10387. /**
  10388. * Sets the position the shadow will be casted from. Also use as the light position for both
  10389. * point and spot lights.
  10390. */
  10391. position: Vector3;
  10392. protected _direction: Vector3;
  10393. protected _setDirection(value: Vector3): void;
  10394. /**
  10395. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10396. * Also use as the light direction on spot and directional lights.
  10397. */
  10398. /**
  10399. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10400. * Also use as the light direction on spot and directional lights.
  10401. */
  10402. direction: Vector3;
  10403. private _shadowMinZ;
  10404. /**
  10405. * Gets the shadow projection clipping minimum z value.
  10406. */
  10407. /**
  10408. * Sets the shadow projection clipping minimum z value.
  10409. */
  10410. shadowMinZ: number;
  10411. private _shadowMaxZ;
  10412. /**
  10413. * Sets the shadow projection clipping maximum z value.
  10414. */
  10415. /**
  10416. * Gets the shadow projection clipping maximum z value.
  10417. */
  10418. shadowMaxZ: number;
  10419. /**
  10420. * Callback defining a custom Projection Matrix Builder.
  10421. * This can be used to override the default projection matrix computation.
  10422. */
  10423. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10424. /**
  10425. * The transformed position. Position of the light in world space taking parenting in account.
  10426. */
  10427. transformedPosition: Vector3;
  10428. /**
  10429. * The transformed direction. Direction of the light in world space taking parenting in account.
  10430. */
  10431. transformedDirection: Vector3;
  10432. private _needProjectionMatrixCompute;
  10433. /**
  10434. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10435. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10436. */
  10437. computeTransformedInformation(): boolean;
  10438. /**
  10439. * Return the depth scale used for the shadow map.
  10440. * @returns the depth scale.
  10441. */
  10442. getDepthScale(): number;
  10443. /**
  10444. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10445. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10446. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10447. */
  10448. getShadowDirection(faceIndex?: number): Vector3;
  10449. /**
  10450. * Returns the ShadowLight absolute position in the World.
  10451. * @returns the position vector in world space
  10452. */
  10453. getAbsolutePosition(): Vector3;
  10454. /**
  10455. * Sets the ShadowLight direction toward the passed target.
  10456. * @param target The point tot target in local space
  10457. * @returns the updated ShadowLight direction
  10458. */
  10459. setDirectionToTarget(target: Vector3): Vector3;
  10460. /**
  10461. * Returns the light rotation in euler definition.
  10462. * @returns the x y z rotation in local space.
  10463. */
  10464. getRotation(): Vector3;
  10465. /**
  10466. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10467. * @returns true if a cube texture needs to be use
  10468. */
  10469. needCube(): boolean;
  10470. /**
  10471. * Detects if the projection matrix requires to be recomputed this frame.
  10472. * @returns true if it requires to be recomputed otherwise, false.
  10473. */
  10474. needProjectionMatrixCompute(): boolean;
  10475. /**
  10476. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10477. */
  10478. forceProjectionMatrixCompute(): void;
  10479. /** @hidden */
  10480. _initCache(): void;
  10481. /** @hidden */
  10482. _isSynchronized(): boolean;
  10483. /**
  10484. * Computes the world matrix of the node
  10485. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10486. * @returns the world matrix
  10487. */
  10488. computeWorldMatrix(force?: boolean): Matrix;
  10489. /**
  10490. * Gets the minZ used for shadow according to both the scene and the light.
  10491. * @param activeCamera The camera we are returning the min for
  10492. * @returns the depth min z
  10493. */
  10494. getDepthMinZ(activeCamera: Camera): number;
  10495. /**
  10496. * Gets the maxZ used for shadow according to both the scene and the light.
  10497. * @param activeCamera The camera we are returning the max for
  10498. * @returns the depth max z
  10499. */
  10500. getDepthMaxZ(activeCamera: Camera): number;
  10501. /**
  10502. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10503. * @param matrix The materix to updated with the projection information
  10504. * @param viewMatrix The transform matrix of the light
  10505. * @param renderList The list of mesh to render in the map
  10506. * @returns The current light
  10507. */
  10508. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10509. }
  10510. }
  10511. declare module "babylonjs/Materials/materialHelper" {
  10512. import { Nullable } from "babylonjs/types";
  10513. import { Scene } from "babylonjs/scene";
  10514. import { Engine } from "babylonjs/Engines/engine";
  10515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10516. import { Light } from "babylonjs/Lights/light";
  10517. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10518. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  10519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10520. /**
  10521. * "Static Class" containing the most commonly used helper while dealing with material for
  10522. * rendering purpose.
  10523. *
  10524. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10525. *
  10526. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10527. */
  10528. export class MaterialHelper {
  10529. /**
  10530. * Bind the current view position to an effect.
  10531. * @param effect The effect to be bound
  10532. * @param scene The scene the eyes position is used from
  10533. */
  10534. static BindEyePosition(effect: Effect, scene: Scene): void;
  10535. /**
  10536. * Helps preparing the defines values about the UVs in used in the effect.
  10537. * UVs are shared as much as we can accross channels in the shaders.
  10538. * @param texture The texture we are preparing the UVs for
  10539. * @param defines The defines to update
  10540. * @param key The channel key "diffuse", "specular"... used in the shader
  10541. */
  10542. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10543. /**
  10544. * Binds a texture matrix value to its corrsponding uniform
  10545. * @param texture The texture to bind the matrix for
  10546. * @param uniformBuffer The uniform buffer receivin the data
  10547. * @param key The channel key "diffuse", "specular"... used in the shader
  10548. */
  10549. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10550. /**
  10551. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10552. * @param mesh defines the current mesh
  10553. * @param scene defines the current scene
  10554. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10555. * @param pointsCloud defines if point cloud rendering has to be turned on
  10556. * @param fogEnabled defines if fog has to be turned on
  10557. * @param alphaTest defines if alpha testing has to be turned on
  10558. * @param defines defines the current list of defines
  10559. */
  10560. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10561. /**
  10562. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10563. * @param scene defines the current scene
  10564. * @param engine defines the current engine
  10565. * @param defines specifies the list of active defines
  10566. * @param useInstances defines if instances have to be turned on
  10567. * @param useClipPlane defines if clip plane have to be turned on
  10568. */
  10569. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10570. /**
  10571. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10572. * @param mesh The mesh containing the geometry data we will draw
  10573. * @param defines The defines to update
  10574. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10575. * @param useBones Precise whether bones should be used or not (override mesh info)
  10576. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10577. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10578. * @returns false if defines are considered not dirty and have not been checked
  10579. */
  10580. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10581. /**
  10582. * Prepares the defines related to the light information passed in parameter
  10583. * @param scene The scene we are intending to draw
  10584. * @param mesh The mesh the effect is compiling for
  10585. * @param defines The defines to update
  10586. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10587. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10588. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10589. * @returns true if normals will be required for the rest of the effect
  10590. */
  10591. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10592. /**
  10593. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  10594. * that won t be acctive due to defines being turned off.
  10595. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  10596. * @param samplersList The samplers list
  10597. * @param defines The defines helping in the list generation
  10598. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  10599. */
  10600. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  10601. /**
  10602. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  10603. * @param defines The defines to update while falling back
  10604. * @param fallbacks The authorized effect fallbacks
  10605. * @param maxSimultaneousLights The maximum number of lights allowed
  10606. * @param rank the current rank of the Effect
  10607. * @returns The newly affected rank
  10608. */
  10609. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  10610. /**
  10611. * Prepares the list of attributes required for morph targets according to the effect defines.
  10612. * @param attribs The current list of supported attribs
  10613. * @param mesh The mesh to prepare the morph targets attributes for
  10614. * @param defines The current Defines of the effect
  10615. */
  10616. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  10617. /**
  10618. * Prepares the list of attributes required for bones according to the effect defines.
  10619. * @param attribs The current list of supported attribs
  10620. * @param mesh The mesh to prepare the bones attributes for
  10621. * @param defines The current Defines of the effect
  10622. * @param fallbacks The current efffect fallback strategy
  10623. */
  10624. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  10625. /**
  10626. * Prepares the list of attributes required for instances according to the effect defines.
  10627. * @param attribs The current list of supported attribs
  10628. * @param defines The current Defines of the effect
  10629. */
  10630. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  10631. /**
  10632. * Binds the light shadow information to the effect for the given mesh.
  10633. * @param light The light containing the generator
  10634. * @param scene The scene the lights belongs to
  10635. * @param mesh The mesh we are binding the information to render
  10636. * @param lightIndex The light index in the effect used to render the mesh
  10637. * @param effect The effect we are binding the data to
  10638. */
  10639. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  10640. /**
  10641. * Binds the light information to the effect.
  10642. * @param light The light containing the generator
  10643. * @param effect The effect we are binding the data to
  10644. * @param lightIndex The light index in the effect used to render
  10645. */
  10646. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  10647. /**
  10648. * Binds the lights information from the scene to the effect for the given mesh.
  10649. * @param scene The scene the lights belongs to
  10650. * @param mesh The mesh we are binding the information to render
  10651. * @param effect The effect we are binding the data to
  10652. * @param defines The generated defines for the effect
  10653. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  10654. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10655. */
  10656. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  10657. private static _tempFogColor;
  10658. /**
  10659. * Binds the fog information from the scene to the effect for the given mesh.
  10660. * @param scene The scene the lights belongs to
  10661. * @param mesh The mesh we are binding the information to render
  10662. * @param effect The effect we are binding the data to
  10663. * @param linearSpace Defines if the fog effect is applied in linear space
  10664. */
  10665. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  10666. /**
  10667. * Binds the bones information from the mesh to the effect.
  10668. * @param mesh The mesh we are binding the information to render
  10669. * @param effect The effect we are binding the data to
  10670. */
  10671. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  10672. /**
  10673. * Binds the morph targets information from the mesh to the effect.
  10674. * @param abstractMesh The mesh we are binding the information to render
  10675. * @param effect The effect we are binding the data to
  10676. */
  10677. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  10678. /**
  10679. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  10680. * @param defines The generated defines used in the effect
  10681. * @param effect The effect we are binding the data to
  10682. * @param scene The scene we are willing to render with logarithmic scale for
  10683. */
  10684. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  10685. /**
  10686. * Binds the clip plane information from the scene to the effect.
  10687. * @param scene The scene the clip plane information are extracted from
  10688. * @param effect The effect we are binding the data to
  10689. */
  10690. static BindClipPlane(effect: Effect, scene: Scene): void;
  10691. }
  10692. }
  10693. declare module "babylonjs/Shaders/shadowMap.fragment" {
  10694. /** @hidden */
  10695. export var shadowMapPixelShader: {
  10696. name: string;
  10697. shader: string;
  10698. };
  10699. }
  10700. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  10701. /** @hidden */
  10702. export var bonesDeclaration: {
  10703. name: string;
  10704. shader: string;
  10705. };
  10706. }
  10707. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  10708. /** @hidden */
  10709. export var morphTargetsVertexGlobalDeclaration: {
  10710. name: string;
  10711. shader: string;
  10712. };
  10713. }
  10714. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  10715. /** @hidden */
  10716. export var morphTargetsVertexDeclaration: {
  10717. name: string;
  10718. shader: string;
  10719. };
  10720. }
  10721. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  10722. /** @hidden */
  10723. export var instancesDeclaration: {
  10724. name: string;
  10725. shader: string;
  10726. };
  10727. }
  10728. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  10729. /** @hidden */
  10730. export var helperFunctions: {
  10731. name: string;
  10732. shader: string;
  10733. };
  10734. }
  10735. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  10736. /** @hidden */
  10737. export var morphTargetsVertex: {
  10738. name: string;
  10739. shader: string;
  10740. };
  10741. }
  10742. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  10743. /** @hidden */
  10744. export var instancesVertex: {
  10745. name: string;
  10746. shader: string;
  10747. };
  10748. }
  10749. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  10750. /** @hidden */
  10751. export var bonesVertex: {
  10752. name: string;
  10753. shader: string;
  10754. };
  10755. }
  10756. declare module "babylonjs/Shaders/shadowMap.vertex" {
  10757. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  10758. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  10759. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  10760. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  10761. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  10762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  10763. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  10764. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  10765. /** @hidden */
  10766. export var shadowMapVertexShader: {
  10767. name: string;
  10768. shader: string;
  10769. };
  10770. }
  10771. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10772. /** @hidden */
  10773. export var depthBoxBlurPixelShader: {
  10774. name: string;
  10775. shader: string;
  10776. };
  10777. }
  10778. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10779. import { Nullable } from "babylonjs/types";
  10780. import { Scene } from "babylonjs/scene";
  10781. import { Matrix } from "babylonjs/Maths/math";
  10782. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10784. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10785. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10786. import { Effect } from "babylonjs/Materials/effect";
  10787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10788. import "babylonjs/Shaders/shadowMap.fragment";
  10789. import "babylonjs/Shaders/shadowMap.vertex";
  10790. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10791. import { Observable } from "babylonjs/Misc/observable";
  10792. /**
  10793. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10794. */
  10795. export interface ICustomShaderOptions {
  10796. /**
  10797. * Gets or sets the custom shader name to use
  10798. */
  10799. shaderName: string;
  10800. /**
  10801. * The list of attribute names used in the shader
  10802. */
  10803. attributes?: string[];
  10804. /**
  10805. * The list of unifrom names used in the shader
  10806. */
  10807. uniforms?: string[];
  10808. /**
  10809. * The list of sampler names used in the shader
  10810. */
  10811. samplers?: string[];
  10812. /**
  10813. * The list of defines used in the shader
  10814. */
  10815. defines?: string[];
  10816. }
  10817. /**
  10818. * Interface to implement to create a shadow generator compatible with BJS.
  10819. */
  10820. export interface IShadowGenerator {
  10821. /**
  10822. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10823. * @returns The render target texture if present otherwise, null
  10824. */
  10825. getShadowMap(): Nullable<RenderTargetTexture>;
  10826. /**
  10827. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10828. * @returns The render target texture if the shadow map is present otherwise, null
  10829. */
  10830. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10831. /**
  10832. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10833. * @param subMesh The submesh we want to render in the shadow map
  10834. * @param useInstances Defines wether will draw in the map using instances
  10835. * @returns true if ready otherwise, false
  10836. */
  10837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10838. /**
  10839. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10840. * @param defines Defines of the material we want to update
  10841. * @param lightIndex Index of the light in the enabled light list of the material
  10842. */
  10843. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10844. /**
  10845. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10846. * defined in the generator but impacting the effect).
  10847. * It implies the unifroms available on the materials are the standard BJS ones.
  10848. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10849. * @param effect The effect we are binfing the information for
  10850. */
  10851. bindShadowLight(lightIndex: string, effect: Effect): void;
  10852. /**
  10853. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10854. * (eq to shadow prjection matrix * light transform matrix)
  10855. * @returns The transform matrix used to create the shadow map
  10856. */
  10857. getTransformMatrix(): Matrix;
  10858. /**
  10859. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10860. * Cube and 2D textures for instance.
  10861. */
  10862. recreateShadowMap(): void;
  10863. /**
  10864. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10865. * @param onCompiled Callback triggered at the and of the effects compilation
  10866. * @param options Sets of optional options forcing the compilation with different modes
  10867. */
  10868. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10869. useInstances: boolean;
  10870. }>): void;
  10871. /**
  10872. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10873. * @param options Sets of optional options forcing the compilation with different modes
  10874. * @returns A promise that resolves when the compilation completes
  10875. */
  10876. forceCompilationAsync(options?: Partial<{
  10877. useInstances: boolean;
  10878. }>): Promise<void>;
  10879. /**
  10880. * Serializes the shadow generator setup to a json object.
  10881. * @returns The serialized JSON object
  10882. */
  10883. serialize(): any;
  10884. /**
  10885. * Disposes the Shadow map and related Textures and effects.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * Default implementation IShadowGenerator.
  10891. * This is the main object responsible of generating shadows in the framework.
  10892. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10893. */
  10894. export class ShadowGenerator implements IShadowGenerator {
  10895. /**
  10896. * Shadow generator mode None: no filtering applied.
  10897. */
  10898. static readonly FILTER_NONE: number;
  10899. /**
  10900. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10901. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10902. */
  10903. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10904. /**
  10905. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10906. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10907. */
  10908. static readonly FILTER_POISSONSAMPLING: number;
  10909. /**
  10910. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10911. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10912. */
  10913. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10914. /**
  10915. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10916. * edge artifacts on steep falloff.
  10917. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10918. */
  10919. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10920. /**
  10921. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10922. * edge artifacts on steep falloff.
  10923. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10924. */
  10925. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10926. /**
  10927. * Shadow generator mode PCF: Percentage Closer Filtering
  10928. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10929. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10930. */
  10931. static readonly FILTER_PCF: number;
  10932. /**
  10933. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10934. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10935. * Contact Hardening
  10936. */
  10937. static readonly FILTER_PCSS: number;
  10938. /**
  10939. * Reserved for PCF and PCSS
  10940. * Highest Quality.
  10941. *
  10942. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10943. *
  10944. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10945. */
  10946. static readonly QUALITY_HIGH: number;
  10947. /**
  10948. * Reserved for PCF and PCSS
  10949. * Good tradeoff for quality/perf cross devices
  10950. *
  10951. * Execute PCF on a 3*3 kernel.
  10952. *
  10953. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10954. */
  10955. static readonly QUALITY_MEDIUM: number;
  10956. /**
  10957. * Reserved for PCF and PCSS
  10958. * The lowest quality but the fastest.
  10959. *
  10960. * Execute PCF on a 1*1 kernel.
  10961. *
  10962. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10963. */
  10964. static readonly QUALITY_LOW: number;
  10965. /** Gets or sets the custom shader name to use */
  10966. customShaderOptions: ICustomShaderOptions;
  10967. /**
  10968. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10969. */
  10970. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10971. private _bias;
  10972. /**
  10973. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10974. */
  10975. /**
  10976. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10977. */
  10978. bias: number;
  10979. private _normalBias;
  10980. /**
  10981. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10982. */
  10983. /**
  10984. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10985. */
  10986. normalBias: number;
  10987. private _blurBoxOffset;
  10988. /**
  10989. * Gets the blur box offset: offset applied during the blur pass.
  10990. * Only useful if useKernelBlur = false
  10991. */
  10992. /**
  10993. * Sets the blur box offset: offset applied during the blur pass.
  10994. * Only useful if useKernelBlur = false
  10995. */
  10996. blurBoxOffset: number;
  10997. private _blurScale;
  10998. /**
  10999. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11000. * 2 means half of the size.
  11001. */
  11002. /**
  11003. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11004. * 2 means half of the size.
  11005. */
  11006. blurScale: number;
  11007. private _blurKernel;
  11008. /**
  11009. * Gets the blur kernel: kernel size of the blur pass.
  11010. * Only useful if useKernelBlur = true
  11011. */
  11012. /**
  11013. * Sets the blur kernel: kernel size of the blur pass.
  11014. * Only useful if useKernelBlur = true
  11015. */
  11016. blurKernel: number;
  11017. private _useKernelBlur;
  11018. /**
  11019. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11020. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11021. */
  11022. /**
  11023. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11024. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11025. */
  11026. useKernelBlur: boolean;
  11027. private _depthScale;
  11028. /**
  11029. * Gets the depth scale used in ESM mode.
  11030. */
  11031. /**
  11032. * Sets the depth scale used in ESM mode.
  11033. * This can override the scale stored on the light.
  11034. */
  11035. depthScale: number;
  11036. private _filter;
  11037. /**
  11038. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11039. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11040. */
  11041. /**
  11042. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11043. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11044. */
  11045. filter: number;
  11046. /**
  11047. * Gets if the current filter is set to Poisson Sampling.
  11048. */
  11049. /**
  11050. * Sets the current filter to Poisson Sampling.
  11051. */
  11052. usePoissonSampling: boolean;
  11053. /**
  11054. * Gets if the current filter is set to ESM.
  11055. */
  11056. /**
  11057. * Sets the current filter is to ESM.
  11058. */
  11059. useExponentialShadowMap: boolean;
  11060. /**
  11061. * Gets if the current filter is set to filtered ESM.
  11062. */
  11063. /**
  11064. * Gets if the current filter is set to filtered ESM.
  11065. */
  11066. useBlurExponentialShadowMap: boolean;
  11067. /**
  11068. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11069. * exponential to prevent steep falloff artifacts).
  11070. */
  11071. /**
  11072. * Sets the current filter to "close ESM" (using the inverse of the
  11073. * exponential to prevent steep falloff artifacts).
  11074. */
  11075. useCloseExponentialShadowMap: boolean;
  11076. /**
  11077. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11078. * exponential to prevent steep falloff artifacts).
  11079. */
  11080. /**
  11081. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11082. * exponential to prevent steep falloff artifacts).
  11083. */
  11084. useBlurCloseExponentialShadowMap: boolean;
  11085. /**
  11086. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11087. */
  11088. /**
  11089. * Sets the current filter to "PCF" (percentage closer filtering).
  11090. */
  11091. usePercentageCloserFiltering: boolean;
  11092. private _filteringQuality;
  11093. /**
  11094. * Gets the PCF or PCSS Quality.
  11095. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11096. */
  11097. /**
  11098. * Sets the PCF or PCSS Quality.
  11099. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11100. */
  11101. filteringQuality: number;
  11102. /**
  11103. * Gets if the current filter is set to "PCSS" (contact hardening).
  11104. */
  11105. /**
  11106. * Sets the current filter to "PCSS" (contact hardening).
  11107. */
  11108. useContactHardeningShadow: boolean;
  11109. private _contactHardeningLightSizeUVRatio;
  11110. /**
  11111. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11112. * Using a ratio helps keeping shape stability independently of the map size.
  11113. *
  11114. * It does not account for the light projection as it was having too much
  11115. * instability during the light setup or during light position changes.
  11116. *
  11117. * Only valid if useContactHardeningShadow is true.
  11118. */
  11119. /**
  11120. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11121. * Using a ratio helps keeping shape stability independently of the map size.
  11122. *
  11123. * It does not account for the light projection as it was having too much
  11124. * instability during the light setup or during light position changes.
  11125. *
  11126. * Only valid if useContactHardeningShadow is true.
  11127. */
  11128. contactHardeningLightSizeUVRatio: number;
  11129. private _darkness;
  11130. /**
  11131. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11132. * 0 means strongest and 1 would means no shadow.
  11133. * @returns the darkness.
  11134. */
  11135. getDarkness(): number;
  11136. /**
  11137. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11138. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11139. * @returns the shadow generator allowing fluent coding.
  11140. */
  11141. setDarkness(darkness: number): ShadowGenerator;
  11142. private _transparencyShadow;
  11143. /**
  11144. * Sets the ability to have transparent shadow (boolean).
  11145. * @param transparent True if transparent else False
  11146. * @returns the shadow generator allowing fluent coding
  11147. */
  11148. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11149. private _shadowMap;
  11150. private _shadowMap2;
  11151. /**
  11152. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11153. * @returns The render target texture if present otherwise, null
  11154. */
  11155. getShadowMap(): Nullable<RenderTargetTexture>;
  11156. /**
  11157. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11158. * @returns The render target texture if the shadow map is present otherwise, null
  11159. */
  11160. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11161. /**
  11162. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11163. * @param mesh Mesh to add
  11164. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11165. * @returns the Shadow Generator itself
  11166. */
  11167. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11168. /**
  11169. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11170. * @param mesh Mesh to remove
  11171. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11172. * @returns the Shadow Generator itself
  11173. */
  11174. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11175. /**
  11176. * Controls the extent to which the shadows fade out at the edge of the frustum
  11177. * Used only by directionals and spots
  11178. */
  11179. frustumEdgeFalloff: number;
  11180. private _light;
  11181. /**
  11182. * Returns the associated light object.
  11183. * @returns the light generating the shadow
  11184. */
  11185. getLight(): IShadowLight;
  11186. /**
  11187. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11188. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11189. * It might on the other hand introduce peter panning.
  11190. */
  11191. forceBackFacesOnly: boolean;
  11192. private _scene;
  11193. private _lightDirection;
  11194. private _effect;
  11195. private _viewMatrix;
  11196. private _projectionMatrix;
  11197. private _transformMatrix;
  11198. private _cachedPosition;
  11199. private _cachedDirection;
  11200. private _cachedDefines;
  11201. private _currentRenderID;
  11202. private _boxBlurPostprocess;
  11203. private _kernelBlurXPostprocess;
  11204. private _kernelBlurYPostprocess;
  11205. private _blurPostProcesses;
  11206. private _mapSize;
  11207. private _currentFaceIndex;
  11208. private _currentFaceIndexCache;
  11209. private _textureType;
  11210. private _defaultTextureMatrix;
  11211. /** @hidden */
  11212. static _SceneComponentInitialization: (scene: Scene) => void;
  11213. /**
  11214. * Creates a ShadowGenerator object.
  11215. * A ShadowGenerator is the required tool to use the shadows.
  11216. * Each light casting shadows needs to use its own ShadowGenerator.
  11217. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11218. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11219. * @param light The light object generating the shadows.
  11220. * @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.
  11221. */
  11222. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11223. private _initializeGenerator;
  11224. private _initializeShadowMap;
  11225. private _initializeBlurRTTAndPostProcesses;
  11226. private _renderForShadowMap;
  11227. private _renderSubMeshForShadowMap;
  11228. private _applyFilterValues;
  11229. /**
  11230. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11231. * @param onCompiled Callback triggered at the and of the effects compilation
  11232. * @param options Sets of optional options forcing the compilation with different modes
  11233. */
  11234. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11235. useInstances: boolean;
  11236. }>): void;
  11237. /**
  11238. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11239. * @param options Sets of optional options forcing the compilation with different modes
  11240. * @returns A promise that resolves when the compilation completes
  11241. */
  11242. forceCompilationAsync(options?: Partial<{
  11243. useInstances: boolean;
  11244. }>): Promise<void>;
  11245. /**
  11246. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11247. * @param subMesh The submesh we want to render in the shadow map
  11248. * @param useInstances Defines wether will draw in the map using instances
  11249. * @returns true if ready otherwise, false
  11250. */
  11251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11252. /**
  11253. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11254. * @param defines Defines of the material we want to update
  11255. * @param lightIndex Index of the light in the enabled light list of the material
  11256. */
  11257. prepareDefines(defines: any, lightIndex: number): void;
  11258. /**
  11259. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11260. * defined in the generator but impacting the effect).
  11261. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11262. * @param effect The effect we are binfing the information for
  11263. */
  11264. bindShadowLight(lightIndex: string, effect: Effect): void;
  11265. /**
  11266. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11267. * (eq to shadow prjection matrix * light transform matrix)
  11268. * @returns The transform matrix used to create the shadow map
  11269. */
  11270. getTransformMatrix(): Matrix;
  11271. /**
  11272. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11273. * Cube and 2D textures for instance.
  11274. */
  11275. recreateShadowMap(): void;
  11276. private _disposeBlurPostProcesses;
  11277. private _disposeRTTandPostProcesses;
  11278. /**
  11279. * Disposes the ShadowGenerator.
  11280. * Returns nothing.
  11281. */
  11282. dispose(): void;
  11283. /**
  11284. * Serializes the shadow generator setup to a json object.
  11285. * @returns The serialized JSON object
  11286. */
  11287. serialize(): any;
  11288. /**
  11289. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11290. * @param parsedShadowGenerator The JSON object to parse
  11291. * @param scene The scene to create the shadow map for
  11292. * @returns The parsed shadow generator
  11293. */
  11294. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11295. }
  11296. }
  11297. declare module "babylonjs/Lights/light" {
  11298. import { Nullable } from "babylonjs/types";
  11299. import { Scene } from "babylonjs/scene";
  11300. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11301. import { Node } from "babylonjs/node";
  11302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11303. import { Effect } from "babylonjs/Materials/effect";
  11304. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11305. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11306. /**
  11307. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11308. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11309. * 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.
  11310. */
  11311. export abstract class Light extends Node {
  11312. /**
  11313. * Falloff Default: light is falling off following the material specification:
  11314. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11315. */
  11316. static readonly FALLOFF_DEFAULT: number;
  11317. /**
  11318. * Falloff Physical: light is falling off following the inverse squared distance law.
  11319. */
  11320. static readonly FALLOFF_PHYSICAL: number;
  11321. /**
  11322. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11323. * to enhance interoperability with other engines.
  11324. */
  11325. static readonly FALLOFF_GLTF: number;
  11326. /**
  11327. * Falloff Standard: light is falling off like in the standard material
  11328. * to enhance interoperability with other materials.
  11329. */
  11330. static readonly FALLOFF_STANDARD: number;
  11331. /**
  11332. * If every light affecting the material is in this lightmapMode,
  11333. * material.lightmapTexture adds or multiplies
  11334. * (depends on material.useLightmapAsShadowmap)
  11335. * after every other light calculations.
  11336. */
  11337. static readonly LIGHTMAP_DEFAULT: number;
  11338. /**
  11339. * material.lightmapTexture as only diffuse lighting from this light
  11340. * adds only specular lighting from this light
  11341. * adds dynamic shadows
  11342. */
  11343. static readonly LIGHTMAP_SPECULAR: number;
  11344. /**
  11345. * material.lightmapTexture as only lighting
  11346. * no light calculation from this light
  11347. * only adds dynamic shadows from this light
  11348. */
  11349. static readonly LIGHTMAP_SHADOWSONLY: number;
  11350. /**
  11351. * Each light type uses the default quantity according to its type:
  11352. * point/spot lights use luminous intensity
  11353. * directional lights use illuminance
  11354. */
  11355. static readonly INTENSITYMODE_AUTOMATIC: number;
  11356. /**
  11357. * lumen (lm)
  11358. */
  11359. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11360. /**
  11361. * candela (lm/sr)
  11362. */
  11363. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11364. /**
  11365. * lux (lm/m^2)
  11366. */
  11367. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11368. /**
  11369. * nit (cd/m^2)
  11370. */
  11371. static readonly INTENSITYMODE_LUMINANCE: number;
  11372. /**
  11373. * Light type const id of the point light.
  11374. */
  11375. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11376. /**
  11377. * Light type const id of the directional light.
  11378. */
  11379. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11380. /**
  11381. * Light type const id of the spot light.
  11382. */
  11383. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11384. /**
  11385. * Light type const id of the hemispheric light.
  11386. */
  11387. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11388. /**
  11389. * Diffuse gives the basic color to an object.
  11390. */
  11391. diffuse: Color3;
  11392. /**
  11393. * Specular produces a highlight color on an object.
  11394. * Note: This is note affecting PBR materials.
  11395. */
  11396. specular: Color3;
  11397. /**
  11398. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11399. * falling off base on range or angle.
  11400. * This can be set to any values in Light.FALLOFF_x.
  11401. *
  11402. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11403. * other types of materials.
  11404. */
  11405. falloffType: number;
  11406. /**
  11407. * Strength of the light.
  11408. * Note: By default it is define in the framework own unit.
  11409. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11410. */
  11411. intensity: number;
  11412. private _range;
  11413. protected _inverseSquaredRange: number;
  11414. /**
  11415. * Defines how far from the source the light is impacting in scene units.
  11416. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11417. */
  11418. /**
  11419. * Defines how far from the source the light is impacting in scene units.
  11420. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11421. */
  11422. range: number;
  11423. /**
  11424. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11425. * of light.
  11426. */
  11427. private _photometricScale;
  11428. private _intensityMode;
  11429. /**
  11430. * Gets the photometric scale used to interpret the intensity.
  11431. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11432. */
  11433. /**
  11434. * Sets the photometric scale used to interpret the intensity.
  11435. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11436. */
  11437. intensityMode: number;
  11438. private _radius;
  11439. /**
  11440. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11441. */
  11442. /**
  11443. * sets the light radius used by PBR Materials to simulate soft area lights.
  11444. */
  11445. radius: number;
  11446. private _renderPriority;
  11447. /**
  11448. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11449. * exceeding the number allowed of the materials.
  11450. */
  11451. renderPriority: number;
  11452. private _shadowEnabled;
  11453. /**
  11454. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11455. * the current shadow generator.
  11456. */
  11457. /**
  11458. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11459. * the current shadow generator.
  11460. */
  11461. shadowEnabled: boolean;
  11462. private _includedOnlyMeshes;
  11463. /**
  11464. * Gets the only meshes impacted by this light.
  11465. */
  11466. /**
  11467. * Sets the only meshes impacted by this light.
  11468. */
  11469. includedOnlyMeshes: AbstractMesh[];
  11470. private _excludedMeshes;
  11471. /**
  11472. * Gets the meshes not impacted by this light.
  11473. */
  11474. /**
  11475. * Sets the meshes not impacted by this light.
  11476. */
  11477. excludedMeshes: AbstractMesh[];
  11478. private _excludeWithLayerMask;
  11479. /**
  11480. * Gets the layer id use to find what meshes are not impacted by the light.
  11481. * Inactive if 0
  11482. */
  11483. /**
  11484. * Sets the layer id use to find what meshes are not impacted by the light.
  11485. * Inactive if 0
  11486. */
  11487. excludeWithLayerMask: number;
  11488. private _includeOnlyWithLayerMask;
  11489. /**
  11490. * Gets the layer id use to find what meshes are impacted by the light.
  11491. * Inactive if 0
  11492. */
  11493. /**
  11494. * Sets the layer id use to find what meshes are impacted by the light.
  11495. * Inactive if 0
  11496. */
  11497. includeOnlyWithLayerMask: number;
  11498. private _lightmapMode;
  11499. /**
  11500. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11501. */
  11502. /**
  11503. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11504. */
  11505. lightmapMode: number;
  11506. /**
  11507. * Shadow generator associted to the light.
  11508. * @hidden Internal use only.
  11509. */
  11510. _shadowGenerator: Nullable<IShadowGenerator>;
  11511. /**
  11512. * @hidden Internal use only.
  11513. */
  11514. _excludedMeshesIds: string[];
  11515. /**
  11516. * @hidden Internal use only.
  11517. */
  11518. _includedOnlyMeshesIds: string[];
  11519. /**
  11520. * The current light unifom buffer.
  11521. * @hidden Internal use only.
  11522. */
  11523. _uniformBuffer: UniformBuffer;
  11524. /**
  11525. * Creates a Light object in the scene.
  11526. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11527. * @param name The firendly name of the light
  11528. * @param scene The scene the light belongs too
  11529. */
  11530. constructor(name: string, scene: Scene);
  11531. protected abstract _buildUniformLayout(): void;
  11532. /**
  11533. * Sets the passed Effect "effect" with the Light information.
  11534. * @param effect The effect to update
  11535. * @param lightIndex The index of the light in the effect to update
  11536. * @returns The light
  11537. */
  11538. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11539. /**
  11540. * Returns the string "Light".
  11541. * @returns the class name
  11542. */
  11543. getClassName(): string;
  11544. /** @hidden */
  11545. readonly _isLight: boolean;
  11546. /**
  11547. * Converts the light information to a readable string for debug purpose.
  11548. * @param fullDetails Supports for multiple levels of logging within scene loading
  11549. * @returns the human readable light info
  11550. */
  11551. toString(fullDetails?: boolean): string;
  11552. /** @hidden */
  11553. protected _syncParentEnabledState(): void;
  11554. /**
  11555. * Set the enabled state of this node.
  11556. * @param value - the new enabled state
  11557. */
  11558. setEnabled(value: boolean): void;
  11559. /**
  11560. * Returns the Light associated shadow generator if any.
  11561. * @return the associated shadow generator.
  11562. */
  11563. getShadowGenerator(): Nullable<IShadowGenerator>;
  11564. /**
  11565. * Returns a Vector3, the absolute light position in the World.
  11566. * @returns the world space position of the light
  11567. */
  11568. getAbsolutePosition(): Vector3;
  11569. /**
  11570. * Specifies if the light will affect the passed mesh.
  11571. * @param mesh The mesh to test against the light
  11572. * @return true the mesh is affected otherwise, false.
  11573. */
  11574. canAffectMesh(mesh: AbstractMesh): boolean;
  11575. /**
  11576. * Sort function to order lights for rendering.
  11577. * @param a First Light object to compare to second.
  11578. * @param b Second Light object to compare first.
  11579. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  11580. */
  11581. static CompareLightsPriority(a: Light, b: Light): number;
  11582. /**
  11583. * Releases resources associated with this node.
  11584. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  11585. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  11586. */
  11587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11588. /**
  11589. * Returns the light type ID (integer).
  11590. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11591. */
  11592. getTypeID(): number;
  11593. /**
  11594. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  11595. * @returns the scaled intensity in intensity mode unit
  11596. */
  11597. getScaledIntensity(): number;
  11598. /**
  11599. * Returns a new Light object, named "name", from the current one.
  11600. * @param name The name of the cloned light
  11601. * @returns the new created light
  11602. */
  11603. clone(name: string): Nullable<Light>;
  11604. /**
  11605. * Serializes the current light into a Serialization object.
  11606. * @returns the serialized object.
  11607. */
  11608. serialize(): any;
  11609. /**
  11610. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  11611. * This new light is named "name" and added to the passed scene.
  11612. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  11613. * @param name The friendly name of the light
  11614. * @param scene The scene the new light will belong to
  11615. * @returns the constructor function
  11616. */
  11617. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  11618. /**
  11619. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  11620. * @param parsedLight The JSON representation of the light
  11621. * @param scene The scene to create the parsed light in
  11622. * @returns the created light after parsing
  11623. */
  11624. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  11625. private _hookArrayForExcluded;
  11626. private _hookArrayForIncludedOnly;
  11627. private _resyncMeshes;
  11628. /**
  11629. * Forces the meshes to update their light related information in their rendering used effects
  11630. * @hidden Internal Use Only
  11631. */
  11632. _markMeshesAsLightDirty(): void;
  11633. /**
  11634. * Recomputes the cached photometric scale if needed.
  11635. */
  11636. private _computePhotometricScale;
  11637. /**
  11638. * Returns the Photometric Scale according to the light type and intensity mode.
  11639. */
  11640. private _getPhotometricScale;
  11641. /**
  11642. * Reorder the light in the scene according to their defined priority.
  11643. * @hidden Internal Use Only
  11644. */
  11645. _reorderLightsInScene(): void;
  11646. /**
  11647. * Prepares the list of defines specific to the light type.
  11648. * @param defines the list of defines
  11649. * @param lightIndex defines the index of the light for the effect
  11650. */
  11651. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11652. }
  11653. }
  11654. declare module "babylonjs/Lights/hemisphericLight" {
  11655. import { Nullable } from "babylonjs/types";
  11656. import { Scene } from "babylonjs/scene";
  11657. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  11658. import { Effect } from "babylonjs/Materials/effect";
  11659. import { Light } from "babylonjs/Lights/light";
  11660. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11661. /**
  11662. * The HemisphericLight simulates the ambient environment light,
  11663. * so the passed direction is the light reflection direction, not the incoming direction.
  11664. */
  11665. export class HemisphericLight extends Light {
  11666. /**
  11667. * The groundColor is the light in the opposite direction to the one specified during creation.
  11668. * 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.
  11669. */
  11670. groundColor: Color3;
  11671. /**
  11672. * The light reflection direction, not the incoming direction.
  11673. */
  11674. direction: Vector3;
  11675. /**
  11676. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  11677. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  11678. * The HemisphericLight can't cast shadows.
  11679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11680. * @param name The friendly name of the light
  11681. * @param direction The direction of the light reflection
  11682. * @param scene The scene the light belongs to
  11683. */
  11684. constructor(name: string, direction: Vector3, scene: Scene);
  11685. protected _buildUniformLayout(): void;
  11686. /**
  11687. * Returns the string "HemisphericLight".
  11688. * @return The class name
  11689. */
  11690. getClassName(): string;
  11691. /**
  11692. * Sets the HemisphericLight direction towards the passed target (Vector3).
  11693. * Returns the updated direction.
  11694. * @param target The target the direction should point to
  11695. * @return The computed direction
  11696. */
  11697. setDirectionToTarget(target: Vector3): Vector3;
  11698. /**
  11699. * Returns the shadow generator associated to the light.
  11700. * @returns Always null for hemispheric lights because it does not support shadows.
  11701. */
  11702. getShadowGenerator(): Nullable<IShadowGenerator>;
  11703. /**
  11704. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  11705. * @param effect The effect to update
  11706. * @param lightIndex The index of the light in the effect to update
  11707. * @returns The hemispheric light
  11708. */
  11709. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  11710. /**
  11711. * Computes the world matrix of the node
  11712. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11713. * @param useWasUpdatedFlag defines a reserved property
  11714. * @returns the world matrix
  11715. */
  11716. computeWorldMatrix(): Matrix;
  11717. /**
  11718. * Returns the integer 3.
  11719. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  11720. */
  11721. getTypeID(): number;
  11722. /**
  11723. * Prepares the list of defines specific to the light type.
  11724. * @param defines the list of defines
  11725. * @param lightIndex defines the index of the light for the effect
  11726. */
  11727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  11728. }
  11729. }
  11730. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  11731. declare module "babylonjs/Cameras/VR/webVRCamera" {
  11732. import { Nullable } from "babylonjs/types";
  11733. import { Observable } from "babylonjs/Misc/observable";
  11734. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11735. import { Scene } from "babylonjs/scene";
  11736. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  11737. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  11738. import { Node } from "babylonjs/node";
  11739. import { Ray } from "babylonjs/Culling/ray";
  11740. import "babylonjs/Cameras/RigModes/webVRRigMode";
  11741. /**
  11742. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  11743. * IMPORTANT!! The data is right-hand data.
  11744. * @export
  11745. * @interface DevicePose
  11746. */
  11747. export interface DevicePose {
  11748. /**
  11749. * The position of the device, values in array are [x,y,z].
  11750. */
  11751. readonly position: Nullable<Float32Array>;
  11752. /**
  11753. * The linearVelocity of the device, values in array are [x,y,z].
  11754. */
  11755. readonly linearVelocity: Nullable<Float32Array>;
  11756. /**
  11757. * The linearAcceleration of the device, values in array are [x,y,z].
  11758. */
  11759. readonly linearAcceleration: Nullable<Float32Array>;
  11760. /**
  11761. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  11762. */
  11763. readonly orientation: Nullable<Float32Array>;
  11764. /**
  11765. * The angularVelocity of the device, values in array are [x,y,z].
  11766. */
  11767. readonly angularVelocity: Nullable<Float32Array>;
  11768. /**
  11769. * The angularAcceleration of the device, values in array are [x,y,z].
  11770. */
  11771. readonly angularAcceleration: Nullable<Float32Array>;
  11772. }
  11773. /**
  11774. * Interface representing a pose controlled object in Babylon.
  11775. * A pose controlled object has both regular pose values as well as pose values
  11776. * from an external device such as a VR head mounted display
  11777. */
  11778. export interface PoseControlled {
  11779. /**
  11780. * The position of the object in babylon space.
  11781. */
  11782. position: Vector3;
  11783. /**
  11784. * The rotation quaternion of the object in babylon space.
  11785. */
  11786. rotationQuaternion: Quaternion;
  11787. /**
  11788. * The position of the device in babylon space.
  11789. */
  11790. devicePosition?: Vector3;
  11791. /**
  11792. * The rotation quaternion of the device in babylon space.
  11793. */
  11794. deviceRotationQuaternion: Quaternion;
  11795. /**
  11796. * The raw pose coming from the device.
  11797. */
  11798. rawPose: Nullable<DevicePose>;
  11799. /**
  11800. * The scale of the device to be used when translating from device space to babylon space.
  11801. */
  11802. deviceScaleFactor: number;
  11803. /**
  11804. * Updates the poseControlled values based on the input device pose.
  11805. * @param poseData the pose data to update the object with
  11806. */
  11807. updateFromDevice(poseData: DevicePose): void;
  11808. }
  11809. /**
  11810. * Set of options to customize the webVRCamera
  11811. */
  11812. export interface WebVROptions {
  11813. /**
  11814. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11815. */
  11816. trackPosition?: boolean;
  11817. /**
  11818. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11819. */
  11820. positionScale?: number;
  11821. /**
  11822. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11823. */
  11824. displayName?: string;
  11825. /**
  11826. * Should the native controller meshes be initialized. (default: true)
  11827. */
  11828. controllerMeshes?: boolean;
  11829. /**
  11830. * Creating a default HemiLight only on controllers. (default: true)
  11831. */
  11832. defaultLightingOnControllers?: boolean;
  11833. /**
  11834. * If you don't want to use the default VR button of the helper. (default: false)
  11835. */
  11836. useCustomVRButton?: boolean;
  11837. /**
  11838. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11839. */
  11840. customVRButton?: HTMLButtonElement;
  11841. /**
  11842. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11843. */
  11844. rayLength?: number;
  11845. /**
  11846. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11847. */
  11848. defaultHeight?: number;
  11849. }
  11850. /**
  11851. * This represents a WebVR camera.
  11852. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11853. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11854. */
  11855. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11856. private webVROptions;
  11857. /**
  11858. * @hidden
  11859. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11860. */
  11861. _vrDevice: any;
  11862. /**
  11863. * The rawPose of the vrDevice.
  11864. */
  11865. rawPose: Nullable<DevicePose>;
  11866. private _onVREnabled;
  11867. private _specsVersion;
  11868. private _attached;
  11869. private _frameData;
  11870. protected _descendants: Array<Node>;
  11871. private _deviceRoomPosition;
  11872. /** @hidden */
  11873. _deviceRoomRotationQuaternion: Quaternion;
  11874. private _standingMatrix;
  11875. /**
  11876. * Represents device position in babylon space.
  11877. */
  11878. devicePosition: Vector3;
  11879. /**
  11880. * Represents device rotation in babylon space.
  11881. */
  11882. deviceRotationQuaternion: Quaternion;
  11883. /**
  11884. * The scale of the device to be used when translating from device space to babylon space.
  11885. */
  11886. deviceScaleFactor: number;
  11887. private _deviceToWorld;
  11888. private _worldToDevice;
  11889. /**
  11890. * References to the webVR controllers for the vrDevice.
  11891. */
  11892. controllers: Array<WebVRController>;
  11893. /**
  11894. * Emits an event when a controller is attached.
  11895. */
  11896. onControllersAttachedObservable: Observable<WebVRController[]>;
  11897. /**
  11898. * Emits an event when a controller's mesh has been loaded;
  11899. */
  11900. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11901. /**
  11902. * Emits an event when the HMD's pose has been updated.
  11903. */
  11904. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11905. private _poseSet;
  11906. /**
  11907. * If the rig cameras be used as parent instead of this camera.
  11908. */
  11909. rigParenting: boolean;
  11910. private _lightOnControllers;
  11911. private _defaultHeight?;
  11912. /**
  11913. * Instantiates a WebVRFreeCamera.
  11914. * @param name The name of the WebVRFreeCamera
  11915. * @param position The starting anchor position for the camera
  11916. * @param scene The scene the camera belongs to
  11917. * @param webVROptions a set of customizable options for the webVRCamera
  11918. */
  11919. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11920. /**
  11921. * Gets the device distance from the ground in meters.
  11922. * @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.
  11923. */
  11924. deviceDistanceToRoomGround(): number;
  11925. /**
  11926. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11927. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11928. */
  11929. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11930. /**
  11931. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11932. * @returns A promise with a boolean set to if the standing matrix is supported.
  11933. */
  11934. useStandingMatrixAsync(): Promise<boolean>;
  11935. /**
  11936. * Disposes the camera
  11937. */
  11938. dispose(): void;
  11939. /**
  11940. * Gets a vrController by name.
  11941. * @param name The name of the controller to retreive
  11942. * @returns the controller matching the name specified or null if not found
  11943. */
  11944. getControllerByName(name: string): Nullable<WebVRController>;
  11945. private _leftController;
  11946. /**
  11947. * The controller corrisponding to the users left hand.
  11948. */
  11949. readonly leftController: Nullable<WebVRController>;
  11950. private _rightController;
  11951. /**
  11952. * The controller corrisponding to the users right hand.
  11953. */
  11954. readonly rightController: Nullable<WebVRController>;
  11955. /**
  11956. * Casts a ray forward from the vrCamera's gaze.
  11957. * @param length Length of the ray (default: 100)
  11958. * @returns the ray corrisponding to the gaze
  11959. */
  11960. getForwardRay(length?: number): Ray;
  11961. /**
  11962. * @hidden
  11963. * Updates the camera based on device's frame data
  11964. */
  11965. _checkInputs(): void;
  11966. /**
  11967. * Updates the poseControlled values based on the input device pose.
  11968. * @param poseData Pose coming from the device
  11969. */
  11970. updateFromDevice(poseData: DevicePose): void;
  11971. private _htmlElementAttached;
  11972. private _detachIfAttached;
  11973. /**
  11974. * WebVR's attach control will start broadcasting frames to the device.
  11975. * Note that in certain browsers (chrome for example) this function must be called
  11976. * within a user-interaction callback. Example:
  11977. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11978. *
  11979. * @param element html element to attach the vrDevice to
  11980. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11981. */
  11982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11983. /**
  11984. * Detaches the camera from the html element and disables VR
  11985. *
  11986. * @param element html element to detach from
  11987. */
  11988. detachControl(element: HTMLElement): void;
  11989. /**
  11990. * @returns the name of this class
  11991. */
  11992. getClassName(): string;
  11993. /**
  11994. * Calls resetPose on the vrDisplay
  11995. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11996. */
  11997. resetToCurrentRotation(): void;
  11998. /**
  11999. * @hidden
  12000. * Updates the rig cameras (left and right eye)
  12001. */
  12002. _updateRigCameras(): void;
  12003. private _workingVector;
  12004. private _oneVector;
  12005. private _workingMatrix;
  12006. private updateCacheCalled;
  12007. private _correctPositionIfNotTrackPosition;
  12008. /**
  12009. * @hidden
  12010. * Updates the cached values of the camera
  12011. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  12012. */
  12013. _updateCache(ignoreParentClass?: boolean): void;
  12014. /**
  12015. * @hidden
  12016. * Get current device position in babylon world
  12017. */
  12018. _computeDevicePosition(): void;
  12019. /**
  12020. * Updates the current device position and rotation in the babylon world
  12021. */
  12022. update(): void;
  12023. /**
  12024. * @hidden
  12025. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  12026. * @returns an identity matrix
  12027. */
  12028. _getViewMatrix(): Matrix;
  12029. private _tmpMatrix;
  12030. /**
  12031. * This function is called by the two RIG cameras.
  12032. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  12033. * @hidden
  12034. */
  12035. _getWebVRViewMatrix(): Matrix;
  12036. /** @hidden */
  12037. _getWebVRProjectionMatrix(): Matrix;
  12038. private _onGamepadConnectedObserver;
  12039. private _onGamepadDisconnectedObserver;
  12040. private _updateCacheWhenTrackingDisabledObserver;
  12041. /**
  12042. * Initializes the controllers and their meshes
  12043. */
  12044. initControllers(): void;
  12045. }
  12046. }
  12047. declare module "babylonjs/PostProcesses/postProcess" {
  12048. import { Nullable } from "babylonjs/types";
  12049. import { SmartArray } from "babylonjs/Misc/smartArray";
  12050. import { Observable } from "babylonjs/Misc/observable";
  12051. import { Color4, Vector2 } from "babylonjs/Maths/math";
  12052. import { Camera } from "babylonjs/Cameras/camera";
  12053. import { Effect } from "babylonjs/Materials/effect";
  12054. import { Animation } from "babylonjs/Animations/animation";
  12055. import "babylonjs/Shaders/postprocess.vertex";
  12056. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12057. import { Engine } from "babylonjs/Engines/engine";
  12058. /**
  12059. * Size options for a post process
  12060. */
  12061. export type PostProcessOptions = {
  12062. width: number;
  12063. height: number;
  12064. };
  12065. /**
  12066. * PostProcess can be used to apply a shader to a texture after it has been rendered
  12067. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12068. */
  12069. export class PostProcess {
  12070. /** Name of the PostProcess. */
  12071. name: string;
  12072. /**
  12073. * Width of the texture to apply the post process on
  12074. */
  12075. width: number;
  12076. /**
  12077. * Height of the texture to apply the post process on
  12078. */
  12079. height: number;
  12080. /**
  12081. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  12082. * @hidden
  12083. */
  12084. _outputTexture: Nullable<InternalTexture>;
  12085. /**
  12086. * Sampling mode used by the shader
  12087. * See https://doc.babylonjs.com/classes/3.1/texture
  12088. */
  12089. renderTargetSamplingMode: number;
  12090. /**
  12091. * Clear color to use when screen clearing
  12092. */
  12093. clearColor: Color4;
  12094. /**
  12095. * If the buffer needs to be cleared before applying the post process. (default: true)
  12096. * Should be set to false if shader will overwrite all previous pixels.
  12097. */
  12098. autoClear: boolean;
  12099. /**
  12100. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  12101. */
  12102. alphaMode: number;
  12103. /**
  12104. * Sets the setAlphaBlendConstants of the babylon engine
  12105. */
  12106. alphaConstants: Color4;
  12107. /**
  12108. * Animations to be used for the post processing
  12109. */
  12110. animations: Animation[];
  12111. /**
  12112. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  12113. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  12114. */
  12115. enablePixelPerfectMode: boolean;
  12116. /**
  12117. * Force the postprocess to be applied without taking in account viewport
  12118. */
  12119. forceFullscreenViewport: boolean;
  12120. /**
  12121. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  12122. *
  12123. * | Value | Type | Description |
  12124. * | ----- | ----------------------------------- | ----------- |
  12125. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  12126. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  12127. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  12128. *
  12129. */
  12130. scaleMode: number;
  12131. /**
  12132. * Force textures to be a power of two (default: false)
  12133. */
  12134. alwaysForcePOT: boolean;
  12135. private _samples;
  12136. /**
  12137. * Number of sample textures (default: 1)
  12138. */
  12139. samples: number;
  12140. /**
  12141. * Modify the scale of the post process to be the same as the viewport (default: false)
  12142. */
  12143. adaptScaleToCurrentViewport: boolean;
  12144. private _camera;
  12145. private _scene;
  12146. private _engine;
  12147. private _options;
  12148. private _reusable;
  12149. private _textureType;
  12150. /**
  12151. * Smart array of input and output textures for the post process.
  12152. * @hidden
  12153. */
  12154. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  12155. /**
  12156. * The index in _textures that corresponds to the output texture.
  12157. * @hidden
  12158. */
  12159. _currentRenderTextureInd: number;
  12160. private _effect;
  12161. private _samplers;
  12162. private _fragmentUrl;
  12163. private _vertexUrl;
  12164. private _parameters;
  12165. private _scaleRatio;
  12166. protected _indexParameters: any;
  12167. private _shareOutputWithPostProcess;
  12168. private _texelSize;
  12169. private _forcedOutputTexture;
  12170. /**
  12171. * Returns the fragment url or shader name used in the post process.
  12172. * @returns the fragment url or name in the shader store.
  12173. */
  12174. getEffectName(): string;
  12175. /**
  12176. * An event triggered when the postprocess is activated.
  12177. */
  12178. onActivateObservable: Observable<Camera>;
  12179. private _onActivateObserver;
  12180. /**
  12181. * A function that is added to the onActivateObservable
  12182. */
  12183. onActivate: Nullable<(camera: Camera) => void>;
  12184. /**
  12185. * An event triggered when the postprocess changes its size.
  12186. */
  12187. onSizeChangedObservable: Observable<PostProcess>;
  12188. private _onSizeChangedObserver;
  12189. /**
  12190. * A function that is added to the onSizeChangedObservable
  12191. */
  12192. onSizeChanged: (postProcess: PostProcess) => void;
  12193. /**
  12194. * An event triggered when the postprocess applies its effect.
  12195. */
  12196. onApplyObservable: Observable<Effect>;
  12197. private _onApplyObserver;
  12198. /**
  12199. * A function that is added to the onApplyObservable
  12200. */
  12201. onApply: (effect: Effect) => void;
  12202. /**
  12203. * An event triggered before rendering the postprocess
  12204. */
  12205. onBeforeRenderObservable: Observable<Effect>;
  12206. private _onBeforeRenderObserver;
  12207. /**
  12208. * A function that is added to the onBeforeRenderObservable
  12209. */
  12210. onBeforeRender: (effect: Effect) => void;
  12211. /**
  12212. * An event triggered after rendering the postprocess
  12213. */
  12214. onAfterRenderObservable: Observable<Effect>;
  12215. private _onAfterRenderObserver;
  12216. /**
  12217. * A function that is added to the onAfterRenderObservable
  12218. */
  12219. onAfterRender: (efect: Effect) => void;
  12220. /**
  12221. * 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
  12222. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  12223. */
  12224. inputTexture: InternalTexture;
  12225. /**
  12226. * Gets the camera which post process is applied to.
  12227. * @returns The camera the post process is applied to.
  12228. */
  12229. getCamera(): Camera;
  12230. /**
  12231. * Gets the texel size of the postprocess.
  12232. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  12233. */
  12234. readonly texelSize: Vector2;
  12235. /**
  12236. * Creates a new instance PostProcess
  12237. * @param name The name of the PostProcess.
  12238. * @param fragmentUrl The url of the fragment shader to be used.
  12239. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  12240. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  12241. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12242. * @param camera The camera to apply the render pass to.
  12243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12244. * @param engine The engine which the post process will be applied. (default: current engine)
  12245. * @param reusable If the post process can be reused on the same frame. (default: false)
  12246. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  12247. * @param textureType Type of textures used when performing the post process. (default: 0)
  12248. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  12249. * @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
  12250. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  12251. */
  12252. constructor(
  12253. /** Name of the PostProcess. */
  12254. 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);
  12255. /**
  12256. * Gets the engine which this post process belongs to.
  12257. * @returns The engine the post process was enabled with.
  12258. */
  12259. getEngine(): Engine;
  12260. /**
  12261. * The effect that is created when initializing the post process.
  12262. * @returns The created effect corrisponding the the postprocess.
  12263. */
  12264. getEffect(): Effect;
  12265. /**
  12266. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  12267. * @param postProcess The post process to share the output with.
  12268. * @returns This post process.
  12269. */
  12270. shareOutputWith(postProcess: PostProcess): PostProcess;
  12271. /**
  12272. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  12273. * This should be called if the post process that shares output with this post process is disabled/disposed.
  12274. */
  12275. useOwnOutput(): void;
  12276. /**
  12277. * Updates the effect with the current post process compile time values and recompiles the shader.
  12278. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12279. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12280. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12281. * @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
  12282. * @param onCompiled Called when the shader has been compiled.
  12283. * @param onError Called if there is an error when compiling a shader.
  12284. */
  12285. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12286. /**
  12287. * The post process is reusable if it can be used multiple times within one frame.
  12288. * @returns If the post process is reusable
  12289. */
  12290. isReusable(): boolean;
  12291. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  12292. markTextureDirty(): void;
  12293. /**
  12294. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  12295. * 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.
  12296. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  12297. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  12298. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  12299. * @returns The target texture that was bound to be written to.
  12300. */
  12301. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  12302. /**
  12303. * If the post process is supported.
  12304. */
  12305. readonly isSupported: boolean;
  12306. /**
  12307. * The aspect ratio of the output texture.
  12308. */
  12309. readonly aspectRatio: number;
  12310. /**
  12311. * Get a value indicating if the post-process is ready to be used
  12312. * @returns true if the post-process is ready (shader is compiled)
  12313. */
  12314. isReady(): boolean;
  12315. /**
  12316. * Binds all textures and uniforms to the shader, this will be run on every pass.
  12317. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  12318. */
  12319. apply(): Nullable<Effect>;
  12320. private _disposeTextures;
  12321. /**
  12322. * Disposes the post process.
  12323. * @param camera The camera to dispose the post process on.
  12324. */
  12325. dispose(camera?: Camera): void;
  12326. }
  12327. }
  12328. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  12329. /** @hidden */
  12330. export var kernelBlurVaryingDeclaration: {
  12331. name: string;
  12332. shader: string;
  12333. };
  12334. }
  12335. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  12336. /** @hidden */
  12337. export var kernelBlurFragment: {
  12338. name: string;
  12339. shader: string;
  12340. };
  12341. }
  12342. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  12343. /** @hidden */
  12344. export var kernelBlurFragment2: {
  12345. name: string;
  12346. shader: string;
  12347. };
  12348. }
  12349. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  12350. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12351. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  12352. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  12353. /** @hidden */
  12354. export var kernelBlurPixelShader: {
  12355. name: string;
  12356. shader: string;
  12357. };
  12358. }
  12359. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  12360. /** @hidden */
  12361. export var kernelBlurVertex: {
  12362. name: string;
  12363. shader: string;
  12364. };
  12365. }
  12366. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  12367. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  12368. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  12369. /** @hidden */
  12370. export var kernelBlurVertexShader: {
  12371. name: string;
  12372. shader: string;
  12373. };
  12374. }
  12375. declare module "babylonjs/PostProcesses/blurPostProcess" {
  12376. import { Vector2 } from "babylonjs/Maths/math";
  12377. import { Nullable } from "babylonjs/types";
  12378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  12379. import { Camera } from "babylonjs/Cameras/camera";
  12380. import { Effect } from "babylonjs/Materials/effect";
  12381. import { Engine } from "babylonjs/Engines/engine";
  12382. import "babylonjs/Shaders/kernelBlur.fragment";
  12383. import "babylonjs/Shaders/kernelBlur.vertex";
  12384. /**
  12385. * The Blur Post Process which blurs an image based on a kernel and direction.
  12386. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  12387. */
  12388. export class BlurPostProcess extends PostProcess {
  12389. /** The direction in which to blur the image. */
  12390. direction: Vector2;
  12391. private blockCompilation;
  12392. protected _kernel: number;
  12393. protected _idealKernel: number;
  12394. protected _packedFloat: boolean;
  12395. private _staticDefines;
  12396. /**
  12397. * Sets the length in pixels of the blur sample region
  12398. */
  12399. /**
  12400. * Gets the length in pixels of the blur sample region
  12401. */
  12402. kernel: number;
  12403. /**
  12404. * Sets wether or not the blur needs to unpack/repack floats
  12405. */
  12406. /**
  12407. * Gets wether or not the blur is unpacking/repacking floats
  12408. */
  12409. packedFloat: boolean;
  12410. /**
  12411. * Creates a new instance BlurPostProcess
  12412. * @param name The name of the effect.
  12413. * @param direction The direction in which to blur the image.
  12414. * @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.
  12415. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  12416. * @param camera The camera to apply the render pass to.
  12417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  12418. * @param engine The engine which the post process will be applied. (default: current engine)
  12419. * @param reusable If the post process can be reused on the same frame. (default: false)
  12420. * @param textureType Type of textures used when performing the post process. (default: 0)
  12421. * @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)
  12422. */
  12423. constructor(name: string,
  12424. /** The direction in which to blur the image. */
  12425. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  12426. /**
  12427. * Updates the effect with the current post process compile time values and recompiles the shader.
  12428. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  12429. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  12430. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  12431. * @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
  12432. * @param onCompiled Called when the shader has been compiled.
  12433. * @param onError Called if there is an error when compiling a shader.
  12434. */
  12435. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12436. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  12437. /**
  12438. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  12439. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  12440. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  12441. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  12442. * The gaps between physical kernels are compensated for in the weighting of the samples
  12443. * @param idealKernel Ideal blur kernel.
  12444. * @return Nearest best kernel.
  12445. */
  12446. protected _nearestBestKernel(idealKernel: number): number;
  12447. /**
  12448. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  12449. * @param x The point on the Gaussian distribution to sample.
  12450. * @return the value of the Gaussian function at x.
  12451. */
  12452. protected _gaussianWeight(x: number): number;
  12453. /**
  12454. * Generates a string that can be used as a floating point number in GLSL.
  12455. * @param x Value to print.
  12456. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  12457. * @return GLSL float string.
  12458. */
  12459. protected _glslFloat(x: number, decimalFigures?: number): string;
  12460. }
  12461. }
  12462. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  12463. import { Scene } from "babylonjs/scene";
  12464. import { Plane } from "babylonjs/Maths/math";
  12465. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12466. /**
  12467. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12468. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12469. * You can then easily use it as a reflectionTexture on a flat surface.
  12470. * In case the surface is not a plane, please consider relying on reflection probes.
  12471. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12472. */
  12473. export class MirrorTexture extends RenderTargetTexture {
  12474. private scene;
  12475. /**
  12476. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  12477. * 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.
  12478. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12479. */
  12480. mirrorPlane: Plane;
  12481. /**
  12482. * Define the blur ratio used to blur the reflection if needed.
  12483. */
  12484. blurRatio: number;
  12485. /**
  12486. * Define the adaptive blur kernel used to blur the reflection if needed.
  12487. * This will autocompute the closest best match for the `blurKernel`
  12488. */
  12489. adaptiveBlurKernel: number;
  12490. /**
  12491. * Define the blur kernel used to blur the reflection if needed.
  12492. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12493. */
  12494. blurKernel: number;
  12495. /**
  12496. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  12497. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12498. */
  12499. blurKernelX: number;
  12500. /**
  12501. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  12502. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  12503. */
  12504. blurKernelY: number;
  12505. private _autoComputeBlurKernel;
  12506. protected _onRatioRescale(): void;
  12507. private _updateGammaSpace;
  12508. private _imageProcessingConfigChangeObserver;
  12509. private _transformMatrix;
  12510. private _mirrorMatrix;
  12511. private _savedViewMatrix;
  12512. private _blurX;
  12513. private _blurY;
  12514. private _adaptiveBlurKernel;
  12515. private _blurKernelX;
  12516. private _blurKernelY;
  12517. private _blurRatio;
  12518. /**
  12519. * Instantiates a Mirror Texture.
  12520. * Mirror texture can be used to simulate the view from a mirror in a scene.
  12521. * It will dynamically be rendered every frame to adapt to the camera point of view.
  12522. * You can then easily use it as a reflectionTexture on a flat surface.
  12523. * In case the surface is not a plane, please consider relying on reflection probes.
  12524. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  12525. * @param name
  12526. * @param size
  12527. * @param scene
  12528. * @param generateMipMaps
  12529. * @param type
  12530. * @param samplingMode
  12531. * @param generateDepthBuffer
  12532. */
  12533. constructor(name: string, size: number | {
  12534. width: number;
  12535. height: number;
  12536. } | {
  12537. ratio: number;
  12538. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  12539. private _preparePostProcesses;
  12540. /**
  12541. * Clone the mirror texture.
  12542. * @returns the cloned texture
  12543. */
  12544. clone(): MirrorTexture;
  12545. /**
  12546. * Serialize the texture to a JSON representation you could use in Parse later on
  12547. * @returns the serialized JSON representation
  12548. */
  12549. serialize(): any;
  12550. /**
  12551. * Dispose the texture and release its associated resources.
  12552. */
  12553. dispose(): void;
  12554. }
  12555. }
  12556. declare module "babylonjs/Materials/Textures/texture" {
  12557. import { Observable } from "babylonjs/Misc/observable";
  12558. import { Nullable } from "babylonjs/types";
  12559. import { Scene } from "babylonjs/scene";
  12560. import { Matrix } from "babylonjs/Maths/math";
  12561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12562. /**
  12563. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12564. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12565. */
  12566. export class Texture extends BaseTexture {
  12567. /** @hidden */
  12568. static _AnimationParser: (jsonAnimation: any) => import("babylonjs/Animations/animation").Animation;
  12569. /** @hidden */
  12570. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  12571. /** @hidden */
  12572. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  12573. /** @hidden */
  12574. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  12575. /** nearest is mag = nearest and min = nearest and mip = linear */
  12576. static readonly NEAREST_SAMPLINGMODE: number;
  12577. /** nearest is mag = nearest and min = nearest and mip = linear */
  12578. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  12579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12580. static readonly BILINEAR_SAMPLINGMODE: number;
  12581. /** Bilinear is mag = linear and min = linear and mip = nearest */
  12582. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  12583. /** Trilinear is mag = linear and min = linear and mip = linear */
  12584. static readonly TRILINEAR_SAMPLINGMODE: number;
  12585. /** Trilinear is mag = linear and min = linear and mip = linear */
  12586. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  12587. /** mag = nearest and min = nearest and mip = nearest */
  12588. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  12589. /** mag = nearest and min = linear and mip = nearest */
  12590. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  12591. /** mag = nearest and min = linear and mip = linear */
  12592. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  12593. /** mag = nearest and min = linear and mip = none */
  12594. static readonly NEAREST_LINEAR: number;
  12595. /** mag = nearest and min = nearest and mip = none */
  12596. static readonly NEAREST_NEAREST: number;
  12597. /** mag = linear and min = nearest and mip = nearest */
  12598. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  12599. /** mag = linear and min = nearest and mip = linear */
  12600. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  12601. /** mag = linear and min = linear and mip = none */
  12602. static readonly LINEAR_LINEAR: number;
  12603. /** mag = linear and min = nearest and mip = none */
  12604. static readonly LINEAR_NEAREST: number;
  12605. /** Explicit coordinates mode */
  12606. static readonly EXPLICIT_MODE: number;
  12607. /** Spherical coordinates mode */
  12608. static readonly SPHERICAL_MODE: number;
  12609. /** Planar coordinates mode */
  12610. static readonly PLANAR_MODE: number;
  12611. /** Cubic coordinates mode */
  12612. static readonly CUBIC_MODE: number;
  12613. /** Projection coordinates mode */
  12614. static readonly PROJECTION_MODE: number;
  12615. /** Inverse Cubic coordinates mode */
  12616. static readonly SKYBOX_MODE: number;
  12617. /** Inverse Cubic coordinates mode */
  12618. static readonly INVCUBIC_MODE: number;
  12619. /** Equirectangular coordinates mode */
  12620. static readonly EQUIRECTANGULAR_MODE: number;
  12621. /** Equirectangular Fixed coordinates mode */
  12622. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  12623. /** Equirectangular Fixed Mirrored coordinates mode */
  12624. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  12625. /** Texture is not repeating outside of 0..1 UVs */
  12626. static readonly CLAMP_ADDRESSMODE: number;
  12627. /** Texture is repeating outside of 0..1 UVs */
  12628. static readonly WRAP_ADDRESSMODE: number;
  12629. /** Texture is repeating and mirrored */
  12630. static readonly MIRROR_ADDRESSMODE: number;
  12631. /**
  12632. * 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
  12633. */
  12634. static UseSerializedUrlIfAny: boolean;
  12635. /**
  12636. * Define the url of the texture.
  12637. */
  12638. url: Nullable<string>;
  12639. /**
  12640. * Define an offset on the texture to offset the u coordinates of the UVs
  12641. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12642. */
  12643. uOffset: number;
  12644. /**
  12645. * Define an offset on the texture to offset the v coordinates of the UVs
  12646. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  12647. */
  12648. vOffset: number;
  12649. /**
  12650. * Define an offset on the texture to scale the u coordinates of the UVs
  12651. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12652. */
  12653. uScale: number;
  12654. /**
  12655. * Define an offset on the texture to scale the v coordinates of the UVs
  12656. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  12657. */
  12658. vScale: number;
  12659. /**
  12660. * Define an offset on the texture to rotate around the u coordinates of the UVs
  12661. * @see http://doc.babylonjs.com/how_to/more_materials
  12662. */
  12663. uAng: number;
  12664. /**
  12665. * Define an offset on the texture to rotate around the v coordinates of the UVs
  12666. * @see http://doc.babylonjs.com/how_to/more_materials
  12667. */
  12668. vAng: number;
  12669. /**
  12670. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  12671. * @see http://doc.babylonjs.com/how_to/more_materials
  12672. */
  12673. wAng: number;
  12674. /**
  12675. * Defines the center of rotation (U)
  12676. */
  12677. uRotationCenter: number;
  12678. /**
  12679. * Defines the center of rotation (V)
  12680. */
  12681. vRotationCenter: number;
  12682. /**
  12683. * Defines the center of rotation (W)
  12684. */
  12685. wRotationCenter: number;
  12686. /**
  12687. * Are mip maps generated for this texture or not.
  12688. */
  12689. readonly noMipmap: boolean;
  12690. private _noMipmap;
  12691. /** @hidden */
  12692. _invertY: boolean;
  12693. private _rowGenerationMatrix;
  12694. private _cachedTextureMatrix;
  12695. private _projectionModeMatrix;
  12696. private _t0;
  12697. private _t1;
  12698. private _t2;
  12699. private _cachedUOffset;
  12700. private _cachedVOffset;
  12701. private _cachedUScale;
  12702. private _cachedVScale;
  12703. private _cachedUAng;
  12704. private _cachedVAng;
  12705. private _cachedWAng;
  12706. private _cachedProjectionMatrixId;
  12707. private _cachedCoordinatesMode;
  12708. /** @hidden */
  12709. protected _initialSamplingMode: number;
  12710. /** @hidden */
  12711. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  12712. private _deleteBuffer;
  12713. protected _format: Nullable<number>;
  12714. private _delayedOnLoad;
  12715. private _delayedOnError;
  12716. /**
  12717. * Observable triggered once the texture has been loaded.
  12718. */
  12719. onLoadObservable: Observable<Texture>;
  12720. protected _isBlocking: boolean;
  12721. /**
  12722. * Is the texture preventing material to render while loading.
  12723. * If false, a default texture will be used instead of the loading one during the preparation step.
  12724. */
  12725. isBlocking: boolean;
  12726. /**
  12727. * Get the current sampling mode associated with the texture.
  12728. */
  12729. readonly samplingMode: number;
  12730. /**
  12731. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  12732. */
  12733. readonly invertY: boolean;
  12734. /**
  12735. * Instantiates a new texture.
  12736. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  12737. * @see http://doc.babylonjs.com/babylon101/materials#texture
  12738. * @param url define the url of the picture to load as a texture
  12739. * @param scene define the scene the texture will belong to
  12740. * @param noMipmap define if the texture will require mip maps or not
  12741. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12742. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12743. * @param onLoad define a callback triggered when the texture has been loaded
  12744. * @param onError define a callback triggered when an error occurred during the loading session
  12745. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12746. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12747. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12748. */
  12749. 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);
  12750. /**
  12751. * Update the url (and optional buffer) of this texture if url was null during construction.
  12752. * @param url the url of the texture
  12753. * @param buffer the buffer of the texture (defaults to null)
  12754. * @param onLoad callback called when the texture is loaded (defaults to null)
  12755. */
  12756. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  12757. /**
  12758. * Finish the loading sequence of a texture flagged as delayed load.
  12759. * @hidden
  12760. */
  12761. delayLoad(): void;
  12762. private _prepareRowForTextureGeneration;
  12763. /**
  12764. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  12765. * @returns the transform matrix of the texture.
  12766. */
  12767. getTextureMatrix(): Matrix;
  12768. /**
  12769. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  12770. * @returns The reflection texture transform
  12771. */
  12772. getReflectionTextureMatrix(): Matrix;
  12773. /**
  12774. * Clones the texture.
  12775. * @returns the cloned texture
  12776. */
  12777. clone(): Texture;
  12778. /**
  12779. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  12780. * @returns The JSON representation of the texture
  12781. */
  12782. serialize(): any;
  12783. /**
  12784. * Get the current class name of the texture useful for serialization or dynamic coding.
  12785. * @returns "Texture"
  12786. */
  12787. getClassName(): string;
  12788. /**
  12789. * Dispose the texture and release its associated resources.
  12790. */
  12791. dispose(): void;
  12792. /**
  12793. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  12794. * @param parsedTexture Define the JSON representation of the texture
  12795. * @param scene Define the scene the parsed texture should be instantiated in
  12796. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  12797. * @returns The parsed texture if successful
  12798. */
  12799. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12800. /**
  12801. * Creates a texture from its base 64 representation.
  12802. * @param data Define the base64 payload without the data: prefix
  12803. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12804. * @param scene Define the scene the texture should belong to
  12805. * @param noMipmap Forces the texture to not create mip map information if true
  12806. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12807. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12808. * @param onLoad define a callback triggered when the texture has been loaded
  12809. * @param onError define a callback triggered when an error occurred during the loading session
  12810. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12811. * @returns the created texture
  12812. */
  12813. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12814. /**
  12815. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12816. * @param data Define the base64 payload without the data: prefix
  12817. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12818. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12819. * @param scene Define the scene the texture should belong to
  12820. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12821. * @param noMipmap Forces the texture to not create mip map information if true
  12822. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12823. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12824. * @param onLoad define a callback triggered when the texture has been loaded
  12825. * @param onError define a callback triggered when an error occurred during the loading session
  12826. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12827. * @returns the created texture
  12828. */
  12829. 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;
  12830. }
  12831. }
  12832. declare module "babylonjs/PostProcesses/postProcessManager" {
  12833. import { Nullable } from "babylonjs/types";
  12834. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12835. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  12836. import { Scene } from "babylonjs/scene";
  12837. /**
  12838. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12839. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12840. */
  12841. export class PostProcessManager {
  12842. private _scene;
  12843. private _indexBuffer;
  12844. private _vertexBuffers;
  12845. /**
  12846. * Creates a new instance PostProcess
  12847. * @param scene The scene that the post process is associated with.
  12848. */
  12849. constructor(scene: Scene);
  12850. private _prepareBuffers;
  12851. private _buildIndexBuffer;
  12852. /**
  12853. * Rebuilds the vertex buffers of the manager.
  12854. * @hidden
  12855. */
  12856. _rebuild(): void;
  12857. /**
  12858. * Prepares a frame to be run through a post process.
  12859. * @param sourceTexture The input texture to the post procesess. (default: null)
  12860. * @param postProcesses An array of post processes to be run. (default: null)
  12861. * @returns True if the post processes were able to be run.
  12862. * @hidden
  12863. */
  12864. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12865. /**
  12866. * Manually render a set of post processes to a texture.
  12867. * @param postProcesses An array of post processes to be run.
  12868. * @param targetTexture The target texture to render to.
  12869. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12870. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12871. * @param lodLevel defines which lod of the texture to render to
  12872. */
  12873. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12874. /**
  12875. * Finalize the result of the output of the postprocesses.
  12876. * @param doNotPresent If true the result will not be displayed to the screen.
  12877. * @param targetTexture The target texture to render to.
  12878. * @param faceIndex The index of the face to bind the target texture to.
  12879. * @param postProcesses The array of post processes to render.
  12880. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12881. * @hidden
  12882. */
  12883. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12884. /**
  12885. * Disposes of the post process manager.
  12886. */
  12887. dispose(): void;
  12888. }
  12889. }
  12890. declare module "babylonjs/sceneComponent" {
  12891. import { Scene } from "babylonjs/scene";
  12892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12893. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12894. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  12895. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  12896. import { Nullable } from "babylonjs/types";
  12897. import { Camera } from "babylonjs/Cameras/camera";
  12898. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12899. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12900. import { AbstractScene } from "babylonjs/abstractScene";
  12901. /**
  12902. * Groups all the scene component constants in one place to ease maintenance.
  12903. * @hidden
  12904. */
  12905. export class SceneComponentConstants {
  12906. static readonly NAME_EFFECTLAYER: string;
  12907. static readonly NAME_LAYER: string;
  12908. static readonly NAME_LENSFLARESYSTEM: string;
  12909. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12910. static readonly NAME_PARTICLESYSTEM: string;
  12911. static readonly NAME_GAMEPAD: string;
  12912. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12913. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12914. static readonly NAME_DEPTHRENDERER: string;
  12915. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12916. static readonly NAME_SPRITE: string;
  12917. static readonly NAME_OUTLINERENDERER: string;
  12918. static readonly NAME_PROCEDURALTEXTURE: string;
  12919. static readonly NAME_SHADOWGENERATOR: string;
  12920. static readonly NAME_OCTREE: string;
  12921. static readonly NAME_PHYSICSENGINE: string;
  12922. static readonly NAME_AUDIO: string;
  12923. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12924. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12925. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12926. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12927. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12928. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12929. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12930. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12931. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12932. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12933. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12934. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12935. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12936. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12937. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12938. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12939. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12940. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12941. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12942. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12943. static readonly STEP_AFTERRENDER_AUDIO: number;
  12944. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12945. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12946. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12947. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12948. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12949. static readonly STEP_POINTERMOVE_SPRITE: number;
  12950. static readonly STEP_POINTERDOWN_SPRITE: number;
  12951. static readonly STEP_POINTERUP_SPRITE: number;
  12952. }
  12953. /**
  12954. * This represents a scene component.
  12955. *
  12956. * This is used to decouple the dependency the scene is having on the different workloads like
  12957. * layers, post processes...
  12958. */
  12959. export interface ISceneComponent {
  12960. /**
  12961. * The name of the component. Each component must have a unique name.
  12962. */
  12963. name: string;
  12964. /**
  12965. * The scene the component belongs to.
  12966. */
  12967. scene: Scene;
  12968. /**
  12969. * Register the component to one instance of a scene.
  12970. */
  12971. register(): void;
  12972. /**
  12973. * Rebuilds the elements related to this component in case of
  12974. * context lost for instance.
  12975. */
  12976. rebuild(): void;
  12977. /**
  12978. * Disposes the component and the associated ressources.
  12979. */
  12980. dispose(): void;
  12981. }
  12982. /**
  12983. * This represents a SERIALIZABLE scene component.
  12984. *
  12985. * This extends Scene Component to add Serialization methods on top.
  12986. */
  12987. export interface ISceneSerializableComponent extends ISceneComponent {
  12988. /**
  12989. * Adds all the element from the container to the scene
  12990. * @param container the container holding the elements
  12991. */
  12992. addFromContainer(container: AbstractScene): void;
  12993. /**
  12994. * Removes all the elements in the container from the scene
  12995. * @param container contains the elements to remove
  12996. */
  12997. removeFromContainer(container: AbstractScene): void;
  12998. /**
  12999. * Serializes the component data to the specified json object
  13000. * @param serializationObject The object to serialize to
  13001. */
  13002. serialize(serializationObject: any): void;
  13003. }
  13004. /**
  13005. * Strong typing of a Mesh related stage step action
  13006. */
  13007. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  13008. /**
  13009. * Strong typing of a Evaluate Sub Mesh related stage step action
  13010. */
  13011. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  13012. /**
  13013. * Strong typing of a Active Mesh related stage step action
  13014. */
  13015. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  13016. /**
  13017. * Strong typing of a Camera related stage step action
  13018. */
  13019. export type CameraStageAction = (camera: Camera) => void;
  13020. /**
  13021. * Strong typing of a Render Target related stage step action
  13022. */
  13023. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  13024. /**
  13025. * Strong typing of a RenderingGroup related stage step action
  13026. */
  13027. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  13028. /**
  13029. * Strong typing of a Mesh Render related stage step action
  13030. */
  13031. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  13032. /**
  13033. * Strong typing of a simple stage step action
  13034. */
  13035. export type SimpleStageAction = () => void;
  13036. /**
  13037. * Strong typing of a render target action.
  13038. */
  13039. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  13040. /**
  13041. * Strong typing of a pointer move action.
  13042. */
  13043. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  13044. /**
  13045. * Strong typing of a pointer up/down action.
  13046. */
  13047. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  13048. /**
  13049. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  13050. * @hidden
  13051. */
  13052. export class Stage<T extends Function> extends Array<{
  13053. index: number;
  13054. component: ISceneComponent;
  13055. action: T;
  13056. }> {
  13057. /**
  13058. * Hide ctor from the rest of the world.
  13059. * @param items The items to add.
  13060. */
  13061. private constructor();
  13062. /**
  13063. * Creates a new Stage.
  13064. * @returns A new instance of a Stage
  13065. */
  13066. static Create<T extends Function>(): Stage<T>;
  13067. /**
  13068. * Registers a step in an ordered way in the targeted stage.
  13069. * @param index Defines the position to register the step in
  13070. * @param component Defines the component attached to the step
  13071. * @param action Defines the action to launch during the step
  13072. */
  13073. registerStep(index: number, component: ISceneComponent, action: T): void;
  13074. /**
  13075. * Clears all the steps from the stage.
  13076. */
  13077. clear(): void;
  13078. }
  13079. }
  13080. declare module "babylonjs/Sprites/spriteSceneComponent" {
  13081. import { Nullable } from "babylonjs/types";
  13082. import { Observable } from "babylonjs/Misc/observable";
  13083. import { Scene } from "babylonjs/scene";
  13084. import { Sprite } from "babylonjs/Sprites/sprite";
  13085. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  13086. import { Ray } from "babylonjs/Culling/ray";
  13087. import { Camera } from "babylonjs/Cameras/camera";
  13088. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13089. import { ISceneComponent } from "babylonjs/sceneComponent";
  13090. module "babylonjs/scene" {
  13091. interface Scene {
  13092. /** @hidden */
  13093. _pointerOverSprite: Nullable<Sprite>;
  13094. /** @hidden */
  13095. _pickedDownSprite: Nullable<Sprite>;
  13096. /** @hidden */
  13097. _tempSpritePickingRay: Nullable<Ray>;
  13098. /**
  13099. * All of the sprite managers added to this scene
  13100. * @see http://doc.babylonjs.com/babylon101/sprites
  13101. */
  13102. spriteManagers: Array<ISpriteManager>;
  13103. /**
  13104. * An event triggered when sprites rendering is about to start
  13105. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13106. */
  13107. onBeforeSpritesRenderingObservable: Observable<Scene>;
  13108. /**
  13109. * An event triggered when sprites rendering is done
  13110. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  13111. */
  13112. onAfterSpritesRenderingObservable: Observable<Scene>;
  13113. /** @hidden */
  13114. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13115. /** Launch a ray to try to pick a sprite in the scene
  13116. * @param x position on screen
  13117. * @param y position on screen
  13118. * @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
  13119. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13120. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  13121. * @returns a PickingInfo
  13122. */
  13123. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13124. /** Use the given ray to pick a sprite in the scene
  13125. * @param ray The ray (in world space) to use to pick meshes
  13126. * @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
  13127. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  13128. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  13129. * @returns a PickingInfo
  13130. */
  13131. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  13132. /**
  13133. * Force the sprite under the pointer
  13134. * @param sprite defines the sprite to use
  13135. */
  13136. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  13137. /**
  13138. * Gets the sprite under the pointer
  13139. * @returns a Sprite or null if no sprite is under the pointer
  13140. */
  13141. getPointerOverSprite(): Nullable<Sprite>;
  13142. }
  13143. }
  13144. /**
  13145. * Defines the sprite scene component responsible to manage sprites
  13146. * in a given scene.
  13147. */
  13148. export class SpriteSceneComponent implements ISceneComponent {
  13149. /**
  13150. * The component name helpfull to identify the component in the list of scene components.
  13151. */
  13152. readonly name: string;
  13153. /**
  13154. * The scene the component belongs to.
  13155. */
  13156. scene: Scene;
  13157. /** @hidden */
  13158. private _spritePredicate;
  13159. /**
  13160. * Creates a new instance of the component for the given scene
  13161. * @param scene Defines the scene to register the component in
  13162. */
  13163. constructor(scene: Scene);
  13164. /**
  13165. * Registers the component in a given scene
  13166. */
  13167. register(): void;
  13168. /**
  13169. * Rebuilds the elements related to this component in case of
  13170. * context lost for instance.
  13171. */
  13172. rebuild(): void;
  13173. /**
  13174. * Disposes the component and the associated ressources.
  13175. */
  13176. dispose(): void;
  13177. private _pickSpriteButKeepRay;
  13178. private _pointerMove;
  13179. private _pointerDown;
  13180. private _pointerUp;
  13181. }
  13182. }
  13183. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  13184. /** @hidden */
  13185. export var fogFragmentDeclaration: {
  13186. name: string;
  13187. shader: string;
  13188. };
  13189. }
  13190. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  13191. /** @hidden */
  13192. export var fogFragment: {
  13193. name: string;
  13194. shader: string;
  13195. };
  13196. }
  13197. declare module "babylonjs/Shaders/sprites.fragment" {
  13198. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  13199. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  13200. /** @hidden */
  13201. export var spritesPixelShader: {
  13202. name: string;
  13203. shader: string;
  13204. };
  13205. }
  13206. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  13207. /** @hidden */
  13208. export var fogVertexDeclaration: {
  13209. name: string;
  13210. shader: string;
  13211. };
  13212. }
  13213. declare module "babylonjs/Shaders/sprites.vertex" {
  13214. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  13215. /** @hidden */
  13216. export var spritesVertexShader: {
  13217. name: string;
  13218. shader: string;
  13219. };
  13220. }
  13221. declare module "babylonjs/Sprites/spriteManager" {
  13222. import { IDisposable, Scene } from "babylonjs/scene";
  13223. import { Nullable } from "babylonjs/types";
  13224. import { Observable } from "babylonjs/Misc/observable";
  13225. import { Sprite } from "babylonjs/Sprites/sprite";
  13226. import { Ray } from "babylonjs/Culling/ray";
  13227. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  13228. import { Camera } from "babylonjs/Cameras/camera";
  13229. import { Texture } from "babylonjs/Materials/Textures/texture";
  13230. import "babylonjs/Shaders/sprites.fragment";
  13231. import "babylonjs/Shaders/sprites.vertex";
  13232. /**
  13233. * Defines the minimum interface to fullfil in order to be a sprite manager.
  13234. */
  13235. export interface ISpriteManager extends IDisposable {
  13236. /**
  13237. * Restricts the camera to viewing objects with the same layerMask.
  13238. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  13239. */
  13240. layerMask: number;
  13241. /**
  13242. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  13243. */
  13244. isPickable: boolean;
  13245. /**
  13246. * Specifies the rendering group id for this mesh (0 by default)
  13247. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  13248. */
  13249. renderingGroupId: number;
  13250. /**
  13251. * Defines the list of sprites managed by the manager.
  13252. */
  13253. sprites: Array<Sprite>;
  13254. /**
  13255. * Tests the intersection of a sprite with a specific ray.
  13256. * @param ray The ray we are sending to test the collision
  13257. * @param camera The camera space we are sending rays in
  13258. * @param predicate A predicate allowing excluding sprites from the list of object to test
  13259. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  13260. * @returns picking info or null.
  13261. */
  13262. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13263. /**
  13264. * Renders the list of sprites on screen.
  13265. */
  13266. render(): void;
  13267. }
  13268. /**
  13269. * Class used to manage multiple sprites on the same spritesheet
  13270. * @see http://doc.babylonjs.com/babylon101/sprites
  13271. */
  13272. export class SpriteManager implements ISpriteManager {
  13273. /** defines the manager's name */
  13274. name: string;
  13275. /** Gets the list of sprites */
  13276. sprites: Sprite[];
  13277. /** Gets or sets the rendering group id (0 by default) */
  13278. renderingGroupId: number;
  13279. /** Gets or sets camera layer mask */
  13280. layerMask: number;
  13281. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  13282. fogEnabled: boolean;
  13283. /** Gets or sets a boolean indicating if the sprites are pickable */
  13284. isPickable: boolean;
  13285. /** Defines the default width of a cell in the spritesheet */
  13286. cellWidth: number;
  13287. /** Defines the default height of a cell in the spritesheet */
  13288. cellHeight: number;
  13289. /**
  13290. * An event triggered when the manager is disposed.
  13291. */
  13292. onDisposeObservable: Observable<SpriteManager>;
  13293. private _onDisposeObserver;
  13294. /**
  13295. * Callback called when the manager is disposed
  13296. */
  13297. onDispose: () => void;
  13298. private _capacity;
  13299. private _spriteTexture;
  13300. private _epsilon;
  13301. private _scene;
  13302. private _vertexData;
  13303. private _buffer;
  13304. private _vertexBuffers;
  13305. private _indexBuffer;
  13306. private _effectBase;
  13307. private _effectFog;
  13308. /**
  13309. * Gets or sets the spritesheet texture
  13310. */
  13311. texture: Texture;
  13312. /**
  13313. * Creates a new sprite manager
  13314. * @param name defines the manager's name
  13315. * @param imgUrl defines the sprite sheet url
  13316. * @param capacity defines the maximum allowed number of sprites
  13317. * @param cellSize defines the size of a sprite cell
  13318. * @param scene defines the hosting scene
  13319. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  13320. * @param samplingMode defines the smapling mode to use with spritesheet
  13321. */
  13322. constructor(
  13323. /** defines the manager's name */
  13324. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  13325. private _appendSpriteVertex;
  13326. /**
  13327. * Intersects the sprites with a ray
  13328. * @param ray defines the ray to intersect with
  13329. * @param camera defines the current active camera
  13330. * @param predicate defines a predicate used to select candidate sprites
  13331. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  13332. * @returns null if no hit or a PickingInfo
  13333. */
  13334. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  13335. /**
  13336. * Render all child sprites
  13337. */
  13338. render(): void;
  13339. /**
  13340. * Release associated resources
  13341. */
  13342. dispose(): void;
  13343. }
  13344. }
  13345. declare module "babylonjs/Layers/layerSceneComponent" {
  13346. import { Scene } from "babylonjs/scene";
  13347. import { ISceneComponent } from "babylonjs/sceneComponent";
  13348. import { Layer } from "babylonjs/Layers/layer";
  13349. module "babylonjs/abstractScene" {
  13350. interface AbstractScene {
  13351. /**
  13352. * The list of layers (background and foreground) of the scene
  13353. */
  13354. layers: Array<Layer>;
  13355. }
  13356. }
  13357. /**
  13358. * Defines the layer scene component responsible to manage any layers
  13359. * in a given scene.
  13360. */
  13361. export class LayerSceneComponent implements ISceneComponent {
  13362. /**
  13363. * The component name helpfull to identify the component in the list of scene components.
  13364. */
  13365. readonly name: string;
  13366. /**
  13367. * The scene the component belongs to.
  13368. */
  13369. scene: Scene;
  13370. private _engine;
  13371. /**
  13372. * Creates a new instance of the component for the given scene
  13373. * @param scene Defines the scene to register the component in
  13374. */
  13375. constructor(scene: Scene);
  13376. /**
  13377. * Registers the component in a given scene
  13378. */
  13379. register(): void;
  13380. /**
  13381. * Rebuilds the elements related to this component in case of
  13382. * context lost for instance.
  13383. */
  13384. rebuild(): void;
  13385. /**
  13386. * Disposes the component and the associated ressources.
  13387. */
  13388. dispose(): void;
  13389. private _draw;
  13390. private _drawCameraPredicate;
  13391. private _drawCameraBackground;
  13392. private _drawCameraForeground;
  13393. private _drawRenderTargetPredicate;
  13394. private _drawRenderTargetBackground;
  13395. private _drawRenderTargetForeground;
  13396. }
  13397. }
  13398. declare module "babylonjs/Shaders/layer.fragment" {
  13399. /** @hidden */
  13400. export var layerPixelShader: {
  13401. name: string;
  13402. shader: string;
  13403. };
  13404. }
  13405. declare module "babylonjs/Shaders/layer.vertex" {
  13406. /** @hidden */
  13407. export var layerVertexShader: {
  13408. name: string;
  13409. shader: string;
  13410. };
  13411. }
  13412. declare module "babylonjs/Layers/layer" {
  13413. import { Observable } from "babylonjs/Misc/observable";
  13414. import { Nullable } from "babylonjs/types";
  13415. import { Scene } from "babylonjs/scene";
  13416. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13417. import { Texture } from "babylonjs/Materials/Textures/texture";
  13418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13419. import "babylonjs/Shaders/layer.fragment";
  13420. import "babylonjs/Shaders/layer.vertex";
  13421. /**
  13422. * This represents a full screen 2d layer.
  13423. * This can be useful to display a picture in the background of your scene for instance.
  13424. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13425. */
  13426. export class Layer {
  13427. /**
  13428. * Define the name of the layer.
  13429. */
  13430. name: string;
  13431. /**
  13432. * Define the texture the layer should display.
  13433. */
  13434. texture: Nullable<Texture>;
  13435. /**
  13436. * Is the layer in background or foreground.
  13437. */
  13438. isBackground: boolean;
  13439. /**
  13440. * Define the color of the layer (instead of texture).
  13441. */
  13442. color: Color4;
  13443. /**
  13444. * Define the scale of the layer in order to zoom in out of the texture.
  13445. */
  13446. scale: Vector2;
  13447. /**
  13448. * Define an offset for the layer in order to shift the texture.
  13449. */
  13450. offset: Vector2;
  13451. /**
  13452. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13453. */
  13454. alphaBlendingMode: number;
  13455. /**
  13456. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13457. * Alpha test will not mix with the background color in case of transparency.
  13458. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13459. */
  13460. alphaTest: boolean;
  13461. /**
  13462. * Define a mask to restrict the layer to only some of the scene cameras.
  13463. */
  13464. layerMask: number;
  13465. /**
  13466. * Define the list of render target the layer is visible into.
  13467. */
  13468. renderTargetTextures: RenderTargetTexture[];
  13469. /**
  13470. * Define if the layer is only used in renderTarget or if it also
  13471. * renders in the main frame buffer of the canvas.
  13472. */
  13473. renderOnlyInRenderTargetTextures: boolean;
  13474. private _scene;
  13475. private _vertexBuffers;
  13476. private _indexBuffer;
  13477. private _effect;
  13478. private _alphaTestEffect;
  13479. /**
  13480. * An event triggered when the layer is disposed.
  13481. */
  13482. onDisposeObservable: Observable<Layer>;
  13483. private _onDisposeObserver;
  13484. /**
  13485. * Back compatibility with callback before the onDisposeObservable existed.
  13486. * The set callback will be triggered when the layer has been disposed.
  13487. */
  13488. onDispose: () => void;
  13489. /**
  13490. * An event triggered before rendering the scene
  13491. */
  13492. onBeforeRenderObservable: Observable<Layer>;
  13493. private _onBeforeRenderObserver;
  13494. /**
  13495. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13496. * The set callback will be triggered just before rendering the layer.
  13497. */
  13498. onBeforeRender: () => void;
  13499. /**
  13500. * An event triggered after rendering the scene
  13501. */
  13502. onAfterRenderObservable: Observable<Layer>;
  13503. private _onAfterRenderObserver;
  13504. /**
  13505. * Back compatibility with callback before the onAfterRenderObservable existed.
  13506. * The set callback will be triggered just after rendering the layer.
  13507. */
  13508. onAfterRender: () => void;
  13509. /**
  13510. * Instantiates a new layer.
  13511. * This represents a full screen 2d layer.
  13512. * This can be useful to display a picture in the background of your scene for instance.
  13513. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13514. * @param name Define the name of the layer in the scene
  13515. * @param imgUrl Define the url of the texture to display in the layer
  13516. * @param scene Define the scene the layer belongs to
  13517. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13518. * @param color Defines a color for the layer
  13519. */
  13520. constructor(
  13521. /**
  13522. * Define the name of the layer.
  13523. */
  13524. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13525. private _createIndexBuffer;
  13526. /** @hidden */
  13527. _rebuild(): void;
  13528. /**
  13529. * Renders the layer in the scene.
  13530. */
  13531. render(): void;
  13532. /**
  13533. * Disposes and releases the associated ressources.
  13534. */
  13535. dispose(): void;
  13536. }
  13537. }
  13538. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13539. import { Scene } from "babylonjs/scene";
  13540. import { ISceneComponent } from "babylonjs/sceneComponent";
  13541. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13542. module "babylonjs/abstractScene" {
  13543. interface AbstractScene {
  13544. /**
  13545. * The list of procedural textures added to the scene
  13546. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13547. */
  13548. proceduralTextures: Array<ProceduralTexture>;
  13549. }
  13550. }
  13551. /**
  13552. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13553. * in a given scene.
  13554. */
  13555. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13556. /**
  13557. * The component name helpfull to identify the component in the list of scene components.
  13558. */
  13559. readonly name: string;
  13560. /**
  13561. * The scene the component belongs to.
  13562. */
  13563. scene: Scene;
  13564. /**
  13565. * Creates a new instance of the component for the given scene
  13566. * @param scene Defines the scene to register the component in
  13567. */
  13568. constructor(scene: Scene);
  13569. /**
  13570. * Registers the component in a given scene
  13571. */
  13572. register(): void;
  13573. /**
  13574. * Rebuilds the elements related to this component in case of
  13575. * context lost for instance.
  13576. */
  13577. rebuild(): void;
  13578. /**
  13579. * Disposes the component and the associated ressources.
  13580. */
  13581. dispose(): void;
  13582. private _beforeClear;
  13583. }
  13584. }
  13585. declare module "babylonjs/Shaders/procedural.vertex" {
  13586. /** @hidden */
  13587. export var proceduralVertexShader: {
  13588. name: string;
  13589. shader: string;
  13590. };
  13591. }
  13592. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13593. import { Observable } from "babylonjs/Misc/observable";
  13594. import { Nullable } from "babylonjs/types";
  13595. import { Scene } from "babylonjs/scene";
  13596. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13597. import { Effect } from "babylonjs/Materials/effect";
  13598. import { Texture } from "babylonjs/Materials/Textures/texture";
  13599. import "babylonjs/Shaders/procedural.vertex";
  13600. /**
  13601. * 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.
  13602. * This is the base class of any Procedural texture and contains most of the shareable code.
  13603. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13604. */
  13605. export class ProceduralTexture extends Texture {
  13606. isCube: boolean;
  13607. /**
  13608. * Define if the texture is enabled or not (disabled texture will not render)
  13609. */
  13610. isEnabled: boolean;
  13611. /**
  13612. * Define if the texture must be cleared before rendering (default is true)
  13613. */
  13614. autoClear: boolean;
  13615. /**
  13616. * Callback called when the texture is generated
  13617. */
  13618. onGenerated: () => void;
  13619. /**
  13620. * Event raised when the texture is generated
  13621. */
  13622. onGeneratedObservable: Observable<ProceduralTexture>;
  13623. /** @hidden */
  13624. _generateMipMaps: boolean;
  13625. /** @hidden **/
  13626. _effect: Effect;
  13627. /** @hidden */
  13628. _textures: {
  13629. [key: string]: Texture;
  13630. };
  13631. private _size;
  13632. private _currentRefreshId;
  13633. private _refreshRate;
  13634. private _vertexBuffers;
  13635. private _indexBuffer;
  13636. private _uniforms;
  13637. private _samplers;
  13638. private _fragment;
  13639. private _floats;
  13640. private _ints;
  13641. private _floatsArrays;
  13642. private _colors3;
  13643. private _colors4;
  13644. private _vectors2;
  13645. private _vectors3;
  13646. private _matrices;
  13647. private _fallbackTexture;
  13648. private _fallbackTextureUsed;
  13649. private _engine;
  13650. private _cachedDefines;
  13651. private _contentUpdateId;
  13652. private _contentData;
  13653. /**
  13654. * Instantiates a new procedural texture.
  13655. * 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.
  13656. * This is the base class of any Procedural texture and contains most of the shareable code.
  13657. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13658. * @param name Define the name of the texture
  13659. * @param size Define the size of the texture to create
  13660. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13661. * @param scene Define the scene the texture belongs to
  13662. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13663. * @param generateMipMaps Define if the texture should creates mip maps or not
  13664. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13665. */
  13666. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13667. /**
  13668. * The effect that is created when initializing the post process.
  13669. * @returns The created effect corrisponding the the postprocess.
  13670. */
  13671. getEffect(): Effect;
  13672. /**
  13673. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13674. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13675. */
  13676. getContent(): Nullable<ArrayBufferView>;
  13677. private _createIndexBuffer;
  13678. /** @hidden */
  13679. _rebuild(): void;
  13680. /**
  13681. * Resets the texture in order to recreate its associated resources.
  13682. * This can be called in case of context loss
  13683. */
  13684. reset(): void;
  13685. protected _getDefines(): string;
  13686. /**
  13687. * Is the texture ready to be used ? (rendered at least once)
  13688. * @returns true if ready, otherwise, false.
  13689. */
  13690. isReady(): boolean;
  13691. /**
  13692. * Resets the refresh counter of the texture and start bak from scratch.
  13693. * Could be useful to regenerate the texture if it is setup to render only once.
  13694. */
  13695. resetRefreshCounter(): void;
  13696. /**
  13697. * Set the fragment shader to use in order to render the texture.
  13698. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13699. */
  13700. setFragment(fragment: any): void;
  13701. /**
  13702. * Define the refresh rate of the texture or the rendering frequency.
  13703. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13704. */
  13705. refreshRate: number;
  13706. /** @hidden */
  13707. _shouldRender(): boolean;
  13708. /**
  13709. * Get the size the texture is rendering at.
  13710. * @returns the size (texture is always squared)
  13711. */
  13712. getRenderSize(): number;
  13713. /**
  13714. * Resize the texture to new value.
  13715. * @param size Define the new size the texture should have
  13716. * @param generateMipMaps Define whether the new texture should create mip maps
  13717. */
  13718. resize(size: number, generateMipMaps: boolean): void;
  13719. private _checkUniform;
  13720. /**
  13721. * Set a texture in the shader program used to render.
  13722. * @param name Define the name of the uniform samplers as defined in the shader
  13723. * @param texture Define the texture to bind to this sampler
  13724. * @return the texture itself allowing "fluent" like uniform updates
  13725. */
  13726. setTexture(name: string, texture: Texture): ProceduralTexture;
  13727. /**
  13728. * Set a float in the shader.
  13729. * @param name Define the name of the uniform as defined in the shader
  13730. * @param value Define the value to give to the uniform
  13731. * @return the texture itself allowing "fluent" like uniform updates
  13732. */
  13733. setFloat(name: string, value: number): ProceduralTexture;
  13734. /**
  13735. * Set a int in the shader.
  13736. * @param name Define the name of the uniform as defined in the shader
  13737. * @param value Define the value to give to the uniform
  13738. * @return the texture itself allowing "fluent" like uniform updates
  13739. */
  13740. setInt(name: string, value: number): ProceduralTexture;
  13741. /**
  13742. * Set an array of floats in the shader.
  13743. * @param name Define the name of the uniform as defined in the shader
  13744. * @param value Define the value to give to the uniform
  13745. * @return the texture itself allowing "fluent" like uniform updates
  13746. */
  13747. setFloats(name: string, value: number[]): ProceduralTexture;
  13748. /**
  13749. * Set a vec3 in the shader from a Color3.
  13750. * @param name Define the name of the uniform as defined in the shader
  13751. * @param value Define the value to give to the uniform
  13752. * @return the texture itself allowing "fluent" like uniform updates
  13753. */
  13754. setColor3(name: string, value: Color3): ProceduralTexture;
  13755. /**
  13756. * Set a vec4 in the shader from a Color4.
  13757. * @param name Define the name of the uniform as defined in the shader
  13758. * @param value Define the value to give to the uniform
  13759. * @return the texture itself allowing "fluent" like uniform updates
  13760. */
  13761. setColor4(name: string, value: Color4): ProceduralTexture;
  13762. /**
  13763. * Set a vec2 in the shader from a Vector2.
  13764. * @param name Define the name of the uniform as defined in the shader
  13765. * @param value Define the value to give to the uniform
  13766. * @return the texture itself allowing "fluent" like uniform updates
  13767. */
  13768. setVector2(name: string, value: Vector2): ProceduralTexture;
  13769. /**
  13770. * Set a vec3 in the shader from a Vector3.
  13771. * @param name Define the name of the uniform as defined in the shader
  13772. * @param value Define the value to give to the uniform
  13773. * @return the texture itself allowing "fluent" like uniform updates
  13774. */
  13775. setVector3(name: string, value: Vector3): ProceduralTexture;
  13776. /**
  13777. * Set a mat4 in the shader from a MAtrix.
  13778. * @param name Define the name of the uniform as defined in the shader
  13779. * @param value Define the value to give to the uniform
  13780. * @return the texture itself allowing "fluent" like uniform updates
  13781. */
  13782. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13783. /**
  13784. * Render the texture to its associated render target.
  13785. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13786. */
  13787. render(useCameraPostProcess?: boolean): void;
  13788. /**
  13789. * Clone the texture.
  13790. * @returns the cloned texture
  13791. */
  13792. clone(): ProceduralTexture;
  13793. /**
  13794. * Dispose the texture and release its asoociated resources.
  13795. */
  13796. dispose(): void;
  13797. }
  13798. }
  13799. declare module "babylonjs/Particles/baseParticleSystem" {
  13800. import { Nullable } from "babylonjs/types";
  13801. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  13802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13803. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  13804. import { Texture } from "babylonjs/Materials/Textures/texture";
  13805. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13806. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13807. import { Scene } from "babylonjs/scene";
  13808. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  13809. import { Animation } from "babylonjs/Animations/animation";
  13810. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13811. /**
  13812. * This represents the base class for particle system in Babylon.
  13813. * 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.
  13814. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13815. * @example https://doc.babylonjs.com/babylon101/particles
  13816. */
  13817. export class BaseParticleSystem {
  13818. /**
  13819. * Source color is added to the destination color without alpha affecting the result
  13820. */
  13821. static BLENDMODE_ONEONE: number;
  13822. /**
  13823. * Blend current color and particle color using particle’s alpha
  13824. */
  13825. static BLENDMODE_STANDARD: number;
  13826. /**
  13827. * Add current color and particle color multiplied by particle’s alpha
  13828. */
  13829. static BLENDMODE_ADD: number;
  13830. /**
  13831. * Multiply current color with particle color
  13832. */
  13833. static BLENDMODE_MULTIPLY: number;
  13834. /**
  13835. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13836. */
  13837. static BLENDMODE_MULTIPLYADD: number;
  13838. /**
  13839. * List of animations used by the particle system.
  13840. */
  13841. animations: Animation[];
  13842. /**
  13843. * The id of the Particle system.
  13844. */
  13845. id: string;
  13846. /**
  13847. * The friendly name of the Particle system.
  13848. */
  13849. name: string;
  13850. /**
  13851. * The rendering group used by the Particle system to chose when to render.
  13852. */
  13853. renderingGroupId: number;
  13854. /**
  13855. * The emitter represents the Mesh or position we are attaching the particle system to.
  13856. */
  13857. emitter: Nullable<AbstractMesh | Vector3>;
  13858. /**
  13859. * The maximum number of particles to emit per frame
  13860. */
  13861. emitRate: number;
  13862. /**
  13863. * If you want to launch only a few particles at once, that can be done, as well.
  13864. */
  13865. manualEmitCount: number;
  13866. /**
  13867. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13868. */
  13869. updateSpeed: number;
  13870. /**
  13871. * The amount of time the particle system is running (depends of the overall update speed).
  13872. */
  13873. targetStopDuration: number;
  13874. /**
  13875. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13876. */
  13877. disposeOnStop: boolean;
  13878. /**
  13879. * Minimum power of emitting particles.
  13880. */
  13881. minEmitPower: number;
  13882. /**
  13883. * Maximum power of emitting particles.
  13884. */
  13885. maxEmitPower: number;
  13886. /**
  13887. * Minimum life time of emitting particles.
  13888. */
  13889. minLifeTime: number;
  13890. /**
  13891. * Maximum life time of emitting particles.
  13892. */
  13893. maxLifeTime: number;
  13894. /**
  13895. * Minimum Size of emitting particles.
  13896. */
  13897. minSize: number;
  13898. /**
  13899. * Maximum Size of emitting particles.
  13900. */
  13901. maxSize: number;
  13902. /**
  13903. * Minimum scale of emitting particles on X axis.
  13904. */
  13905. minScaleX: number;
  13906. /**
  13907. * Maximum scale of emitting particles on X axis.
  13908. */
  13909. maxScaleX: number;
  13910. /**
  13911. * Minimum scale of emitting particles on Y axis.
  13912. */
  13913. minScaleY: number;
  13914. /**
  13915. * Maximum scale of emitting particles on Y axis.
  13916. */
  13917. maxScaleY: number;
  13918. /**
  13919. * Gets or sets the minimal initial rotation in radians.
  13920. */
  13921. minInitialRotation: number;
  13922. /**
  13923. * Gets or sets the maximal initial rotation in radians.
  13924. */
  13925. maxInitialRotation: number;
  13926. /**
  13927. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13928. */
  13929. minAngularSpeed: number;
  13930. /**
  13931. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13932. */
  13933. maxAngularSpeed: number;
  13934. /**
  13935. * The texture used to render each particle. (this can be a spritesheet)
  13936. */
  13937. particleTexture: Nullable<Texture>;
  13938. /**
  13939. * The layer mask we are rendering the particles through.
  13940. */
  13941. layerMask: number;
  13942. /**
  13943. * This can help using your own shader to render the particle system.
  13944. * The according effect will be created
  13945. */
  13946. customShader: any;
  13947. /**
  13948. * By default particle system starts as soon as they are created. This prevents the
  13949. * automatic start to happen and let you decide when to start emitting particles.
  13950. */
  13951. preventAutoStart: boolean;
  13952. private _noiseTexture;
  13953. /**
  13954. * Gets or sets a texture used to add random noise to particle positions
  13955. */
  13956. noiseTexture: Nullable<ProceduralTexture>;
  13957. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13958. noiseStrength: Vector3;
  13959. /**
  13960. * Callback triggered when the particle animation is ending.
  13961. */
  13962. onAnimationEnd: Nullable<() => void>;
  13963. /**
  13964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13965. */
  13966. blendMode: number;
  13967. /**
  13968. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13969. * to override the particles.
  13970. */
  13971. forceDepthWrite: boolean;
  13972. /** 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 */
  13973. preWarmCycles: number;
  13974. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13975. preWarmStepOffset: number;
  13976. /**
  13977. * 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)
  13978. */
  13979. spriteCellChangeSpeed: number;
  13980. /**
  13981. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13982. */
  13983. startSpriteCellID: number;
  13984. /**
  13985. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13986. */
  13987. endSpriteCellID: number;
  13988. /**
  13989. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13990. */
  13991. spriteCellWidth: number;
  13992. /**
  13993. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13994. */
  13995. spriteCellHeight: number;
  13996. /**
  13997. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13998. */
  13999. spriteRandomStartCell: boolean;
  14000. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14001. translationPivot: Vector2;
  14002. /** @hidden */
  14003. protected _isAnimationSheetEnabled: boolean;
  14004. /**
  14005. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14006. */
  14007. beginAnimationOnStart: boolean;
  14008. /**
  14009. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14010. */
  14011. beginAnimationFrom: number;
  14012. /**
  14013. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14014. */
  14015. beginAnimationTo: number;
  14016. /**
  14017. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14018. */
  14019. beginAnimationLoop: boolean;
  14020. /**
  14021. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14022. */
  14023. isAnimationSheetEnabled: boolean;
  14024. /**
  14025. * Get hosting scene
  14026. * @returns the scene
  14027. */
  14028. getScene(): Scene;
  14029. /**
  14030. * You can use gravity if you want to give an orientation to your particles.
  14031. */
  14032. gravity: Vector3;
  14033. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14034. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14035. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14036. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14037. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14038. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14039. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14040. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14041. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14042. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14043. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14044. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14045. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14046. /**
  14047. * Defines the delay in milliseconds before starting the system (0 by default)
  14048. */
  14049. startDelay: number;
  14050. /**
  14051. * Gets the current list of drag gradients.
  14052. * You must use addDragGradient and removeDragGradient to udpate this list
  14053. * @returns the list of drag gradients
  14054. */
  14055. getDragGradients(): Nullable<Array<FactorGradient>>;
  14056. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14057. limitVelocityDamping: number;
  14058. /**
  14059. * Gets the current list of limit velocity gradients.
  14060. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14061. * @returns the list of limit velocity gradients
  14062. */
  14063. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14064. /**
  14065. * Gets the current list of color gradients.
  14066. * You must use addColorGradient and removeColorGradient to udpate this list
  14067. * @returns the list of color gradients
  14068. */
  14069. getColorGradients(): Nullable<Array<ColorGradient>>;
  14070. /**
  14071. * Gets the current list of size gradients.
  14072. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14073. * @returns the list of size gradients
  14074. */
  14075. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14076. /**
  14077. * Gets the current list of color remap gradients.
  14078. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14079. * @returns the list of color remap gradients
  14080. */
  14081. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14082. /**
  14083. * Gets the current list of alpha remap gradients.
  14084. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14085. * @returns the list of alpha remap gradients
  14086. */
  14087. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14088. /**
  14089. * Gets the current list of life time gradients.
  14090. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14091. * @returns the list of life time gradients
  14092. */
  14093. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14094. /**
  14095. * Gets the current list of angular speed gradients.
  14096. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14097. * @returns the list of angular speed gradients
  14098. */
  14099. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14100. /**
  14101. * Gets the current list of velocity gradients.
  14102. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14103. * @returns the list of velocity gradients
  14104. */
  14105. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14106. /**
  14107. * Gets the current list of start size gradients.
  14108. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14109. * @returns the list of start size gradients
  14110. */
  14111. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14112. /**
  14113. * Gets the current list of emit rate gradients.
  14114. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14115. * @returns the list of emit rate gradients
  14116. */
  14117. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14118. /**
  14119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14120. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14121. */
  14122. direction1: Vector3;
  14123. /**
  14124. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14125. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14126. */
  14127. direction2: Vector3;
  14128. /**
  14129. * 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.
  14130. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14131. */
  14132. minEmitBox: Vector3;
  14133. /**
  14134. * 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.
  14135. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14136. */
  14137. maxEmitBox: Vector3;
  14138. /**
  14139. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14140. */
  14141. color1: Color4;
  14142. /**
  14143. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14144. */
  14145. color2: Color4;
  14146. /**
  14147. * Color the particle will have at the end of its lifetime
  14148. */
  14149. colorDead: Color4;
  14150. /**
  14151. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14152. */
  14153. textureMask: Color4;
  14154. /**
  14155. * The particle emitter type defines the emitter used by the particle system.
  14156. * It can be for example box, sphere, or cone...
  14157. */
  14158. particleEmitterType: IParticleEmitterType;
  14159. /** @hidden */
  14160. _isSubEmitter: boolean;
  14161. /**
  14162. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14163. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14164. */
  14165. billboardMode: number;
  14166. protected _isBillboardBased: boolean;
  14167. /**
  14168. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14169. */
  14170. isBillboardBased: boolean;
  14171. /**
  14172. * The scene the particle system belongs to.
  14173. */
  14174. protected _scene: Scene;
  14175. /**
  14176. * Local cache of defines for image processing.
  14177. */
  14178. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14179. /**
  14180. * Default configuration related to image processing available in the standard Material.
  14181. */
  14182. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14183. /**
  14184. * Gets the image processing configuration used either in this material.
  14185. */
  14186. /**
  14187. * Sets the Default image processing configuration used either in the this material.
  14188. *
  14189. * If sets to null, the scene one is in use.
  14190. */
  14191. imageProcessingConfiguration: ImageProcessingConfiguration;
  14192. /**
  14193. * Attaches a new image processing configuration to the Standard Material.
  14194. * @param configuration
  14195. */
  14196. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14197. /** @hidden */
  14198. protected _reset(): void;
  14199. /** @hidden */
  14200. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14201. /**
  14202. * Instantiates a particle system.
  14203. * 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.
  14204. * @param name The name of the particle system
  14205. */
  14206. constructor(name: string);
  14207. /**
  14208. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14211. * @returns the emitter
  14212. */
  14213. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14214. /**
  14215. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14216. * @param radius The radius of the hemisphere to emit from
  14217. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14218. * @returns the emitter
  14219. */
  14220. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14221. /**
  14222. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14223. * @param radius The radius of the sphere to emit from
  14224. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14225. * @returns the emitter
  14226. */
  14227. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14228. /**
  14229. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14230. * @param radius The radius of the sphere to emit from
  14231. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14232. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14233. * @returns the emitter
  14234. */
  14235. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14236. /**
  14237. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14238. * @param radius The radius of the emission cylinder
  14239. * @param height The height of the emission cylinder
  14240. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14241. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14242. * @returns the emitter
  14243. */
  14244. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14245. /**
  14246. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14247. * @param radius The radius of the cylinder to emit from
  14248. * @param height The height of the emission cylinder
  14249. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14250. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14251. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14252. * @returns the emitter
  14253. */
  14254. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14255. /**
  14256. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14257. * @param radius The radius of the cone to emit from
  14258. * @param angle The base angle of the cone
  14259. * @returns the emitter
  14260. */
  14261. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14262. /**
  14263. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14264. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14265. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14266. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14267. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14268. * @returns the emitter
  14269. */
  14270. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14271. }
  14272. }
  14273. declare module "babylonjs/Particles/subEmitter" {
  14274. import { Scene } from "babylonjs/scene";
  14275. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14276. /**
  14277. * Type of sub emitter
  14278. */
  14279. export enum SubEmitterType {
  14280. /**
  14281. * Attached to the particle over it's lifetime
  14282. */
  14283. ATTACHED = 0,
  14284. /**
  14285. * Created when the particle dies
  14286. */
  14287. END = 1
  14288. }
  14289. /**
  14290. * Sub emitter class used to emit particles from an existing particle
  14291. */
  14292. export class SubEmitter {
  14293. /**
  14294. * the particle system to be used by the sub emitter
  14295. */
  14296. particleSystem: ParticleSystem;
  14297. /**
  14298. * Type of the submitter (Default: END)
  14299. */
  14300. type: SubEmitterType;
  14301. /**
  14302. * 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)
  14303. * Note: This only is supported when using an emitter of type Mesh
  14304. */
  14305. inheritDirection: boolean;
  14306. /**
  14307. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14308. */
  14309. inheritedVelocityAmount: number;
  14310. /**
  14311. * Creates a sub emitter
  14312. * @param particleSystem the particle system to be used by the sub emitter
  14313. */
  14314. constructor(
  14315. /**
  14316. * the particle system to be used by the sub emitter
  14317. */
  14318. particleSystem: ParticleSystem);
  14319. /**
  14320. * Clones the sub emitter
  14321. * @returns the cloned sub emitter
  14322. */
  14323. clone(): SubEmitter;
  14324. /**
  14325. * Serialize current object to a JSON object
  14326. * @returns the serialized object
  14327. */
  14328. serialize(): any;
  14329. /** @hidden */
  14330. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14331. /**
  14332. * Creates a new SubEmitter from a serialized JSON version
  14333. * @param serializationObject defines the JSON object to read from
  14334. * @param scene defines the hosting scene
  14335. * @param rootUrl defines the rootUrl for data loading
  14336. * @returns a new SubEmitter
  14337. */
  14338. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14339. /** Release associated resources */
  14340. dispose(): void;
  14341. }
  14342. }
  14343. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14344. /** @hidden */
  14345. export var clipPlaneFragmentDeclaration: {
  14346. name: string;
  14347. shader: string;
  14348. };
  14349. }
  14350. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14351. /** @hidden */
  14352. export var imageProcessingDeclaration: {
  14353. name: string;
  14354. shader: string;
  14355. };
  14356. }
  14357. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14358. /** @hidden */
  14359. export var imageProcessingFunctions: {
  14360. name: string;
  14361. shader: string;
  14362. };
  14363. }
  14364. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14365. /** @hidden */
  14366. export var clipPlaneFragment: {
  14367. name: string;
  14368. shader: string;
  14369. };
  14370. }
  14371. declare module "babylonjs/Shaders/particles.fragment" {
  14372. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14373. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14374. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14375. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14376. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14377. /** @hidden */
  14378. export var particlesPixelShader: {
  14379. name: string;
  14380. shader: string;
  14381. };
  14382. }
  14383. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14384. /** @hidden */
  14385. export var clipPlaneVertexDeclaration: {
  14386. name: string;
  14387. shader: string;
  14388. };
  14389. }
  14390. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14391. /** @hidden */
  14392. export var clipPlaneVertex: {
  14393. name: string;
  14394. shader: string;
  14395. };
  14396. }
  14397. declare module "babylonjs/Shaders/particles.vertex" {
  14398. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14399. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14400. /** @hidden */
  14401. export var particlesVertexShader: {
  14402. name: string;
  14403. shader: string;
  14404. };
  14405. }
  14406. declare module "babylonjs/Particles/particleSystem" {
  14407. import { Nullable } from "babylonjs/types";
  14408. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14409. import { Observable } from "babylonjs/Misc/observable";
  14410. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14411. import { Effect } from "babylonjs/Materials/effect";
  14412. import { Scene, IDisposable } from "babylonjs/scene";
  14413. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14414. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14415. import { Particle } from "babylonjs/Particles/particle";
  14416. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14417. import "babylonjs/Shaders/particles.fragment";
  14418. import "babylonjs/Shaders/particles.vertex";
  14419. /**
  14420. * This represents a particle system in Babylon.
  14421. * 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.
  14422. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14423. * @example https://doc.babylonjs.com/babylon101/particles
  14424. */
  14425. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14426. /**
  14427. * Billboard mode will only apply to Y axis
  14428. */
  14429. static readonly BILLBOARDMODE_Y: number;
  14430. /**
  14431. * Billboard mode will apply to all axes
  14432. */
  14433. static readonly BILLBOARDMODE_ALL: number;
  14434. /**
  14435. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14436. */
  14437. static readonly BILLBOARDMODE_STRETCHED: number;
  14438. /**
  14439. * This function can be defined to provide custom update for active particles.
  14440. * This function will be called instead of regular update (age, position, color, etc.).
  14441. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14442. */
  14443. updateFunction: (particles: Particle[]) => void;
  14444. private _emitterWorldMatrix;
  14445. /**
  14446. * This function can be defined to specify initial direction for every new particle.
  14447. * It by default use the emitterType defined function
  14448. */
  14449. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14450. /**
  14451. * This function can be defined to specify initial position for every new particle.
  14452. * It by default use the emitterType defined function
  14453. */
  14454. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14455. /**
  14456. * @hidden
  14457. */
  14458. _inheritedVelocityOffset: Vector3;
  14459. /**
  14460. * An event triggered when the system is disposed
  14461. */
  14462. onDisposeObservable: Observable<ParticleSystem>;
  14463. private _onDisposeObserver;
  14464. /**
  14465. * Sets a callback that will be triggered when the system is disposed
  14466. */
  14467. onDispose: () => void;
  14468. private _particles;
  14469. private _epsilon;
  14470. private _capacity;
  14471. private _stockParticles;
  14472. private _newPartsExcess;
  14473. private _vertexData;
  14474. private _vertexBuffer;
  14475. private _vertexBuffers;
  14476. private _spriteBuffer;
  14477. private _indexBuffer;
  14478. private _effect;
  14479. private _customEffect;
  14480. private _cachedDefines;
  14481. private _scaledColorStep;
  14482. private _colorDiff;
  14483. private _scaledDirection;
  14484. private _scaledGravity;
  14485. private _currentRenderId;
  14486. private _alive;
  14487. private _useInstancing;
  14488. private _started;
  14489. private _stopped;
  14490. private _actualFrame;
  14491. private _scaledUpdateSpeed;
  14492. private _vertexBufferSize;
  14493. /** @hidden */
  14494. _currentEmitRateGradient: Nullable<FactorGradient>;
  14495. /** @hidden */
  14496. _currentEmitRate1: number;
  14497. /** @hidden */
  14498. _currentEmitRate2: number;
  14499. /** @hidden */
  14500. _currentStartSizeGradient: Nullable<FactorGradient>;
  14501. /** @hidden */
  14502. _currentStartSize1: number;
  14503. /** @hidden */
  14504. _currentStartSize2: number;
  14505. private readonly _rawTextureWidth;
  14506. private _rampGradientsTexture;
  14507. private _useRampGradients;
  14508. /** Gets or sets a boolean indicating that ramp gradients must be used
  14509. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14510. */
  14511. useRampGradients: boolean;
  14512. /**
  14513. * 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.
  14514. * 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: [])
  14515. */
  14516. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14517. private _subEmitters;
  14518. /**
  14519. * @hidden
  14520. * If the particle systems emitter should be disposed when the particle system is disposed
  14521. */
  14522. _disposeEmitterOnDispose: boolean;
  14523. /**
  14524. * The current active Sub-systems, this property is used by the root particle system only.
  14525. */
  14526. activeSubSystems: Array<ParticleSystem>;
  14527. private _rootParticleSystem;
  14528. /**
  14529. * Gets the current list of active particles
  14530. */
  14531. readonly particles: Particle[];
  14532. /**
  14533. * Returns the string "ParticleSystem"
  14534. * @returns a string containing the class name
  14535. */
  14536. getClassName(): string;
  14537. /**
  14538. * Instantiates a particle system.
  14539. * 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.
  14540. * @param name The name of the particle system
  14541. * @param capacity The max number of particles alive at the same time
  14542. * @param scene The scene the particle system belongs to
  14543. * @param customEffect a custom effect used to change the way particles are rendered by default
  14544. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14545. * @param epsilon Offset used to render the particles
  14546. */
  14547. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14548. private _addFactorGradient;
  14549. private _removeFactorGradient;
  14550. /**
  14551. * Adds a new life time gradient
  14552. * @param gradient defines the gradient to use (between 0 and 1)
  14553. * @param factor defines the life time factor to affect to the specified gradient
  14554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14555. * @returns the current particle system
  14556. */
  14557. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14558. /**
  14559. * Remove a specific life time gradient
  14560. * @param gradient defines the gradient to remove
  14561. * @returns the current particle system
  14562. */
  14563. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14564. /**
  14565. * Adds a new size gradient
  14566. * @param gradient defines the gradient to use (between 0 and 1)
  14567. * @param factor defines the size factor to affect to the specified gradient
  14568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14569. * @returns the current particle system
  14570. */
  14571. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14572. /**
  14573. * Remove a specific size gradient
  14574. * @param gradient defines the gradient to remove
  14575. * @returns the current particle system
  14576. */
  14577. removeSizeGradient(gradient: number): IParticleSystem;
  14578. /**
  14579. * Adds a new color remap gradient
  14580. * @param gradient defines the gradient to use (between 0 and 1)
  14581. * @param min defines the color remap minimal range
  14582. * @param max defines the color remap maximal range
  14583. * @returns the current particle system
  14584. */
  14585. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14586. /**
  14587. * Remove a specific color remap gradient
  14588. * @param gradient defines the gradient to remove
  14589. * @returns the current particle system
  14590. */
  14591. removeColorRemapGradient(gradient: number): IParticleSystem;
  14592. /**
  14593. * Adds a new alpha remap gradient
  14594. * @param gradient defines the gradient to use (between 0 and 1)
  14595. * @param min defines the alpha remap minimal range
  14596. * @param max defines the alpha remap maximal range
  14597. * @returns the current particle system
  14598. */
  14599. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14600. /**
  14601. * Remove a specific alpha remap gradient
  14602. * @param gradient defines the gradient to remove
  14603. * @returns the current particle system
  14604. */
  14605. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14606. /**
  14607. * Adds a new angular speed gradient
  14608. * @param gradient defines the gradient to use (between 0 and 1)
  14609. * @param factor defines the angular speed to affect to the specified gradient
  14610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14611. * @returns the current particle system
  14612. */
  14613. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14614. /**
  14615. * Remove a specific angular speed gradient
  14616. * @param gradient defines the gradient to remove
  14617. * @returns the current particle system
  14618. */
  14619. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14620. /**
  14621. * Adds a new velocity gradient
  14622. * @param gradient defines the gradient to use (between 0 and 1)
  14623. * @param factor defines the velocity to affect to the specified gradient
  14624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14625. * @returns the current particle system
  14626. */
  14627. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14628. /**
  14629. * Remove a specific velocity gradient
  14630. * @param gradient defines the gradient to remove
  14631. * @returns the current particle system
  14632. */
  14633. removeVelocityGradient(gradient: number): IParticleSystem;
  14634. /**
  14635. * Adds a new limit velocity gradient
  14636. * @param gradient defines the gradient to use (between 0 and 1)
  14637. * @param factor defines the limit velocity value to affect to the specified gradient
  14638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14639. * @returns the current particle system
  14640. */
  14641. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14642. /**
  14643. * Remove a specific limit velocity gradient
  14644. * @param gradient defines the gradient to remove
  14645. * @returns the current particle system
  14646. */
  14647. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14648. /**
  14649. * Adds a new drag gradient
  14650. * @param gradient defines the gradient to use (between 0 and 1)
  14651. * @param factor defines the drag value to affect to the specified gradient
  14652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14653. * @returns the current particle system
  14654. */
  14655. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14656. /**
  14657. * Remove a specific drag gradient
  14658. * @param gradient defines the gradient to remove
  14659. * @returns the current particle system
  14660. */
  14661. removeDragGradient(gradient: number): IParticleSystem;
  14662. /**
  14663. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14664. * @param gradient defines the gradient to use (between 0 and 1)
  14665. * @param factor defines the emit rate value to affect to the specified gradient
  14666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14667. * @returns the current particle system
  14668. */
  14669. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14670. /**
  14671. * Remove a specific emit rate gradient
  14672. * @param gradient defines the gradient to remove
  14673. * @returns the current particle system
  14674. */
  14675. removeEmitRateGradient(gradient: number): IParticleSystem;
  14676. /**
  14677. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14678. * @param gradient defines the gradient to use (between 0 and 1)
  14679. * @param factor defines the start size value to affect to the specified gradient
  14680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14681. * @returns the current particle system
  14682. */
  14683. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14684. /**
  14685. * Remove a specific start size gradient
  14686. * @param gradient defines the gradient to remove
  14687. * @returns the current particle system
  14688. */
  14689. removeStartSizeGradient(gradient: number): IParticleSystem;
  14690. private _createRampGradientTexture;
  14691. /**
  14692. * Gets the current list of ramp gradients.
  14693. * You must use addRampGradient and removeRampGradient to udpate this list
  14694. * @returns the list of ramp gradients
  14695. */
  14696. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14697. /**
  14698. * Adds a new ramp gradient used to remap particle colors
  14699. * @param gradient defines the gradient to use (between 0 and 1)
  14700. * @param color defines the color to affect to the specified gradient
  14701. * @returns the current particle system
  14702. */
  14703. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14704. /**
  14705. * Remove a specific ramp gradient
  14706. * @param gradient defines the gradient to remove
  14707. * @returns the current particle system
  14708. */
  14709. removeRampGradient(gradient: number): ParticleSystem;
  14710. /**
  14711. * Adds a new color gradient
  14712. * @param gradient defines the gradient to use (between 0 and 1)
  14713. * @param color1 defines the color to affect to the specified gradient
  14714. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14715. * @returns this particle system
  14716. */
  14717. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14718. /**
  14719. * Remove a specific color gradient
  14720. * @param gradient defines the gradient to remove
  14721. * @returns this particle system
  14722. */
  14723. removeColorGradient(gradient: number): IParticleSystem;
  14724. private _fetchR;
  14725. protected _reset(): void;
  14726. private _resetEffect;
  14727. private _createVertexBuffers;
  14728. private _createIndexBuffer;
  14729. /**
  14730. * Gets the maximum number of particles active at the same time.
  14731. * @returns The max number of active particles.
  14732. */
  14733. getCapacity(): number;
  14734. /**
  14735. * Gets whether there are still active particles in the system.
  14736. * @returns True if it is alive, otherwise false.
  14737. */
  14738. isAlive(): boolean;
  14739. /**
  14740. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14741. * @returns True if it has been started, otherwise false.
  14742. */
  14743. isStarted(): boolean;
  14744. private _prepareSubEmitterInternalArray;
  14745. /**
  14746. * Starts the particle system and begins to emit
  14747. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14748. */
  14749. start(delay?: number): void;
  14750. /**
  14751. * Stops the particle system.
  14752. * @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.
  14753. */
  14754. stop(stopSubEmitters?: boolean): void;
  14755. /**
  14756. * Remove all active particles
  14757. */
  14758. reset(): void;
  14759. /**
  14760. * @hidden (for internal use only)
  14761. */
  14762. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14763. /**
  14764. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14765. * Its lifetime will start back at 0.
  14766. */
  14767. recycleParticle: (particle: Particle) => void;
  14768. private _stopSubEmitters;
  14769. private _createParticle;
  14770. private _removeFromRoot;
  14771. private _emitFromParticle;
  14772. private _update;
  14773. /** @hidden */
  14774. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14775. /** @hidden */
  14776. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14777. /** @hidden */
  14778. private _getEffect;
  14779. /**
  14780. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14781. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14782. */
  14783. animate(preWarmOnly?: boolean): void;
  14784. private _appendParticleVertices;
  14785. /**
  14786. * Rebuilds the particle system.
  14787. */
  14788. rebuild(): void;
  14789. /**
  14790. * Is this system ready to be used/rendered
  14791. * @return true if the system is ready
  14792. */
  14793. isReady(): boolean;
  14794. private _render;
  14795. /**
  14796. * Renders the particle system in its current state.
  14797. * @returns the current number of particles
  14798. */
  14799. render(): number;
  14800. /**
  14801. * Disposes the particle system and free the associated resources
  14802. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14803. */
  14804. dispose(disposeTexture?: boolean): void;
  14805. /**
  14806. * Clones the particle system.
  14807. * @param name The name of the cloned object
  14808. * @param newEmitter The new emitter to use
  14809. * @returns the cloned particle system
  14810. */
  14811. clone(name: string, newEmitter: any): ParticleSystem;
  14812. /**
  14813. * Serializes the particle system to a JSON object.
  14814. * @returns the JSON object
  14815. */
  14816. serialize(): any;
  14817. /** @hidden */
  14818. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14819. /** @hidden */
  14820. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14821. /**
  14822. * Parses a JSON object to create a particle system.
  14823. * @param parsedParticleSystem The JSON object to parse
  14824. * @param scene The scene to create the particle system in
  14825. * @param rootUrl The root url to use to load external dependencies like texture
  14826. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14827. * @returns the Parsed particle system
  14828. */
  14829. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14830. }
  14831. }
  14832. declare module "babylonjs/Particles/particle" {
  14833. import { Nullable } from "babylonjs/types";
  14834. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  14835. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14836. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14837. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  14838. /**
  14839. * A particle represents one of the element emitted by a particle system.
  14840. * This is mainly define by its coordinates, direction, velocity and age.
  14841. */
  14842. export class Particle {
  14843. /**
  14844. * The particle system the particle belongs to.
  14845. */
  14846. particleSystem: ParticleSystem;
  14847. private static _Count;
  14848. /**
  14849. * Unique ID of the particle
  14850. */
  14851. id: number;
  14852. /**
  14853. * The world position of the particle in the scene.
  14854. */
  14855. position: Vector3;
  14856. /**
  14857. * The world direction of the particle in the scene.
  14858. */
  14859. direction: Vector3;
  14860. /**
  14861. * The color of the particle.
  14862. */
  14863. color: Color4;
  14864. /**
  14865. * The color change of the particle per step.
  14866. */
  14867. colorStep: Color4;
  14868. /**
  14869. * Defines how long will the life of the particle be.
  14870. */
  14871. lifeTime: number;
  14872. /**
  14873. * The current age of the particle.
  14874. */
  14875. age: number;
  14876. /**
  14877. * The current size of the particle.
  14878. */
  14879. size: number;
  14880. /**
  14881. * The current scale of the particle.
  14882. */
  14883. scale: Vector2;
  14884. /**
  14885. * The current angle of the particle.
  14886. */
  14887. angle: number;
  14888. /**
  14889. * Defines how fast is the angle changing.
  14890. */
  14891. angularSpeed: number;
  14892. /**
  14893. * Defines the cell index used by the particle to be rendered from a sprite.
  14894. */
  14895. cellIndex: number;
  14896. /**
  14897. * The information required to support color remapping
  14898. */
  14899. remapData: Vector4;
  14900. /** @hidden */
  14901. _randomCellOffset?: number;
  14902. /** @hidden */
  14903. _initialDirection: Nullable<Vector3>;
  14904. /** @hidden */
  14905. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14906. /** @hidden */
  14907. _initialStartSpriteCellID: number;
  14908. /** @hidden */
  14909. _initialEndSpriteCellID: number;
  14910. /** @hidden */
  14911. _currentColorGradient: Nullable<ColorGradient>;
  14912. /** @hidden */
  14913. _currentColor1: Color4;
  14914. /** @hidden */
  14915. _currentColor2: Color4;
  14916. /** @hidden */
  14917. _currentSizeGradient: Nullable<FactorGradient>;
  14918. /** @hidden */
  14919. _currentSize1: number;
  14920. /** @hidden */
  14921. _currentSize2: number;
  14922. /** @hidden */
  14923. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14924. /** @hidden */
  14925. _currentAngularSpeed1: number;
  14926. /** @hidden */
  14927. _currentAngularSpeed2: number;
  14928. /** @hidden */
  14929. _currentVelocityGradient: Nullable<FactorGradient>;
  14930. /** @hidden */
  14931. _currentVelocity1: number;
  14932. /** @hidden */
  14933. _currentVelocity2: number;
  14934. /** @hidden */
  14935. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14936. /** @hidden */
  14937. _currentLimitVelocity1: number;
  14938. /** @hidden */
  14939. _currentLimitVelocity2: number;
  14940. /** @hidden */
  14941. _currentDragGradient: Nullable<FactorGradient>;
  14942. /** @hidden */
  14943. _currentDrag1: number;
  14944. /** @hidden */
  14945. _currentDrag2: number;
  14946. /** @hidden */
  14947. _randomNoiseCoordinates1: Vector3;
  14948. /** @hidden */
  14949. _randomNoiseCoordinates2: Vector3;
  14950. /**
  14951. * Creates a new instance Particle
  14952. * @param particleSystem the particle system the particle belongs to
  14953. */
  14954. constructor(
  14955. /**
  14956. * The particle system the particle belongs to.
  14957. */
  14958. particleSystem: ParticleSystem);
  14959. private updateCellInfoFromSystem;
  14960. /**
  14961. * Defines how the sprite cell index is updated for the particle
  14962. */
  14963. updateCellIndex(): void;
  14964. /** @hidden */
  14965. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14966. /** @hidden */
  14967. _inheritParticleInfoToSubEmitters(): void;
  14968. /** @hidden */
  14969. _reset(): void;
  14970. /**
  14971. * Copy the properties of particle to another one.
  14972. * @param other the particle to copy the information to.
  14973. */
  14974. copyTo(other: Particle): void;
  14975. }
  14976. }
  14977. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  14978. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14979. import { Effect } from "babylonjs/Materials/effect";
  14980. import { Particle } from "babylonjs/Particles/particle";
  14981. /**
  14982. * Particle emitter represents a volume emitting particles.
  14983. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14984. */
  14985. export interface IParticleEmitterType {
  14986. /**
  14987. * Called by the particle System when the direction is computed for the created particle.
  14988. * @param worldMatrix is the world matrix of the particle system
  14989. * @param directionToUpdate is the direction vector to update with the result
  14990. * @param particle is the particle we are computed the direction for
  14991. */
  14992. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14993. /**
  14994. * Called by the particle System when the position is computed for the created particle.
  14995. * @param worldMatrix is the world matrix of the particle system
  14996. * @param positionToUpdate is the position vector to update with the result
  14997. * @param particle is the particle we are computed the position for
  14998. */
  14999. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15000. /**
  15001. * Clones the current emitter and returns a copy of it
  15002. * @returns the new emitter
  15003. */
  15004. clone(): IParticleEmitterType;
  15005. /**
  15006. * Called by the GPUParticleSystem to setup the update shader
  15007. * @param effect defines the update shader
  15008. */
  15009. applyToShader(effect: Effect): void;
  15010. /**
  15011. * Returns a string to use to update the GPU particles update shader
  15012. * @returns the effect defines string
  15013. */
  15014. getEffectDefines(): string;
  15015. /**
  15016. * Returns a string representing the class name
  15017. * @returns a string containing the class name
  15018. */
  15019. getClassName(): string;
  15020. /**
  15021. * Serializes the particle system to a JSON object.
  15022. * @returns the JSON object
  15023. */
  15024. serialize(): any;
  15025. /**
  15026. * Parse properties from a JSON object
  15027. * @param serializationObject defines the JSON object
  15028. */
  15029. parse(serializationObject: any): void;
  15030. }
  15031. }
  15032. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15033. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15034. import { Effect } from "babylonjs/Materials/effect";
  15035. import { Particle } from "babylonjs/Particles/particle";
  15036. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15037. /**
  15038. * Particle emitter emitting particles from the inside of a box.
  15039. * It emits the particles randomly between 2 given directions.
  15040. */
  15041. export class BoxParticleEmitter implements IParticleEmitterType {
  15042. /**
  15043. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15044. */
  15045. direction1: Vector3;
  15046. /**
  15047. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15048. */
  15049. direction2: Vector3;
  15050. /**
  15051. * 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.
  15052. */
  15053. minEmitBox: Vector3;
  15054. /**
  15055. * 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.
  15056. */
  15057. maxEmitBox: Vector3;
  15058. /**
  15059. * Creates a new instance BoxParticleEmitter
  15060. */
  15061. constructor();
  15062. /**
  15063. * Called by the particle System when the direction is computed for the created particle.
  15064. * @param worldMatrix is the world matrix of the particle system
  15065. * @param directionToUpdate is the direction vector to update with the result
  15066. * @param particle is the particle we are computed the direction for
  15067. */
  15068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15069. /**
  15070. * Called by the particle System when the position is computed for the created particle.
  15071. * @param worldMatrix is the world matrix of the particle system
  15072. * @param positionToUpdate is the position vector to update with the result
  15073. * @param particle is the particle we are computed the position for
  15074. */
  15075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15076. /**
  15077. * Clones the current emitter and returns a copy of it
  15078. * @returns the new emitter
  15079. */
  15080. clone(): BoxParticleEmitter;
  15081. /**
  15082. * Called by the GPUParticleSystem to setup the update shader
  15083. * @param effect defines the update shader
  15084. */
  15085. applyToShader(effect: Effect): void;
  15086. /**
  15087. * Returns a string to use to update the GPU particles update shader
  15088. * @returns a string containng the defines string
  15089. */
  15090. getEffectDefines(): string;
  15091. /**
  15092. * Returns the string "BoxParticleEmitter"
  15093. * @returns a string containing the class name
  15094. */
  15095. getClassName(): string;
  15096. /**
  15097. * Serializes the particle system to a JSON object.
  15098. * @returns the JSON object
  15099. */
  15100. serialize(): any;
  15101. /**
  15102. * Parse properties from a JSON object
  15103. * @param serializationObject defines the JSON object
  15104. */
  15105. parse(serializationObject: any): void;
  15106. }
  15107. }
  15108. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15109. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15110. import { Effect } from "babylonjs/Materials/effect";
  15111. import { Particle } from "babylonjs/Particles/particle";
  15112. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15113. /**
  15114. * Particle emitter emitting particles from the inside of a cone.
  15115. * It emits the particles alongside the cone volume from the base to the particle.
  15116. * The emission direction might be randomized.
  15117. */
  15118. export class ConeParticleEmitter implements IParticleEmitterType {
  15119. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15120. directionRandomizer: number;
  15121. private _radius;
  15122. private _angle;
  15123. private _height;
  15124. /**
  15125. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15126. */
  15127. radiusRange: number;
  15128. /**
  15129. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15130. */
  15131. heightRange: number;
  15132. /**
  15133. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15134. */
  15135. emitFromSpawnPointOnly: boolean;
  15136. /**
  15137. * Gets or sets the radius of the emission cone
  15138. */
  15139. radius: number;
  15140. /**
  15141. * Gets or sets the angle of the emission cone
  15142. */
  15143. angle: number;
  15144. private _buildHeight;
  15145. /**
  15146. * Creates a new instance ConeParticleEmitter
  15147. * @param radius the radius of the emission cone (1 by default)
  15148. * @param angle the cone base angle (PI by default)
  15149. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15150. */
  15151. constructor(radius?: number, angle?: number,
  15152. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15153. directionRandomizer?: number);
  15154. /**
  15155. * Called by the particle System when the direction is computed for the created particle.
  15156. * @param worldMatrix is the world matrix of the particle system
  15157. * @param directionToUpdate is the direction vector to update with the result
  15158. * @param particle is the particle we are computed the direction for
  15159. */
  15160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15161. /**
  15162. * Called by the particle System when the position is computed for the created particle.
  15163. * @param worldMatrix is the world matrix of the particle system
  15164. * @param positionToUpdate is the position vector to update with the result
  15165. * @param particle is the particle we are computed the position for
  15166. */
  15167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15168. /**
  15169. * Clones the current emitter and returns a copy of it
  15170. * @returns the new emitter
  15171. */
  15172. clone(): ConeParticleEmitter;
  15173. /**
  15174. * Called by the GPUParticleSystem to setup the update shader
  15175. * @param effect defines the update shader
  15176. */
  15177. applyToShader(effect: Effect): void;
  15178. /**
  15179. * Returns a string to use to update the GPU particles update shader
  15180. * @returns a string containng the defines string
  15181. */
  15182. getEffectDefines(): string;
  15183. /**
  15184. * Returns the string "ConeParticleEmitter"
  15185. * @returns a string containing the class name
  15186. */
  15187. getClassName(): string;
  15188. /**
  15189. * Serializes the particle system to a JSON object.
  15190. * @returns the JSON object
  15191. */
  15192. serialize(): any;
  15193. /**
  15194. * Parse properties from a JSON object
  15195. * @param serializationObject defines the JSON object
  15196. */
  15197. parse(serializationObject: any): void;
  15198. }
  15199. }
  15200. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15201. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15202. import { Effect } from "babylonjs/Materials/effect";
  15203. import { Particle } from "babylonjs/Particles/particle";
  15204. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15205. /**
  15206. * Particle emitter emitting particles from the inside of a cylinder.
  15207. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15208. */
  15209. export class CylinderParticleEmitter implements IParticleEmitterType {
  15210. /**
  15211. * The radius of the emission cylinder.
  15212. */
  15213. radius: number;
  15214. /**
  15215. * The height of the emission cylinder.
  15216. */
  15217. height: number;
  15218. /**
  15219. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15220. */
  15221. radiusRange: number;
  15222. /**
  15223. * How much to randomize the particle direction [0-1].
  15224. */
  15225. directionRandomizer: number;
  15226. /**
  15227. * Creates a new instance CylinderParticleEmitter
  15228. * @param radius the radius of the emission cylinder (1 by default)
  15229. * @param height the height of the emission cylinder (1 by default)
  15230. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15231. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15232. */
  15233. constructor(
  15234. /**
  15235. * The radius of the emission cylinder.
  15236. */
  15237. radius?: number,
  15238. /**
  15239. * The height of the emission cylinder.
  15240. */
  15241. height?: number,
  15242. /**
  15243. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15244. */
  15245. radiusRange?: number,
  15246. /**
  15247. * How much to randomize the particle direction [0-1].
  15248. */
  15249. directionRandomizer?: number);
  15250. /**
  15251. * Called by the particle System when the direction is computed for the created particle.
  15252. * @param worldMatrix is the world matrix of the particle system
  15253. * @param directionToUpdate is the direction vector to update with the result
  15254. * @param particle is the particle we are computed the direction for
  15255. */
  15256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15257. /**
  15258. * Called by the particle System when the position is computed for the created particle.
  15259. * @param worldMatrix is the world matrix of the particle system
  15260. * @param positionToUpdate is the position vector to update with the result
  15261. * @param particle is the particle we are computed the position for
  15262. */
  15263. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15264. /**
  15265. * Clones the current emitter and returns a copy of it
  15266. * @returns the new emitter
  15267. */
  15268. clone(): CylinderParticleEmitter;
  15269. /**
  15270. * Called by the GPUParticleSystem to setup the update shader
  15271. * @param effect defines the update shader
  15272. */
  15273. applyToShader(effect: Effect): void;
  15274. /**
  15275. * Returns a string to use to update the GPU particles update shader
  15276. * @returns a string containng the defines string
  15277. */
  15278. getEffectDefines(): string;
  15279. /**
  15280. * Returns the string "CylinderParticleEmitter"
  15281. * @returns a string containing the class name
  15282. */
  15283. getClassName(): string;
  15284. /**
  15285. * Serializes the particle system to a JSON object.
  15286. * @returns the JSON object
  15287. */
  15288. serialize(): any;
  15289. /**
  15290. * Parse properties from a JSON object
  15291. * @param serializationObject defines the JSON object
  15292. */
  15293. parse(serializationObject: any): void;
  15294. }
  15295. /**
  15296. * Particle emitter emitting particles from the inside of a cylinder.
  15297. * It emits the particles randomly between two vectors.
  15298. */
  15299. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15300. /**
  15301. * The min limit of the emission direction.
  15302. */
  15303. direction1: Vector3;
  15304. /**
  15305. * The max limit of the emission direction.
  15306. */
  15307. direction2: Vector3;
  15308. /**
  15309. * Creates a new instance CylinderDirectedParticleEmitter
  15310. * @param radius the radius of the emission cylinder (1 by default)
  15311. * @param height the height of the emission cylinder (1 by default)
  15312. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15313. * @param direction1 the min limit of the emission direction (up vector by default)
  15314. * @param direction2 the max limit of the emission direction (up vector by default)
  15315. */
  15316. constructor(radius?: number, height?: number, radiusRange?: number,
  15317. /**
  15318. * The min limit of the emission direction.
  15319. */
  15320. direction1?: Vector3,
  15321. /**
  15322. * The max limit of the emission direction.
  15323. */
  15324. direction2?: Vector3);
  15325. /**
  15326. * Called by the particle System when the direction is computed for the created particle.
  15327. * @param worldMatrix is the world matrix of the particle system
  15328. * @param directionToUpdate is the direction vector to update with the result
  15329. * @param particle is the particle we are computed the direction for
  15330. */
  15331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15332. /**
  15333. * Clones the current emitter and returns a copy of it
  15334. * @returns the new emitter
  15335. */
  15336. clone(): CylinderDirectedParticleEmitter;
  15337. /**
  15338. * Called by the GPUParticleSystem to setup the update shader
  15339. * @param effect defines the update shader
  15340. */
  15341. applyToShader(effect: Effect): void;
  15342. /**
  15343. * Returns a string to use to update the GPU particles update shader
  15344. * @returns a string containng the defines string
  15345. */
  15346. getEffectDefines(): string;
  15347. /**
  15348. * Returns the string "CylinderDirectedParticleEmitter"
  15349. * @returns a string containing the class name
  15350. */
  15351. getClassName(): string;
  15352. /**
  15353. * Serializes the particle system to a JSON object.
  15354. * @returns the JSON object
  15355. */
  15356. serialize(): any;
  15357. /**
  15358. * Parse properties from a JSON object
  15359. * @param serializationObject defines the JSON object
  15360. */
  15361. parse(serializationObject: any): void;
  15362. }
  15363. }
  15364. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15365. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15366. import { Effect } from "babylonjs/Materials/effect";
  15367. import { Particle } from "babylonjs/Particles/particle";
  15368. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15369. /**
  15370. * Particle emitter emitting particles from the inside of a hemisphere.
  15371. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15372. */
  15373. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15374. /**
  15375. * The radius of the emission hemisphere.
  15376. */
  15377. radius: number;
  15378. /**
  15379. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15380. */
  15381. radiusRange: number;
  15382. /**
  15383. * How much to randomize the particle direction [0-1].
  15384. */
  15385. directionRandomizer: number;
  15386. /**
  15387. * Creates a new instance HemisphericParticleEmitter
  15388. * @param radius the radius of the emission hemisphere (1 by default)
  15389. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15390. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15391. */
  15392. constructor(
  15393. /**
  15394. * The radius of the emission hemisphere.
  15395. */
  15396. radius?: number,
  15397. /**
  15398. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15399. */
  15400. radiusRange?: number,
  15401. /**
  15402. * How much to randomize the particle direction [0-1].
  15403. */
  15404. directionRandomizer?: number);
  15405. /**
  15406. * Called by the particle System when the direction is computed for the created particle.
  15407. * @param worldMatrix is the world matrix of the particle system
  15408. * @param directionToUpdate is the direction vector to update with the result
  15409. * @param particle is the particle we are computed the direction for
  15410. */
  15411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15412. /**
  15413. * Called by the particle System when the position is computed for the created particle.
  15414. * @param worldMatrix is the world matrix of the particle system
  15415. * @param positionToUpdate is the position vector to update with the result
  15416. * @param particle is the particle we are computed the position for
  15417. */
  15418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15419. /**
  15420. * Clones the current emitter and returns a copy of it
  15421. * @returns the new emitter
  15422. */
  15423. clone(): HemisphericParticleEmitter;
  15424. /**
  15425. * Called by the GPUParticleSystem to setup the update shader
  15426. * @param effect defines the update shader
  15427. */
  15428. applyToShader(effect: Effect): void;
  15429. /**
  15430. * Returns a string to use to update the GPU particles update shader
  15431. * @returns a string containng the defines string
  15432. */
  15433. getEffectDefines(): string;
  15434. /**
  15435. * Returns the string "HemisphericParticleEmitter"
  15436. * @returns a string containing the class name
  15437. */
  15438. getClassName(): string;
  15439. /**
  15440. * Serializes the particle system to a JSON object.
  15441. * @returns the JSON object
  15442. */
  15443. serialize(): any;
  15444. /**
  15445. * Parse properties from a JSON object
  15446. * @param serializationObject defines the JSON object
  15447. */
  15448. parse(serializationObject: any): void;
  15449. }
  15450. }
  15451. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15452. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15453. import { Effect } from "babylonjs/Materials/effect";
  15454. import { Particle } from "babylonjs/Particles/particle";
  15455. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15456. /**
  15457. * Particle emitter emitting particles from a point.
  15458. * It emits the particles randomly between 2 given directions.
  15459. */
  15460. export class PointParticleEmitter implements IParticleEmitterType {
  15461. /**
  15462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15463. */
  15464. direction1: Vector3;
  15465. /**
  15466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15467. */
  15468. direction2: Vector3;
  15469. /**
  15470. * Creates a new instance PointParticleEmitter
  15471. */
  15472. constructor();
  15473. /**
  15474. * Called by the particle System when the direction is computed for the created particle.
  15475. * @param worldMatrix is the world matrix of the particle system
  15476. * @param directionToUpdate is the direction vector to update with the result
  15477. * @param particle is the particle we are computed the direction for
  15478. */
  15479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15480. /**
  15481. * Called by the particle System when the position is computed for the created particle.
  15482. * @param worldMatrix is the world matrix of the particle system
  15483. * @param positionToUpdate is the position vector to update with the result
  15484. * @param particle is the particle we are computed the position for
  15485. */
  15486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15487. /**
  15488. * Clones the current emitter and returns a copy of it
  15489. * @returns the new emitter
  15490. */
  15491. clone(): PointParticleEmitter;
  15492. /**
  15493. * Called by the GPUParticleSystem to setup the update shader
  15494. * @param effect defines the update shader
  15495. */
  15496. applyToShader(effect: Effect): void;
  15497. /**
  15498. * Returns a string to use to update the GPU particles update shader
  15499. * @returns a string containng the defines string
  15500. */
  15501. getEffectDefines(): string;
  15502. /**
  15503. * Returns the string "PointParticleEmitter"
  15504. * @returns a string containing the class name
  15505. */
  15506. getClassName(): string;
  15507. /**
  15508. * Serializes the particle system to a JSON object.
  15509. * @returns the JSON object
  15510. */
  15511. serialize(): any;
  15512. /**
  15513. * Parse properties from a JSON object
  15514. * @param serializationObject defines the JSON object
  15515. */
  15516. parse(serializationObject: any): void;
  15517. }
  15518. }
  15519. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15520. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15521. import { Effect } from "babylonjs/Materials/effect";
  15522. import { Particle } from "babylonjs/Particles/particle";
  15523. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15524. /**
  15525. * Particle emitter emitting particles from the inside of a sphere.
  15526. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15527. */
  15528. export class SphereParticleEmitter implements IParticleEmitterType {
  15529. /**
  15530. * The radius of the emission sphere.
  15531. */
  15532. radius: number;
  15533. /**
  15534. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15535. */
  15536. radiusRange: number;
  15537. /**
  15538. * How much to randomize the particle direction [0-1].
  15539. */
  15540. directionRandomizer: number;
  15541. /**
  15542. * Creates a new instance SphereParticleEmitter
  15543. * @param radius the radius of the emission sphere (1 by default)
  15544. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15545. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15546. */
  15547. constructor(
  15548. /**
  15549. * The radius of the emission sphere.
  15550. */
  15551. radius?: number,
  15552. /**
  15553. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15554. */
  15555. radiusRange?: number,
  15556. /**
  15557. * How much to randomize the particle direction [0-1].
  15558. */
  15559. directionRandomizer?: number);
  15560. /**
  15561. * Called by the particle System when the direction is computed for the created particle.
  15562. * @param worldMatrix is the world matrix of the particle system
  15563. * @param directionToUpdate is the direction vector to update with the result
  15564. * @param particle is the particle we are computed the direction for
  15565. */
  15566. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15567. /**
  15568. * Called by the particle System when the position is computed for the created particle.
  15569. * @param worldMatrix is the world matrix of the particle system
  15570. * @param positionToUpdate is the position vector to update with the result
  15571. * @param particle is the particle we are computed the position for
  15572. */
  15573. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15574. /**
  15575. * Clones the current emitter and returns a copy of it
  15576. * @returns the new emitter
  15577. */
  15578. clone(): SphereParticleEmitter;
  15579. /**
  15580. * Called by the GPUParticleSystem to setup the update shader
  15581. * @param effect defines the update shader
  15582. */
  15583. applyToShader(effect: Effect): void;
  15584. /**
  15585. * Returns a string to use to update the GPU particles update shader
  15586. * @returns a string containng the defines string
  15587. */
  15588. getEffectDefines(): string;
  15589. /**
  15590. * Returns the string "SphereParticleEmitter"
  15591. * @returns a string containing the class name
  15592. */
  15593. getClassName(): string;
  15594. /**
  15595. * Serializes the particle system to a JSON object.
  15596. * @returns the JSON object
  15597. */
  15598. serialize(): any;
  15599. /**
  15600. * Parse properties from a JSON object
  15601. * @param serializationObject defines the JSON object
  15602. */
  15603. parse(serializationObject: any): void;
  15604. }
  15605. /**
  15606. * Particle emitter emitting particles from the inside of a sphere.
  15607. * It emits the particles randomly between two vectors.
  15608. */
  15609. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15610. /**
  15611. * The min limit of the emission direction.
  15612. */
  15613. direction1: Vector3;
  15614. /**
  15615. * The max limit of the emission direction.
  15616. */
  15617. direction2: Vector3;
  15618. /**
  15619. * Creates a new instance SphereDirectedParticleEmitter
  15620. * @param radius the radius of the emission sphere (1 by default)
  15621. * @param direction1 the min limit of the emission direction (up vector by default)
  15622. * @param direction2 the max limit of the emission direction (up vector by default)
  15623. */
  15624. constructor(radius?: number,
  15625. /**
  15626. * The min limit of the emission direction.
  15627. */
  15628. direction1?: Vector3,
  15629. /**
  15630. * The max limit of the emission direction.
  15631. */
  15632. direction2?: Vector3);
  15633. /**
  15634. * Called by the particle System when the direction is computed for the created particle.
  15635. * @param worldMatrix is the world matrix of the particle system
  15636. * @param directionToUpdate is the direction vector to update with the result
  15637. * @param particle is the particle we are computed the direction for
  15638. */
  15639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15640. /**
  15641. * Clones the current emitter and returns a copy of it
  15642. * @returns the new emitter
  15643. */
  15644. clone(): SphereDirectedParticleEmitter;
  15645. /**
  15646. * Called by the GPUParticleSystem to setup the update shader
  15647. * @param effect defines the update shader
  15648. */
  15649. applyToShader(effect: Effect): void;
  15650. /**
  15651. * Returns a string to use to update the GPU particles update shader
  15652. * @returns a string containng the defines string
  15653. */
  15654. getEffectDefines(): string;
  15655. /**
  15656. * Returns the string "SphereDirectedParticleEmitter"
  15657. * @returns a string containing the class name
  15658. */
  15659. getClassName(): string;
  15660. /**
  15661. * Serializes the particle system to a JSON object.
  15662. * @returns the JSON object
  15663. */
  15664. serialize(): any;
  15665. /**
  15666. * Parse properties from a JSON object
  15667. * @param serializationObject defines the JSON object
  15668. */
  15669. parse(serializationObject: any): void;
  15670. }
  15671. }
  15672. declare module "babylonjs/Particles/EmitterTypes/index" {
  15673. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15674. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15675. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15676. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15677. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15678. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15679. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15680. }
  15681. declare module "babylonjs/Particles/IParticleSystem" {
  15682. import { Nullable } from "babylonjs/types";
  15683. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15686. import { Texture } from "babylonjs/Materials/Textures/texture";
  15687. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15688. import { Scene } from "babylonjs/scene";
  15689. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15690. import { Animation } from "babylonjs/Animations/animation";
  15691. /**
  15692. * Interface representing a particle system in Babylon.js.
  15693. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15694. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15695. */
  15696. export interface IParticleSystem {
  15697. /**
  15698. * List of animations used by the particle system.
  15699. */
  15700. animations: Animation[];
  15701. /**
  15702. * The id of the Particle system.
  15703. */
  15704. id: string;
  15705. /**
  15706. * The name of the Particle system.
  15707. */
  15708. name: string;
  15709. /**
  15710. * The emitter represents the Mesh or position we are attaching the particle system to.
  15711. */
  15712. emitter: Nullable<AbstractMesh | Vector3>;
  15713. /**
  15714. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15715. */
  15716. isBillboardBased: boolean;
  15717. /**
  15718. * The rendering group used by the Particle system to chose when to render.
  15719. */
  15720. renderingGroupId: number;
  15721. /**
  15722. * The layer mask we are rendering the particles through.
  15723. */
  15724. layerMask: number;
  15725. /**
  15726. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15727. */
  15728. updateSpeed: number;
  15729. /**
  15730. * The amount of time the particle system is running (depends of the overall update speed).
  15731. */
  15732. targetStopDuration: number;
  15733. /**
  15734. * The texture used to render each particle. (this can be a spritesheet)
  15735. */
  15736. particleTexture: Nullable<Texture>;
  15737. /**
  15738. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15739. */
  15740. blendMode: number;
  15741. /**
  15742. * Minimum life time of emitting particles.
  15743. */
  15744. minLifeTime: number;
  15745. /**
  15746. * Maximum life time of emitting particles.
  15747. */
  15748. maxLifeTime: number;
  15749. /**
  15750. * Minimum Size of emitting particles.
  15751. */
  15752. minSize: number;
  15753. /**
  15754. * Maximum Size of emitting particles.
  15755. */
  15756. maxSize: number;
  15757. /**
  15758. * Minimum scale of emitting particles on X axis.
  15759. */
  15760. minScaleX: number;
  15761. /**
  15762. * Maximum scale of emitting particles on X axis.
  15763. */
  15764. maxScaleX: number;
  15765. /**
  15766. * Minimum scale of emitting particles on Y axis.
  15767. */
  15768. minScaleY: number;
  15769. /**
  15770. * Maximum scale of emitting particles on Y axis.
  15771. */
  15772. maxScaleY: number;
  15773. /**
  15774. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15775. */
  15776. color1: Color4;
  15777. /**
  15778. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15779. */
  15780. color2: Color4;
  15781. /**
  15782. * Color the particle will have at the end of its lifetime.
  15783. */
  15784. colorDead: Color4;
  15785. /**
  15786. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15787. */
  15788. emitRate: number;
  15789. /**
  15790. * You can use gravity if you want to give an orientation to your particles.
  15791. */
  15792. gravity: Vector3;
  15793. /**
  15794. * Minimum power of emitting particles.
  15795. */
  15796. minEmitPower: number;
  15797. /**
  15798. * Maximum power of emitting particles.
  15799. */
  15800. maxEmitPower: number;
  15801. /**
  15802. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15803. */
  15804. minAngularSpeed: number;
  15805. /**
  15806. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15807. */
  15808. maxAngularSpeed: number;
  15809. /**
  15810. * Gets or sets the minimal initial rotation in radians.
  15811. */
  15812. minInitialRotation: number;
  15813. /**
  15814. * Gets or sets the maximal initial rotation in radians.
  15815. */
  15816. maxInitialRotation: number;
  15817. /**
  15818. * The particle emitter type defines the emitter used by the particle system.
  15819. * It can be for example box, sphere, or cone...
  15820. */
  15821. particleEmitterType: Nullable<IParticleEmitterType>;
  15822. /**
  15823. * Defines the delay in milliseconds before starting the system (0 by default)
  15824. */
  15825. startDelay: number;
  15826. /**
  15827. * 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
  15828. */
  15829. preWarmCycles: number;
  15830. /**
  15831. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15832. */
  15833. preWarmStepOffset: number;
  15834. /**
  15835. * 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)
  15836. */
  15837. spriteCellChangeSpeed: number;
  15838. /**
  15839. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15840. */
  15841. startSpriteCellID: number;
  15842. /**
  15843. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15844. */
  15845. endSpriteCellID: number;
  15846. /**
  15847. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15848. */
  15849. spriteCellWidth: number;
  15850. /**
  15851. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15852. */
  15853. spriteCellHeight: number;
  15854. /**
  15855. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15856. */
  15857. spriteRandomStartCell: boolean;
  15858. /**
  15859. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15860. */
  15861. isAnimationSheetEnabled: boolean;
  15862. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15863. translationPivot: Vector2;
  15864. /**
  15865. * Gets or sets a texture used to add random noise to particle positions
  15866. */
  15867. noiseTexture: Nullable<BaseTexture>;
  15868. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15869. noiseStrength: Vector3;
  15870. /**
  15871. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15872. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15873. */
  15874. billboardMode: number;
  15875. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15876. limitVelocityDamping: number;
  15877. /**
  15878. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15879. */
  15880. beginAnimationOnStart: boolean;
  15881. /**
  15882. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15883. */
  15884. beginAnimationFrom: number;
  15885. /**
  15886. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15887. */
  15888. beginAnimationTo: number;
  15889. /**
  15890. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15891. */
  15892. beginAnimationLoop: boolean;
  15893. /**
  15894. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15895. */
  15896. disposeOnStop: boolean;
  15897. /**
  15898. * Gets the maximum number of particles active at the same time.
  15899. * @returns The max number of active particles.
  15900. */
  15901. getCapacity(): number;
  15902. /**
  15903. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15904. * @returns True if it has been started, otherwise false.
  15905. */
  15906. isStarted(): boolean;
  15907. /**
  15908. * Animates the particle system for this frame.
  15909. */
  15910. animate(): void;
  15911. /**
  15912. * Renders the particle system in its current state.
  15913. * @returns the current number of particles
  15914. */
  15915. render(): number;
  15916. /**
  15917. * Dispose the particle system and frees its associated resources.
  15918. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15919. */
  15920. dispose(disposeTexture?: boolean): void;
  15921. /**
  15922. * Clones the particle system.
  15923. * @param name The name of the cloned object
  15924. * @param newEmitter The new emitter to use
  15925. * @returns the cloned particle system
  15926. */
  15927. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15928. /**
  15929. * Serializes the particle system to a JSON object.
  15930. * @returns the JSON object
  15931. */
  15932. serialize(): any;
  15933. /**
  15934. * Rebuild the particle system
  15935. */
  15936. rebuild(): void;
  15937. /**
  15938. * Starts the particle system and begins to emit
  15939. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15940. */
  15941. start(delay?: number): void;
  15942. /**
  15943. * Stops the particle system.
  15944. */
  15945. stop(): void;
  15946. /**
  15947. * Remove all active particles
  15948. */
  15949. reset(): void;
  15950. /**
  15951. * Is this system ready to be used/rendered
  15952. * @return true if the system is ready
  15953. */
  15954. isReady(): boolean;
  15955. /**
  15956. * Adds a new color gradient
  15957. * @param gradient defines the gradient to use (between 0 and 1)
  15958. * @param color1 defines the color to affect to the specified gradient
  15959. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15960. * @returns the current particle system
  15961. */
  15962. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15963. /**
  15964. * Remove a specific color gradient
  15965. * @param gradient defines the gradient to remove
  15966. * @returns the current particle system
  15967. */
  15968. removeColorGradient(gradient: number): IParticleSystem;
  15969. /**
  15970. * Adds a new size gradient
  15971. * @param gradient defines the gradient to use (between 0 and 1)
  15972. * @param factor defines the size factor to affect to the specified gradient
  15973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15974. * @returns the current particle system
  15975. */
  15976. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15977. /**
  15978. * Remove a specific size gradient
  15979. * @param gradient defines the gradient to remove
  15980. * @returns the current particle system
  15981. */
  15982. removeSizeGradient(gradient: number): IParticleSystem;
  15983. /**
  15984. * Gets the current list of color gradients.
  15985. * You must use addColorGradient and removeColorGradient to udpate this list
  15986. * @returns the list of color gradients
  15987. */
  15988. getColorGradients(): Nullable<Array<ColorGradient>>;
  15989. /**
  15990. * Gets the current list of size gradients.
  15991. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15992. * @returns the list of size gradients
  15993. */
  15994. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15995. /**
  15996. * Gets the current list of angular speed gradients.
  15997. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15998. * @returns the list of angular speed gradients
  15999. */
  16000. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16001. /**
  16002. * Adds a new angular speed gradient
  16003. * @param gradient defines the gradient to use (between 0 and 1)
  16004. * @param factor defines the angular speed to affect to the specified gradient
  16005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16006. * @returns the current particle system
  16007. */
  16008. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16009. /**
  16010. * Remove a specific angular speed gradient
  16011. * @param gradient defines the gradient to remove
  16012. * @returns the current particle system
  16013. */
  16014. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16015. /**
  16016. * Gets the current list of velocity gradients.
  16017. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16018. * @returns the list of velocity gradients
  16019. */
  16020. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16021. /**
  16022. * Adds a new velocity gradient
  16023. * @param gradient defines the gradient to use (between 0 and 1)
  16024. * @param factor defines the velocity to affect to the specified gradient
  16025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16026. * @returns the current particle system
  16027. */
  16028. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16029. /**
  16030. * Remove a specific velocity gradient
  16031. * @param gradient defines the gradient to remove
  16032. * @returns the current particle system
  16033. */
  16034. removeVelocityGradient(gradient: number): IParticleSystem;
  16035. /**
  16036. * Gets the current list of limit velocity gradients.
  16037. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16038. * @returns the list of limit velocity gradients
  16039. */
  16040. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16041. /**
  16042. * Adds a new limit velocity gradient
  16043. * @param gradient defines the gradient to use (between 0 and 1)
  16044. * @param factor defines the limit velocity to affect to the specified gradient
  16045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16046. * @returns the current particle system
  16047. */
  16048. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16049. /**
  16050. * Remove a specific limit velocity gradient
  16051. * @param gradient defines the gradient to remove
  16052. * @returns the current particle system
  16053. */
  16054. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16055. /**
  16056. * Adds a new drag gradient
  16057. * @param gradient defines the gradient to use (between 0 and 1)
  16058. * @param factor defines the drag to affect to the specified gradient
  16059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16060. * @returns the current particle system
  16061. */
  16062. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16063. /**
  16064. * Remove a specific drag gradient
  16065. * @param gradient defines the gradient to remove
  16066. * @returns the current particle system
  16067. */
  16068. removeDragGradient(gradient: number): IParticleSystem;
  16069. /**
  16070. * Gets the current list of drag gradients.
  16071. * You must use addDragGradient and removeDragGradient to udpate this list
  16072. * @returns the list of drag gradients
  16073. */
  16074. getDragGradients(): Nullable<Array<FactorGradient>>;
  16075. /**
  16076. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16077. * @param gradient defines the gradient to use (between 0 and 1)
  16078. * @param factor defines the emit rate to affect to the specified gradient
  16079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16080. * @returns the current particle system
  16081. */
  16082. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16083. /**
  16084. * Remove a specific emit rate gradient
  16085. * @param gradient defines the gradient to remove
  16086. * @returns the current particle system
  16087. */
  16088. removeEmitRateGradient(gradient: number): IParticleSystem;
  16089. /**
  16090. * Gets the current list of emit rate gradients.
  16091. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16092. * @returns the list of emit rate gradients
  16093. */
  16094. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16095. /**
  16096. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16097. * @param gradient defines the gradient to use (between 0 and 1)
  16098. * @param factor defines the start size to affect to the specified gradient
  16099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16100. * @returns the current particle system
  16101. */
  16102. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16103. /**
  16104. * Remove a specific start size gradient
  16105. * @param gradient defines the gradient to remove
  16106. * @returns the current particle system
  16107. */
  16108. removeStartSizeGradient(gradient: number): IParticleSystem;
  16109. /**
  16110. * Gets the current list of start size gradients.
  16111. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16112. * @returns the list of start size gradients
  16113. */
  16114. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16115. /**
  16116. * Adds a new life time gradient
  16117. * @param gradient defines the gradient to use (between 0 and 1)
  16118. * @param factor defines the life time factor to affect to the specified gradient
  16119. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16120. * @returns the current particle system
  16121. */
  16122. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16123. /**
  16124. * Remove a specific life time gradient
  16125. * @param gradient defines the gradient to remove
  16126. * @returns the current particle system
  16127. */
  16128. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16129. /**
  16130. * Gets the current list of life time gradients.
  16131. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16132. * @returns the list of life time gradients
  16133. */
  16134. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16135. /**
  16136. * Gets the current list of color gradients.
  16137. * You must use addColorGradient and removeColorGradient to udpate this list
  16138. * @returns the list of color gradients
  16139. */
  16140. getColorGradients(): Nullable<Array<ColorGradient>>;
  16141. /**
  16142. * Adds a new ramp gradient used to remap particle colors
  16143. * @param gradient defines the gradient to use (between 0 and 1)
  16144. * @param color defines the color to affect to the specified gradient
  16145. * @returns the current particle system
  16146. */
  16147. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16148. /**
  16149. * Gets the current list of ramp gradients.
  16150. * You must use addRampGradient and removeRampGradient to udpate this list
  16151. * @returns the list of ramp gradients
  16152. */
  16153. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16154. /** Gets or sets a boolean indicating that ramp gradients must be used
  16155. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16156. */
  16157. useRampGradients: boolean;
  16158. /**
  16159. * Adds a new color remap gradient
  16160. * @param gradient defines the gradient to use (between 0 and 1)
  16161. * @param min defines the color remap minimal range
  16162. * @param max defines the color remap maximal range
  16163. * @returns the current particle system
  16164. */
  16165. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16166. /**
  16167. * Gets the current list of color remap gradients.
  16168. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16169. * @returns the list of color remap gradients
  16170. */
  16171. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16172. /**
  16173. * Adds a new alpha remap gradient
  16174. * @param gradient defines the gradient to use (between 0 and 1)
  16175. * @param min defines the alpha remap minimal range
  16176. * @param max defines the alpha remap maximal range
  16177. * @returns the current particle system
  16178. */
  16179. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16180. /**
  16181. * Gets the current list of alpha remap gradients.
  16182. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16183. * @returns the list of alpha remap gradients
  16184. */
  16185. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16186. /**
  16187. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16188. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16189. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16190. * @returns the emitter
  16191. */
  16192. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16193. /**
  16194. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16195. * @param radius The radius of the hemisphere to emit from
  16196. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16197. * @returns the emitter
  16198. */
  16199. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16200. /**
  16201. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16202. * @param radius The radius of the sphere to emit from
  16203. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16204. * @returns the emitter
  16205. */
  16206. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16207. /**
  16208. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16209. * @param radius The radius of the sphere to emit from
  16210. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16211. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16212. * @returns the emitter
  16213. */
  16214. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16215. /**
  16216. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16217. * @param radius The radius of the emission cylinder
  16218. * @param height The height of the emission cylinder
  16219. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16220. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16221. * @returns the emitter
  16222. */
  16223. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16224. /**
  16225. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16226. * @param radius The radius of the cylinder to emit from
  16227. * @param height The height of the emission cylinder
  16228. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16229. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16230. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16231. * @returns the emitter
  16232. */
  16233. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16234. /**
  16235. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16236. * @param radius The radius of the cone to emit from
  16237. * @param angle The base angle of the cone
  16238. * @returns the emitter
  16239. */
  16240. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16241. /**
  16242. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16243. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16244. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16245. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16246. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16247. * @returns the emitter
  16248. */
  16249. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16250. /**
  16251. * Get hosting scene
  16252. * @returns the scene
  16253. */
  16254. getScene(): Scene;
  16255. }
  16256. }
  16257. declare module "babylonjs/Meshes/instancedMesh" {
  16258. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16259. import { Vector3 } from "babylonjs/Maths/math";
  16260. import { Camera } from "babylonjs/Cameras/camera";
  16261. import { Node } from "babylonjs/node";
  16262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16263. import { Mesh } from "babylonjs/Meshes/mesh";
  16264. import { Material } from "babylonjs/Materials/material";
  16265. import { Skeleton } from "babylonjs/Bones/skeleton";
  16266. /**
  16267. * Creates an instance based on a source mesh.
  16268. */
  16269. export class InstancedMesh extends AbstractMesh {
  16270. private _sourceMesh;
  16271. private _currentLOD;
  16272. /** @hidden */
  16273. _indexInSourceMeshInstanceArray: number;
  16274. constructor(name: string, source: Mesh);
  16275. /**
  16276. * Returns the string "InstancedMesh".
  16277. */
  16278. getClassName(): string;
  16279. /**
  16280. * If the source mesh receives shadows
  16281. */
  16282. readonly receiveShadows: boolean;
  16283. /**
  16284. * The material of the source mesh
  16285. */
  16286. readonly material: Nullable<Material>;
  16287. /**
  16288. * Visibility of the source mesh
  16289. */
  16290. readonly visibility: number;
  16291. /**
  16292. * Skeleton of the source mesh
  16293. */
  16294. readonly skeleton: Nullable<Skeleton>;
  16295. /**
  16296. * Rendering ground id of the source mesh
  16297. */
  16298. renderingGroupId: number;
  16299. /**
  16300. * Returns the total number of vertices (integer).
  16301. */
  16302. getTotalVertices(): number;
  16303. /**
  16304. * Returns a positive integer : the total number of indices in this mesh geometry.
  16305. * @returns the numner of indices or zero if the mesh has no geometry.
  16306. */
  16307. getTotalIndices(): number;
  16308. /**
  16309. * The source mesh of the instance
  16310. */
  16311. readonly sourceMesh: Mesh;
  16312. /**
  16313. * Is this node ready to be used/rendered
  16314. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16315. * @return {boolean} is it ready
  16316. */
  16317. isReady(completeCheck?: boolean): boolean;
  16318. /**
  16319. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16320. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16321. * @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.
  16322. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16323. */
  16324. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16325. /**
  16326. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16327. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16328. * The `data` are either a numeric array either a Float32Array.
  16329. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16330. * 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).
  16331. * Note that a new underlying VertexBuffer object is created each call.
  16332. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16333. *
  16334. * Possible `kind` values :
  16335. * - VertexBuffer.PositionKind
  16336. * - VertexBuffer.UVKind
  16337. * - VertexBuffer.UV2Kind
  16338. * - VertexBuffer.UV3Kind
  16339. * - VertexBuffer.UV4Kind
  16340. * - VertexBuffer.UV5Kind
  16341. * - VertexBuffer.UV6Kind
  16342. * - VertexBuffer.ColorKind
  16343. * - VertexBuffer.MatricesIndicesKind
  16344. * - VertexBuffer.MatricesIndicesExtraKind
  16345. * - VertexBuffer.MatricesWeightsKind
  16346. * - VertexBuffer.MatricesWeightsExtraKind
  16347. *
  16348. * Returns the Mesh.
  16349. */
  16350. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16351. /**
  16352. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16353. * If the mesh has no geometry, it is simply returned as it is.
  16354. * The `data` are either a numeric array either a Float32Array.
  16355. * No new underlying VertexBuffer object is created.
  16356. * 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.
  16357. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16358. *
  16359. * Possible `kind` values :
  16360. * - VertexBuffer.PositionKind
  16361. * - VertexBuffer.UVKind
  16362. * - VertexBuffer.UV2Kind
  16363. * - VertexBuffer.UV3Kind
  16364. * - VertexBuffer.UV4Kind
  16365. * - VertexBuffer.UV5Kind
  16366. * - VertexBuffer.UV6Kind
  16367. * - VertexBuffer.ColorKind
  16368. * - VertexBuffer.MatricesIndicesKind
  16369. * - VertexBuffer.MatricesIndicesExtraKind
  16370. * - VertexBuffer.MatricesWeightsKind
  16371. * - VertexBuffer.MatricesWeightsExtraKind
  16372. *
  16373. * Returns the Mesh.
  16374. */
  16375. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16376. /**
  16377. * Sets the mesh indices.
  16378. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16379. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16380. * This method creates a new index buffer each call.
  16381. * Returns the Mesh.
  16382. */
  16383. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16384. /**
  16385. * Boolean : True if the mesh owns the requested kind of data.
  16386. */
  16387. isVerticesDataPresent(kind: string): boolean;
  16388. /**
  16389. * Returns an array of indices (IndicesArray).
  16390. */
  16391. getIndices(): Nullable<IndicesArray>;
  16392. readonly _positions: Nullable<Vector3[]>;
  16393. /**
  16394. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16395. * This means the mesh underlying bounding box and sphere are recomputed.
  16396. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16397. * @returns the current mesh
  16398. */
  16399. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16400. /** @hidden */
  16401. _preActivate(): InstancedMesh;
  16402. /** @hidden */
  16403. _activate(renderId: number): InstancedMesh;
  16404. /**
  16405. * Returns the current associated LOD AbstractMesh.
  16406. */
  16407. getLOD(camera: Camera): AbstractMesh;
  16408. /** @hidden */
  16409. _syncSubMeshes(): InstancedMesh;
  16410. /** @hidden */
  16411. _generatePointsArray(): boolean;
  16412. /**
  16413. * Creates a new InstancedMesh from the current mesh.
  16414. * - name (string) : the cloned mesh name
  16415. * - newParent (optional Node) : the optional Node to parent the clone to.
  16416. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16417. *
  16418. * Returns the clone.
  16419. */
  16420. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16421. /**
  16422. * Disposes the InstancedMesh.
  16423. * Returns nothing.
  16424. */
  16425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16426. }
  16427. }
  16428. declare module "babylonjs/Materials/shaderMaterial" {
  16429. import { Scene } from "babylonjs/scene";
  16430. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16432. import { Mesh } from "babylonjs/Meshes/mesh";
  16433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16434. import { Texture } from "babylonjs/Materials/Textures/texture";
  16435. import { Material } from "babylonjs/Materials/material";
  16436. /**
  16437. * Defines the options associated with the creation of a shader material.
  16438. */
  16439. export interface IShaderMaterialOptions {
  16440. /**
  16441. * Does the material work in alpha blend mode
  16442. */
  16443. needAlphaBlending: boolean;
  16444. /**
  16445. * Does the material work in alpha test mode
  16446. */
  16447. needAlphaTesting: boolean;
  16448. /**
  16449. * The list of attribute names used in the shader
  16450. */
  16451. attributes: string[];
  16452. /**
  16453. * The list of unifrom names used in the shader
  16454. */
  16455. uniforms: string[];
  16456. /**
  16457. * The list of UBO names used in the shader
  16458. */
  16459. uniformBuffers: string[];
  16460. /**
  16461. * The list of sampler names used in the shader
  16462. */
  16463. samplers: string[];
  16464. /**
  16465. * The list of defines used in the shader
  16466. */
  16467. defines: string[];
  16468. }
  16469. /**
  16470. * 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.
  16471. *
  16472. * This returned material effects how the mesh will look based on the code in the shaders.
  16473. *
  16474. * @see http://doc.babylonjs.com/how_to/shader_material
  16475. */
  16476. export class ShaderMaterial extends Material {
  16477. private _shaderPath;
  16478. private _options;
  16479. private _textures;
  16480. private _textureArrays;
  16481. private _floats;
  16482. private _ints;
  16483. private _floatsArrays;
  16484. private _colors3;
  16485. private _colors3Arrays;
  16486. private _colors4;
  16487. private _vectors2;
  16488. private _vectors3;
  16489. private _vectors4;
  16490. private _matrices;
  16491. private _matrices3x3;
  16492. private _matrices2x2;
  16493. private _vectors2Arrays;
  16494. private _vectors3Arrays;
  16495. private _cachedWorldViewMatrix;
  16496. private _renderId;
  16497. /**
  16498. * Instantiate a new shader material.
  16499. * 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.
  16500. * This returned material effects how the mesh will look based on the code in the shaders.
  16501. * @see http://doc.babylonjs.com/how_to/shader_material
  16502. * @param name Define the name of the material in the scene
  16503. * @param scene Define the scene the material belongs to
  16504. * @param shaderPath Defines the route to the shader code in one of three ways:
  16505. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16506. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16507. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16508. * @param options Define the options used to create the shader
  16509. */
  16510. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16511. /**
  16512. * Gets the current class name of the material e.g. "ShaderMaterial"
  16513. * Mainly use in serialization.
  16514. * @returns the class name
  16515. */
  16516. getClassName(): string;
  16517. /**
  16518. * Specifies if the material will require alpha blending
  16519. * @returns a boolean specifying if alpha blending is needed
  16520. */
  16521. needAlphaBlending(): boolean;
  16522. /**
  16523. * Specifies if this material should be rendered in alpha test mode
  16524. * @returns a boolean specifying if an alpha test is needed.
  16525. */
  16526. needAlphaTesting(): boolean;
  16527. private _checkUniform;
  16528. /**
  16529. * Set a texture in the shader.
  16530. * @param name Define the name of the uniform samplers as defined in the shader
  16531. * @param texture Define the texture to bind to this sampler
  16532. * @return the material itself allowing "fluent" like uniform updates
  16533. */
  16534. setTexture(name: string, texture: Texture): ShaderMaterial;
  16535. /**
  16536. * Set a texture array in the shader.
  16537. * @param name Define the name of the uniform sampler array as defined in the shader
  16538. * @param textures Define the list of textures to bind to this sampler
  16539. * @return the material itself allowing "fluent" like uniform updates
  16540. */
  16541. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16542. /**
  16543. * Set a float in the shader.
  16544. * @param name Define the name of the uniform as defined in the shader
  16545. * @param value Define the value to give to the uniform
  16546. * @return the material itself allowing "fluent" like uniform updates
  16547. */
  16548. setFloat(name: string, value: number): ShaderMaterial;
  16549. /**
  16550. * Set a int in the shader.
  16551. * @param name Define the name of the uniform as defined in the shader
  16552. * @param value Define the value to give to the uniform
  16553. * @return the material itself allowing "fluent" like uniform updates
  16554. */
  16555. setInt(name: string, value: number): ShaderMaterial;
  16556. /**
  16557. * Set an array of floats in the shader.
  16558. * @param name Define the name of the uniform as defined in the shader
  16559. * @param value Define the value to give to the uniform
  16560. * @return the material itself allowing "fluent" like uniform updates
  16561. */
  16562. setFloats(name: string, value: number[]): ShaderMaterial;
  16563. /**
  16564. * Set a vec3 in the shader from a Color3.
  16565. * @param name Define the name of the uniform as defined in the shader
  16566. * @param value Define the value to give to the uniform
  16567. * @return the material itself allowing "fluent" like uniform updates
  16568. */
  16569. setColor3(name: string, value: Color3): ShaderMaterial;
  16570. /**
  16571. * Set a vec3 array in the shader from a Color3 array.
  16572. * @param name Define the name of the uniform as defined in the shader
  16573. * @param value Define the value to give to the uniform
  16574. * @return the material itself allowing "fluent" like uniform updates
  16575. */
  16576. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16577. /**
  16578. * Set a vec4 in the shader from a Color4.
  16579. * @param name Define the name of the uniform as defined in the shader
  16580. * @param value Define the value to give to the uniform
  16581. * @return the material itself allowing "fluent" like uniform updates
  16582. */
  16583. setColor4(name: string, value: Color4): ShaderMaterial;
  16584. /**
  16585. * Set a vec2 in the shader from a Vector2.
  16586. * @param name Define the name of the uniform as defined in the shader
  16587. * @param value Define the value to give to the uniform
  16588. * @return the material itself allowing "fluent" like uniform updates
  16589. */
  16590. setVector2(name: string, value: Vector2): ShaderMaterial;
  16591. /**
  16592. * Set a vec3 in the shader from a Vector3.
  16593. * @param name Define the name of the uniform as defined in the shader
  16594. * @param value Define the value to give to the uniform
  16595. * @return the material itself allowing "fluent" like uniform updates
  16596. */
  16597. setVector3(name: string, value: Vector3): ShaderMaterial;
  16598. /**
  16599. * Set a vec4 in the shader from a Vector4.
  16600. * @param name Define the name of the uniform as defined in the shader
  16601. * @param value Define the value to give to the uniform
  16602. * @return the material itself allowing "fluent" like uniform updates
  16603. */
  16604. setVector4(name: string, value: Vector4): ShaderMaterial;
  16605. /**
  16606. * Set a mat4 in the shader from a Matrix.
  16607. * @param name Define the name of the uniform as defined in the shader
  16608. * @param value Define the value to give to the uniform
  16609. * @return the material itself allowing "fluent" like uniform updates
  16610. */
  16611. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16612. /**
  16613. * Set a mat3 in the shader from a Float32Array.
  16614. * @param name Define the name of the uniform as defined in the shader
  16615. * @param value Define the value to give to the uniform
  16616. * @return the material itself allowing "fluent" like uniform updates
  16617. */
  16618. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16619. /**
  16620. * Set a mat2 in the shader from a Float32Array.
  16621. * @param name Define the name of the uniform as defined in the shader
  16622. * @param value Define the value to give to the uniform
  16623. * @return the material itself allowing "fluent" like uniform updates
  16624. */
  16625. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16626. /**
  16627. * Set a vec2 array in the shader from a number array.
  16628. * @param name Define the name of the uniform as defined in the shader
  16629. * @param value Define the value to give to the uniform
  16630. * @return the material itself allowing "fluent" like uniform updates
  16631. */
  16632. setArray2(name: string, value: number[]): ShaderMaterial;
  16633. /**
  16634. * Set a vec3 array in the shader from a number array.
  16635. * @param name Define the name of the uniform as defined in the shader
  16636. * @param value Define the value to give to the uniform
  16637. * @return the material itself allowing "fluent" like uniform updates
  16638. */
  16639. setArray3(name: string, value: number[]): ShaderMaterial;
  16640. private _checkCache;
  16641. /**
  16642. * Checks if the material is ready to render the requested mesh
  16643. * @param mesh Define the mesh to render
  16644. * @param useInstances Define whether or not the material is used with instances
  16645. * @returns true if ready, otherwise false
  16646. */
  16647. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16648. /**
  16649. * Binds the world matrix to the material
  16650. * @param world defines the world transformation matrix
  16651. */
  16652. bindOnlyWorldMatrix(world: Matrix): void;
  16653. /**
  16654. * Binds the material to the mesh
  16655. * @param world defines the world transformation matrix
  16656. * @param mesh defines the mesh to bind the material to
  16657. */
  16658. bind(world: Matrix, mesh?: Mesh): void;
  16659. /**
  16660. * Gets the active textures from the material
  16661. * @returns an array of textures
  16662. */
  16663. getActiveTextures(): BaseTexture[];
  16664. /**
  16665. * Specifies if the material uses a texture
  16666. * @param texture defines the texture to check against the material
  16667. * @returns a boolean specifying if the material uses the texture
  16668. */
  16669. hasTexture(texture: BaseTexture): boolean;
  16670. /**
  16671. * Makes a duplicate of the material, and gives it a new name
  16672. * @param name defines the new name for the duplicated material
  16673. * @returns the cloned material
  16674. */
  16675. clone(name: string): ShaderMaterial;
  16676. /**
  16677. * Disposes the material
  16678. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16679. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16680. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16681. */
  16682. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16683. /**
  16684. * Serializes this material in a JSON representation
  16685. * @returns the serialized material object
  16686. */
  16687. serialize(): any;
  16688. /**
  16689. * Creates a shader material from parsed shader material data
  16690. * @param source defines the JSON represnetation of the material
  16691. * @param scene defines the hosting scene
  16692. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16693. * @returns a new material
  16694. */
  16695. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16696. }
  16697. }
  16698. declare module "babylonjs/Shaders/color.fragment" {
  16699. /** @hidden */
  16700. export var colorPixelShader: {
  16701. name: string;
  16702. shader: string;
  16703. };
  16704. }
  16705. declare module "babylonjs/Shaders/color.vertex" {
  16706. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16707. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16708. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16709. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16710. /** @hidden */
  16711. export var colorVertexShader: {
  16712. name: string;
  16713. shader: string;
  16714. };
  16715. }
  16716. declare module "babylonjs/Meshes/linesMesh" {
  16717. import { Nullable } from "babylonjs/types";
  16718. import { Scene } from "babylonjs/scene";
  16719. import { Color3 } from "babylonjs/Maths/math";
  16720. import { Node } from "babylonjs/node";
  16721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16722. import { Mesh } from "babylonjs/Meshes/mesh";
  16723. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16724. import { Effect } from "babylonjs/Materials/effect";
  16725. import { Material } from "babylonjs/Materials/material";
  16726. import "babylonjs/Shaders/color.fragment";
  16727. import "babylonjs/Shaders/color.vertex";
  16728. /**
  16729. * Line mesh
  16730. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16731. */
  16732. export class LinesMesh extends Mesh {
  16733. /**
  16734. * If vertex color should be applied to the mesh
  16735. */
  16736. useVertexColor?: boolean | undefined;
  16737. /**
  16738. * If vertex alpha should be applied to the mesh
  16739. */
  16740. useVertexAlpha?: boolean | undefined;
  16741. /**
  16742. * Color of the line (Default: White)
  16743. */
  16744. color: Color3;
  16745. /**
  16746. * Alpha of the line (Default: 1)
  16747. */
  16748. alpha: number;
  16749. /**
  16750. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16751. * This margin is expressed in world space coordinates, so its value may vary.
  16752. * Default value is 0.1
  16753. */
  16754. intersectionThreshold: number;
  16755. private _colorShader;
  16756. /**
  16757. * Creates a new LinesMesh
  16758. * @param name defines the name
  16759. * @param scene defines the hosting scene
  16760. * @param parent defines the parent mesh if any
  16761. * @param source defines the optional source LinesMesh used to clone data from
  16762. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16763. * When false, achieved by calling a clone(), also passing False.
  16764. * This will make creation of children, recursive.
  16765. * @param useVertexColor defines if this LinesMesh supports vertex color
  16766. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16767. */
  16768. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16769. /**
  16770. * If vertex color should be applied to the mesh
  16771. */
  16772. useVertexColor?: boolean | undefined,
  16773. /**
  16774. * If vertex alpha should be applied to the mesh
  16775. */
  16776. useVertexAlpha?: boolean | undefined);
  16777. /**
  16778. * Returns the string "LineMesh"
  16779. */
  16780. getClassName(): string;
  16781. /**
  16782. * @hidden
  16783. */
  16784. /**
  16785. * @hidden
  16786. */
  16787. material: Material;
  16788. /**
  16789. * @hidden
  16790. */
  16791. readonly checkCollisions: boolean;
  16792. /** @hidden */
  16793. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16794. /** @hidden */
  16795. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16796. /**
  16797. * Disposes of the line mesh
  16798. * @param doNotRecurse If children should be disposed
  16799. */
  16800. dispose(doNotRecurse?: boolean): void;
  16801. /**
  16802. * Returns a new LineMesh object cloned from the current one.
  16803. */
  16804. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16805. /**
  16806. * Creates a new InstancedLinesMesh object from the mesh model.
  16807. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16808. * @param name defines the name of the new instance
  16809. * @returns a new InstancedLinesMesh
  16810. */
  16811. createInstance(name: string): InstancedLinesMesh;
  16812. }
  16813. /**
  16814. * Creates an instance based on a source LinesMesh
  16815. */
  16816. export class InstancedLinesMesh extends InstancedMesh {
  16817. /**
  16818. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16819. * This margin is expressed in world space coordinates, so its value may vary.
  16820. * Initilized with the intersectionThreshold value of the source LinesMesh
  16821. */
  16822. intersectionThreshold: number;
  16823. constructor(name: string, source: LinesMesh);
  16824. /**
  16825. * Returns the string "InstancedLinesMesh".
  16826. */
  16827. getClassName(): string;
  16828. }
  16829. }
  16830. declare module "babylonjs/Shaders/line.fragment" {
  16831. /** @hidden */
  16832. export var linePixelShader: {
  16833. name: string;
  16834. shader: string;
  16835. };
  16836. }
  16837. declare module "babylonjs/Shaders/line.vertex" {
  16838. /** @hidden */
  16839. export var lineVertexShader: {
  16840. name: string;
  16841. shader: string;
  16842. };
  16843. }
  16844. declare module "babylonjs/Rendering/edgesRenderer" {
  16845. import { Nullable } from "babylonjs/types";
  16846. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16848. import { Vector3 } from "babylonjs/Maths/math";
  16849. import { IDisposable } from "babylonjs/scene";
  16850. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16851. import "babylonjs/Shaders/line.fragment";
  16852. import "babylonjs/Shaders/line.vertex";
  16853. module "babylonjs/Meshes/abstractMesh" {
  16854. interface AbstractMesh {
  16855. /**
  16856. * Disables the mesh edge rendering mode
  16857. * @returns the currentAbstractMesh
  16858. */
  16859. disableEdgesRendering(): AbstractMesh;
  16860. /**
  16861. * Enables the edge rendering mode on the mesh.
  16862. * This mode makes the mesh edges visible
  16863. * @param epsilon defines the maximal distance between two angles to detect a face
  16864. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16865. * @returns the currentAbstractMesh
  16866. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16867. */
  16868. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16869. /**
  16870. * Gets the edgesRenderer associated with the mesh
  16871. */
  16872. edgesRenderer: Nullable<EdgesRenderer>;
  16873. }
  16874. }
  16875. module "babylonjs/Meshes/linesMesh" {
  16876. interface LinesMesh {
  16877. /**
  16878. * Enables the edge rendering mode on the mesh.
  16879. * This mode makes the mesh edges visible
  16880. * @param epsilon defines the maximal distance between two angles to detect a face
  16881. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16882. * @returns the currentAbstractMesh
  16883. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16884. */
  16885. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16886. }
  16887. }
  16888. module "babylonjs/Meshes/linesMesh" {
  16889. interface InstancedLinesMesh {
  16890. /**
  16891. * Enables the edge rendering mode on the mesh.
  16892. * This mode makes the mesh edges visible
  16893. * @param epsilon defines the maximal distance between two angles to detect a face
  16894. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16895. * @returns the current InstancedLinesMesh
  16896. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16897. */
  16898. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16899. }
  16900. }
  16901. /**
  16902. * Defines the minimum contract an Edges renderer should follow.
  16903. */
  16904. export interface IEdgesRenderer extends IDisposable {
  16905. /**
  16906. * Gets or sets a boolean indicating if the edgesRenderer is active
  16907. */
  16908. isEnabled: boolean;
  16909. /**
  16910. * Renders the edges of the attached mesh,
  16911. */
  16912. render(): void;
  16913. /**
  16914. * Checks wether or not the edges renderer is ready to render.
  16915. * @return true if ready, otherwise false.
  16916. */
  16917. isReady(): boolean;
  16918. }
  16919. /**
  16920. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16921. */
  16922. export class EdgesRenderer implements IEdgesRenderer {
  16923. /**
  16924. * Define the size of the edges with an orthographic camera
  16925. */
  16926. edgesWidthScalerForOrthographic: number;
  16927. /**
  16928. * Define the size of the edges with a perspective camera
  16929. */
  16930. edgesWidthScalerForPerspective: number;
  16931. protected _source: AbstractMesh;
  16932. protected _linesPositions: number[];
  16933. protected _linesNormals: number[];
  16934. protected _linesIndices: number[];
  16935. protected _epsilon: number;
  16936. protected _indicesCount: number;
  16937. protected _lineShader: ShaderMaterial;
  16938. protected _ib: WebGLBuffer;
  16939. protected _buffers: {
  16940. [key: string]: Nullable<VertexBuffer>;
  16941. };
  16942. protected _checkVerticesInsteadOfIndices: boolean;
  16943. private _meshRebuildObserver;
  16944. private _meshDisposeObserver;
  16945. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16946. isEnabled: boolean;
  16947. /**
  16948. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16949. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16950. * @param source Mesh used to create edges
  16951. * @param epsilon sum of angles in adjacency to check for edge
  16952. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16953. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16954. */
  16955. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16956. protected _prepareRessources(): void;
  16957. /** @hidden */
  16958. _rebuild(): void;
  16959. /**
  16960. * Releases the required resources for the edges renderer
  16961. */
  16962. dispose(): void;
  16963. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16964. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16965. /**
  16966. * Checks if the pair of p0 and p1 is en edge
  16967. * @param faceIndex
  16968. * @param edge
  16969. * @param faceNormals
  16970. * @param p0
  16971. * @param p1
  16972. * @private
  16973. */
  16974. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16975. /**
  16976. * push line into the position, normal and index buffer
  16977. * @protected
  16978. */
  16979. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16980. /**
  16981. * Generates lines edges from adjacencjes
  16982. * @private
  16983. */
  16984. _generateEdgesLines(): void;
  16985. /**
  16986. * Checks wether or not the edges renderer is ready to render.
  16987. * @return true if ready, otherwise false.
  16988. */
  16989. isReady(): boolean;
  16990. /**
  16991. * Renders the edges of the attached mesh,
  16992. */
  16993. render(): void;
  16994. }
  16995. /**
  16996. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16997. */
  16998. export class LineEdgesRenderer extends EdgesRenderer {
  16999. /**
  17000. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17001. * @param source LineMesh used to generate edges
  17002. * @param epsilon not important (specified angle for edge detection)
  17003. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17004. */
  17005. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17006. /**
  17007. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17008. */
  17009. _generateEdgesLines(): void;
  17010. }
  17011. }
  17012. declare module "babylonjs/Rendering/renderingGroup" {
  17013. import { SmartArray } from "babylonjs/Misc/smartArray";
  17014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17016. import { Nullable } from "babylonjs/types";
  17017. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17018. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17019. import { Material } from "babylonjs/Materials/material";
  17020. import { Scene } from "babylonjs/scene";
  17021. /**
  17022. * This represents the object necessary to create a rendering group.
  17023. * This is exclusively used and created by the rendering manager.
  17024. * To modify the behavior, you use the available helpers in your scene or meshes.
  17025. * @hidden
  17026. */
  17027. export class RenderingGroup {
  17028. index: number;
  17029. private _scene;
  17030. private _opaqueSubMeshes;
  17031. private _transparentSubMeshes;
  17032. private _alphaTestSubMeshes;
  17033. private _depthOnlySubMeshes;
  17034. private _particleSystems;
  17035. private _spriteManagers;
  17036. private _opaqueSortCompareFn;
  17037. private _alphaTestSortCompareFn;
  17038. private _transparentSortCompareFn;
  17039. private _renderOpaque;
  17040. private _renderAlphaTest;
  17041. private _renderTransparent;
  17042. private _edgesRenderers;
  17043. onBeforeTransparentRendering: () => void;
  17044. /**
  17045. * Set the opaque sort comparison function.
  17046. * If null the sub meshes will be render in the order they were created
  17047. */
  17048. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17049. /**
  17050. * Set the alpha test sort comparison function.
  17051. * If null the sub meshes will be render in the order they were created
  17052. */
  17053. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17054. /**
  17055. * Set the transparent sort comparison function.
  17056. * If null the sub meshes will be render in the order they were created
  17057. */
  17058. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17059. /**
  17060. * Creates a new rendering group.
  17061. * @param index The rendering group index
  17062. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17063. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17064. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17065. */
  17066. 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>);
  17067. /**
  17068. * Render all the sub meshes contained in the group.
  17069. * @param customRenderFunction Used to override the default render behaviour of the group.
  17070. * @returns true if rendered some submeshes.
  17071. */
  17072. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17073. /**
  17074. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17075. * @param subMeshes The submeshes to render
  17076. */
  17077. private renderOpaqueSorted;
  17078. /**
  17079. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17080. * @param subMeshes The submeshes to render
  17081. */
  17082. private renderAlphaTestSorted;
  17083. /**
  17084. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17085. * @param subMeshes The submeshes to render
  17086. */
  17087. private renderTransparentSorted;
  17088. /**
  17089. * Renders the submeshes in a specified order.
  17090. * @param subMeshes The submeshes to sort before render
  17091. * @param sortCompareFn The comparison function use to sort
  17092. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17093. * @param transparent Specifies to activate blending if true
  17094. */
  17095. private static renderSorted;
  17096. /**
  17097. * Renders the submeshes in the order they were dispatched (no sort applied).
  17098. * @param subMeshes The submeshes to render
  17099. */
  17100. private static renderUnsorted;
  17101. /**
  17102. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17103. * are rendered back to front if in the same alpha index.
  17104. *
  17105. * @param a The first submesh
  17106. * @param b The second submesh
  17107. * @returns The result of the comparison
  17108. */
  17109. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17110. /**
  17111. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17112. * are rendered back to front.
  17113. *
  17114. * @param a The first submesh
  17115. * @param b The second submesh
  17116. * @returns The result of the comparison
  17117. */
  17118. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17119. /**
  17120. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17121. * are rendered front to back (prevent overdraw).
  17122. *
  17123. * @param a The first submesh
  17124. * @param b The second submesh
  17125. * @returns The result of the comparison
  17126. */
  17127. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17128. /**
  17129. * Resets the different lists of submeshes to prepare a new frame.
  17130. */
  17131. prepare(): void;
  17132. dispose(): void;
  17133. /**
  17134. * Inserts the submesh in its correct queue depending on its material.
  17135. * @param subMesh The submesh to dispatch
  17136. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17137. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17138. */
  17139. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17140. dispatchSprites(spriteManager: ISpriteManager): void;
  17141. dispatchParticles(particleSystem: IParticleSystem): void;
  17142. private _renderParticles;
  17143. private _renderSprites;
  17144. }
  17145. }
  17146. declare module "babylonjs/Rendering/renderingManager" {
  17147. import { Nullable } from "babylonjs/types";
  17148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17150. import { SmartArray } from "babylonjs/Misc/smartArray";
  17151. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17152. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17153. import { Material } from "babylonjs/Materials/material";
  17154. import { Scene } from "babylonjs/scene";
  17155. import { Camera } from "babylonjs/Cameras/camera";
  17156. /**
  17157. * Interface describing the different options available in the rendering manager
  17158. * regarding Auto Clear between groups.
  17159. */
  17160. export interface IRenderingManagerAutoClearSetup {
  17161. /**
  17162. * Defines whether or not autoclear is enable.
  17163. */
  17164. autoClear: boolean;
  17165. /**
  17166. * Defines whether or not to autoclear the depth buffer.
  17167. */
  17168. depth: boolean;
  17169. /**
  17170. * Defines whether or not to autoclear the stencil buffer.
  17171. */
  17172. stencil: boolean;
  17173. }
  17174. /**
  17175. * This class is used by the onRenderingGroupObservable
  17176. */
  17177. export class RenderingGroupInfo {
  17178. /**
  17179. * The Scene that being rendered
  17180. */
  17181. scene: Scene;
  17182. /**
  17183. * The camera currently used for the rendering pass
  17184. */
  17185. camera: Nullable<Camera>;
  17186. /**
  17187. * The ID of the renderingGroup being processed
  17188. */
  17189. renderingGroupId: number;
  17190. }
  17191. /**
  17192. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17193. * It is enable to manage the different groups as well as the different necessary sort functions.
  17194. * This should not be used directly aside of the few static configurations
  17195. */
  17196. export class RenderingManager {
  17197. /**
  17198. * The max id used for rendering groups (not included)
  17199. */
  17200. static MAX_RENDERINGGROUPS: number;
  17201. /**
  17202. * The min id used for rendering groups (included)
  17203. */
  17204. static MIN_RENDERINGGROUPS: number;
  17205. /**
  17206. * Used to globally prevent autoclearing scenes.
  17207. */
  17208. static AUTOCLEAR: boolean;
  17209. /**
  17210. * @hidden
  17211. */
  17212. _useSceneAutoClearSetup: boolean;
  17213. private _scene;
  17214. private _renderingGroups;
  17215. private _depthStencilBufferAlreadyCleaned;
  17216. private _autoClearDepthStencil;
  17217. private _customOpaqueSortCompareFn;
  17218. private _customAlphaTestSortCompareFn;
  17219. private _customTransparentSortCompareFn;
  17220. private _renderingGroupInfo;
  17221. /**
  17222. * Instantiates a new rendering group for a particular scene
  17223. * @param scene Defines the scene the groups belongs to
  17224. */
  17225. constructor(scene: Scene);
  17226. private _clearDepthStencilBuffer;
  17227. /**
  17228. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17229. * @hidden
  17230. */
  17231. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17232. /**
  17233. * Resets the different information of the group to prepare a new frame
  17234. * @hidden
  17235. */
  17236. reset(): void;
  17237. /**
  17238. * Dispose and release the group and its associated resources.
  17239. * @hidden
  17240. */
  17241. dispose(): void;
  17242. /**
  17243. * Clear the info related to rendering groups preventing retention points during dispose.
  17244. */
  17245. freeRenderingGroups(): void;
  17246. private _prepareRenderingGroup;
  17247. /**
  17248. * Add a sprite manager to the rendering manager in order to render it this frame.
  17249. * @param spriteManager Define the sprite manager to render
  17250. */
  17251. dispatchSprites(spriteManager: ISpriteManager): void;
  17252. /**
  17253. * Add a particle system to the rendering manager in order to render it this frame.
  17254. * @param particleSystem Define the particle system to render
  17255. */
  17256. dispatchParticles(particleSystem: IParticleSystem): void;
  17257. /**
  17258. * Add a submesh to the manager in order to render it this frame
  17259. * @param subMesh The submesh to dispatch
  17260. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17261. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17262. */
  17263. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17264. /**
  17265. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17266. * This allowed control for front to back rendering or reversly depending of the special needs.
  17267. *
  17268. * @param renderingGroupId The rendering group id corresponding to its index
  17269. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17270. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17271. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17272. */
  17273. 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;
  17274. /**
  17275. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17276. *
  17277. * @param renderingGroupId The rendering group id corresponding to its index
  17278. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17279. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17280. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17281. */
  17282. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17283. /**
  17284. * Gets the current auto clear configuration for one rendering group of the rendering
  17285. * manager.
  17286. * @param index the rendering group index to get the information for
  17287. * @returns The auto clear setup for the requested rendering group
  17288. */
  17289. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17290. }
  17291. }
  17292. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17293. import { Observable } from "babylonjs/Misc/observable";
  17294. import { SmartArray } from "babylonjs/Misc/smartArray";
  17295. import { Nullable } from "babylonjs/types";
  17296. import { Camera } from "babylonjs/Cameras/camera";
  17297. import { Scene } from "babylonjs/scene";
  17298. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17299. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17302. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17303. import { Texture } from "babylonjs/Materials/Textures/texture";
  17304. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17305. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17306. import { Engine } from "babylonjs/Engines/engine";
  17307. /**
  17308. * This Helps creating a texture that will be created from a camera in your scene.
  17309. * It is basically a dynamic texture that could be used to create special effects for instance.
  17310. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17311. */
  17312. export class RenderTargetTexture extends Texture {
  17313. isCube: boolean;
  17314. /**
  17315. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17316. */
  17317. static readonly REFRESHRATE_RENDER_ONCE: number;
  17318. /**
  17319. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17320. */
  17321. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17322. /**
  17323. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17324. * the central point of your effect and can save a lot of performances.
  17325. */
  17326. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17327. /**
  17328. * Use this predicate to dynamically define the list of mesh you want to render.
  17329. * If set, the renderList property will be overwritten.
  17330. */
  17331. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17332. private _renderList;
  17333. /**
  17334. * Use this list to define the list of mesh you want to render.
  17335. */
  17336. renderList: Nullable<Array<AbstractMesh>>;
  17337. private _hookArray;
  17338. /**
  17339. * Define if particles should be rendered in your texture.
  17340. */
  17341. renderParticles: boolean;
  17342. /**
  17343. * Define if sprites should be rendered in your texture.
  17344. */
  17345. renderSprites: boolean;
  17346. /**
  17347. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17348. */
  17349. coordinatesMode: number;
  17350. /**
  17351. * Define the camera used to render the texture.
  17352. */
  17353. activeCamera: Nullable<Camera>;
  17354. /**
  17355. * Override the render function of the texture with your own one.
  17356. */
  17357. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17358. /**
  17359. * Define if camera post processes should be use while rendering the texture.
  17360. */
  17361. useCameraPostProcesses: boolean;
  17362. /**
  17363. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17364. */
  17365. ignoreCameraViewport: boolean;
  17366. private _postProcessManager;
  17367. private _postProcesses;
  17368. private _resizeObserver;
  17369. /**
  17370. * An event triggered when the texture is unbind.
  17371. */
  17372. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17373. /**
  17374. * An event triggered when the texture is unbind.
  17375. */
  17376. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17377. private _onAfterUnbindObserver;
  17378. /**
  17379. * Set a after unbind callback in the texture.
  17380. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17381. */
  17382. onAfterUnbind: () => void;
  17383. /**
  17384. * An event triggered before rendering the texture
  17385. */
  17386. onBeforeRenderObservable: Observable<number>;
  17387. private _onBeforeRenderObserver;
  17388. /**
  17389. * Set a before render callback in the texture.
  17390. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17391. */
  17392. onBeforeRender: (faceIndex: number) => void;
  17393. /**
  17394. * An event triggered after rendering the texture
  17395. */
  17396. onAfterRenderObservable: Observable<number>;
  17397. private _onAfterRenderObserver;
  17398. /**
  17399. * Set a after render callback in the texture.
  17400. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17401. */
  17402. onAfterRender: (faceIndex: number) => void;
  17403. /**
  17404. * An event triggered after the texture clear
  17405. */
  17406. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17407. private _onClearObserver;
  17408. /**
  17409. * Set a clear callback in the texture.
  17410. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17411. */
  17412. onClear: (Engine: Engine) => void;
  17413. /**
  17414. * Define the clear color of the Render Target if it should be different from the scene.
  17415. */
  17416. clearColor: Color4;
  17417. protected _size: number | {
  17418. width: number;
  17419. height: number;
  17420. };
  17421. protected _initialSizeParameter: number | {
  17422. width: number;
  17423. height: number;
  17424. } | {
  17425. ratio: number;
  17426. };
  17427. protected _sizeRatio: Nullable<number>;
  17428. /** @hidden */
  17429. _generateMipMaps: boolean;
  17430. protected _renderingManager: RenderingManager;
  17431. /** @hidden */
  17432. _waitingRenderList: string[];
  17433. protected _doNotChangeAspectRatio: boolean;
  17434. protected _currentRefreshId: number;
  17435. protected _refreshRate: number;
  17436. protected _textureMatrix: Matrix;
  17437. protected _samples: number;
  17438. protected _renderTargetOptions: RenderTargetCreationOptions;
  17439. /**
  17440. * Gets render target creation options that were used.
  17441. */
  17442. readonly renderTargetOptions: RenderTargetCreationOptions;
  17443. protected _engine: Engine;
  17444. protected _onRatioRescale(): void;
  17445. /**
  17446. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17447. * It must define where the camera used to render the texture is set
  17448. */
  17449. boundingBoxPosition: Vector3;
  17450. private _boundingBoxSize;
  17451. /**
  17452. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17453. * When defined, the cubemap will switch to local mode
  17454. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17455. * @example https://www.babylonjs-playground.com/#RNASML
  17456. */
  17457. boundingBoxSize: Vector3;
  17458. /**
  17459. * In case the RTT has been created with a depth texture, get the associated
  17460. * depth texture.
  17461. * Otherwise, return null.
  17462. */
  17463. depthStencilTexture: Nullable<InternalTexture>;
  17464. /**
  17465. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17466. * or used a shadow, depth texture...
  17467. * @param name The friendly name of the texture
  17468. * @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)
  17469. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17470. * @param generateMipMaps True if mip maps need to be generated after render.
  17471. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17472. * @param type The type of the buffer in the RTT (int, half float, float...)
  17473. * @param isCube True if a cube texture needs to be created
  17474. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17475. * @param generateDepthBuffer True to generate a depth buffer
  17476. * @param generateStencilBuffer True to generate a stencil buffer
  17477. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17478. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17479. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17480. */
  17481. constructor(name: string, size: number | {
  17482. width: number;
  17483. height: number;
  17484. } | {
  17485. ratio: number;
  17486. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17487. /**
  17488. * Creates a depth stencil texture.
  17489. * This is only available in WebGL 2 or with the depth texture extension available.
  17490. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17491. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17492. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17493. */
  17494. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17495. private _processSizeParameter;
  17496. /**
  17497. * Define the number of samples to use in case of MSAA.
  17498. * It defaults to one meaning no MSAA has been enabled.
  17499. */
  17500. samples: number;
  17501. /**
  17502. * Resets the refresh counter of the texture and start bak from scratch.
  17503. * Could be useful to regenerate the texture if it is setup to render only once.
  17504. */
  17505. resetRefreshCounter(): void;
  17506. /**
  17507. * Define the refresh rate of the texture or the rendering frequency.
  17508. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17509. */
  17510. refreshRate: number;
  17511. /**
  17512. * Adds a post process to the render target rendering passes.
  17513. * @param postProcess define the post process to add
  17514. */
  17515. addPostProcess(postProcess: PostProcess): void;
  17516. /**
  17517. * Clear all the post processes attached to the render target
  17518. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17519. */
  17520. clearPostProcesses(dispose?: boolean): void;
  17521. /**
  17522. * Remove one of the post process from the list of attached post processes to the texture
  17523. * @param postProcess define the post process to remove from the list
  17524. */
  17525. removePostProcess(postProcess: PostProcess): void;
  17526. /** @hidden */
  17527. _shouldRender(): boolean;
  17528. /**
  17529. * Gets the actual render size of the texture.
  17530. * @returns the width of the render size
  17531. */
  17532. getRenderSize(): number;
  17533. /**
  17534. * Gets the actual render width of the texture.
  17535. * @returns the width of the render size
  17536. */
  17537. getRenderWidth(): number;
  17538. /**
  17539. * Gets the actual render height of the texture.
  17540. * @returns the height of the render size
  17541. */
  17542. getRenderHeight(): number;
  17543. /**
  17544. * Get if the texture can be rescaled or not.
  17545. */
  17546. readonly canRescale: boolean;
  17547. /**
  17548. * Resize the texture using a ratio.
  17549. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17550. */
  17551. scale(ratio: number): void;
  17552. /**
  17553. * Get the texture reflection matrix used to rotate/transform the reflection.
  17554. * @returns the reflection matrix
  17555. */
  17556. getReflectionTextureMatrix(): Matrix;
  17557. /**
  17558. * Resize the texture to a new desired size.
  17559. * Be carrefull as it will recreate all the data in the new texture.
  17560. * @param size Define the new size. It can be:
  17561. * - a number for squared texture,
  17562. * - an object containing { width: number, height: number }
  17563. * - or an object containing a ratio { ratio: number }
  17564. */
  17565. resize(size: number | {
  17566. width: number;
  17567. height: number;
  17568. } | {
  17569. ratio: number;
  17570. }): void;
  17571. /**
  17572. * Renders all the objects from the render list into the texture.
  17573. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17574. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17575. */
  17576. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17577. private _bestReflectionRenderTargetDimension;
  17578. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17579. private renderToTarget;
  17580. /**
  17581. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17582. * This allowed control for front to back rendering or reversly depending of the special needs.
  17583. *
  17584. * @param renderingGroupId The rendering group id corresponding to its index
  17585. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17586. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17587. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17588. */
  17589. 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;
  17590. /**
  17591. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17592. *
  17593. * @param renderingGroupId The rendering group id corresponding to its index
  17594. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17595. */
  17596. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17597. /**
  17598. * Clones the texture.
  17599. * @returns the cloned texture
  17600. */
  17601. clone(): RenderTargetTexture;
  17602. /**
  17603. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17604. * @returns The JSON representation of the texture
  17605. */
  17606. serialize(): any;
  17607. /**
  17608. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17609. */
  17610. disposeFramebufferObjects(): void;
  17611. /**
  17612. * Dispose the texture and release its associated resources.
  17613. */
  17614. dispose(): void;
  17615. /** @hidden */
  17616. _rebuild(): void;
  17617. /**
  17618. * Clear the info related to rendering groups preventing retention point in material dispose.
  17619. */
  17620. freeRenderingGroups(): void;
  17621. }
  17622. }
  17623. declare module "babylonjs/Materials/material" {
  17624. import { IAnimatable } from "babylonjs/Misc/tools";
  17625. import { SmartArray } from "babylonjs/Misc/smartArray";
  17626. import { Observable } from "babylonjs/Misc/observable";
  17627. import { Nullable } from "babylonjs/types";
  17628. import { Scene } from "babylonjs/scene";
  17629. import { Matrix } from "babylonjs/Maths/math";
  17630. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  17631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17632. import { Mesh } from "babylonjs/Meshes/mesh";
  17633. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17634. import { Effect } from "babylonjs/Materials/effect";
  17635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17636. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17637. import { Animation } from "babylonjs/Animations/animation";
  17638. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17639. /**
  17640. * Base class for the main features of a material in Babylon.js
  17641. */
  17642. export class Material implements IAnimatable {
  17643. /**
  17644. * Returns the triangle fill mode
  17645. */
  17646. static readonly TriangleFillMode: number;
  17647. /**
  17648. * Returns the wireframe mode
  17649. */
  17650. static readonly WireFrameFillMode: number;
  17651. /**
  17652. * Returns the point fill mode
  17653. */
  17654. static readonly PointFillMode: number;
  17655. /**
  17656. * Returns the point list draw mode
  17657. */
  17658. static readonly PointListDrawMode: number;
  17659. /**
  17660. * Returns the line list draw mode
  17661. */
  17662. static readonly LineListDrawMode: number;
  17663. /**
  17664. * Returns the line loop draw mode
  17665. */
  17666. static readonly LineLoopDrawMode: number;
  17667. /**
  17668. * Returns the line strip draw mode
  17669. */
  17670. static readonly LineStripDrawMode: number;
  17671. /**
  17672. * Returns the triangle strip draw mode
  17673. */
  17674. static readonly TriangleStripDrawMode: number;
  17675. /**
  17676. * Returns the triangle fan draw mode
  17677. */
  17678. static readonly TriangleFanDrawMode: number;
  17679. /**
  17680. * Stores the clock-wise side orientation
  17681. */
  17682. static readonly ClockWiseSideOrientation: number;
  17683. /**
  17684. * Stores the counter clock-wise side orientation
  17685. */
  17686. static readonly CounterClockWiseSideOrientation: number;
  17687. /**
  17688. * The dirty texture flag value
  17689. */
  17690. static readonly TextureDirtyFlag: number;
  17691. /**
  17692. * The dirty light flag value
  17693. */
  17694. static readonly LightDirtyFlag: number;
  17695. /**
  17696. * The dirty fresnel flag value
  17697. */
  17698. static readonly FresnelDirtyFlag: number;
  17699. /**
  17700. * The dirty attribute flag value
  17701. */
  17702. static readonly AttributesDirtyFlag: number;
  17703. /**
  17704. * The dirty misc flag value
  17705. */
  17706. static readonly MiscDirtyFlag: number;
  17707. /**
  17708. * The all dirty flag value
  17709. */
  17710. static readonly AllDirtyFlag: number;
  17711. /**
  17712. * The ID of the material
  17713. */
  17714. id: string;
  17715. /**
  17716. * Gets or sets the unique id of the material
  17717. */
  17718. uniqueId: number;
  17719. /**
  17720. * The name of the material
  17721. */
  17722. name: string;
  17723. /**
  17724. * Gets or sets user defined metadata
  17725. */
  17726. metadata: any;
  17727. /**
  17728. * For internal use only. Please do not use.
  17729. */
  17730. reservedDataStore: any;
  17731. /**
  17732. * Specifies if the ready state should be checked on each call
  17733. */
  17734. checkReadyOnEveryCall: boolean;
  17735. /**
  17736. * Specifies if the ready state should be checked once
  17737. */
  17738. checkReadyOnlyOnce: boolean;
  17739. /**
  17740. * The state of the material
  17741. */
  17742. state: string;
  17743. /**
  17744. * The alpha value of the material
  17745. */
  17746. protected _alpha: number;
  17747. /**
  17748. * Sets the alpha value of the material
  17749. */
  17750. /**
  17751. * Gets the alpha value of the material
  17752. */
  17753. alpha: number;
  17754. /**
  17755. * Specifies if back face culling is enabled
  17756. */
  17757. protected _backFaceCulling: boolean;
  17758. /**
  17759. * Sets the back-face culling state
  17760. */
  17761. /**
  17762. * Gets the back-face culling state
  17763. */
  17764. backFaceCulling: boolean;
  17765. /**
  17766. * Stores the value for side orientation
  17767. */
  17768. sideOrientation: number;
  17769. /**
  17770. * Callback triggered when the material is compiled
  17771. */
  17772. onCompiled: (effect: Effect) => void;
  17773. /**
  17774. * Callback triggered when an error occurs
  17775. */
  17776. onError: (effect: Effect, errors: string) => void;
  17777. /**
  17778. * Callback triggered to get the render target textures
  17779. */
  17780. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17781. /**
  17782. * Gets a boolean indicating that current material needs to register RTT
  17783. */
  17784. readonly hasRenderTargetTextures: boolean;
  17785. /**
  17786. * Specifies if the material should be serialized
  17787. */
  17788. doNotSerialize: boolean;
  17789. /**
  17790. * @hidden
  17791. */
  17792. _storeEffectOnSubMeshes: boolean;
  17793. /**
  17794. * Stores the animations for the material
  17795. */
  17796. animations: Array<Animation>;
  17797. /**
  17798. * An event triggered when the material is disposed
  17799. */
  17800. onDisposeObservable: Observable<Material>;
  17801. /**
  17802. * An observer which watches for dispose events
  17803. */
  17804. private _onDisposeObserver;
  17805. private _onUnBindObservable;
  17806. /**
  17807. * Called during a dispose event
  17808. */
  17809. onDispose: () => void;
  17810. private _onBindObservable;
  17811. /**
  17812. * An event triggered when the material is bound
  17813. */
  17814. readonly onBindObservable: Observable<AbstractMesh>;
  17815. /**
  17816. * An observer which watches for bind events
  17817. */
  17818. private _onBindObserver;
  17819. /**
  17820. * Called during a bind event
  17821. */
  17822. onBind: (Mesh: AbstractMesh) => void;
  17823. /**
  17824. * An event triggered when the material is unbound
  17825. */
  17826. readonly onUnBindObservable: Observable<Material>;
  17827. /**
  17828. * Stores the value of the alpha mode
  17829. */
  17830. private _alphaMode;
  17831. /**
  17832. * Sets the value of the alpha mode.
  17833. *
  17834. * | Value | Type | Description |
  17835. * | --- | --- | --- |
  17836. * | 0 | ALPHA_DISABLE | |
  17837. * | 1 | ALPHA_ADD | |
  17838. * | 2 | ALPHA_COMBINE | |
  17839. * | 3 | ALPHA_SUBTRACT | |
  17840. * | 4 | ALPHA_MULTIPLY | |
  17841. * | 5 | ALPHA_MAXIMIZED | |
  17842. * | 6 | ALPHA_ONEONE | |
  17843. * | 7 | ALPHA_PREMULTIPLIED | |
  17844. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17845. * | 9 | ALPHA_INTERPOLATE | |
  17846. * | 10 | ALPHA_SCREENMODE | |
  17847. *
  17848. */
  17849. /**
  17850. * Gets the value of the alpha mode
  17851. */
  17852. alphaMode: number;
  17853. /**
  17854. * Stores the state of the need depth pre-pass value
  17855. */
  17856. private _needDepthPrePass;
  17857. /**
  17858. * Sets the need depth pre-pass value
  17859. */
  17860. /**
  17861. * Gets the depth pre-pass value
  17862. */
  17863. needDepthPrePass: boolean;
  17864. /**
  17865. * Specifies if depth writing should be disabled
  17866. */
  17867. disableDepthWrite: boolean;
  17868. /**
  17869. * Specifies if depth writing should be forced
  17870. */
  17871. forceDepthWrite: boolean;
  17872. /**
  17873. * Specifies if there should be a separate pass for culling
  17874. */
  17875. separateCullingPass: boolean;
  17876. /**
  17877. * Stores the state specifing if fog should be enabled
  17878. */
  17879. private _fogEnabled;
  17880. /**
  17881. * Sets the state for enabling fog
  17882. */
  17883. /**
  17884. * Gets the value of the fog enabled state
  17885. */
  17886. fogEnabled: boolean;
  17887. /**
  17888. * Stores the size of points
  17889. */
  17890. pointSize: number;
  17891. /**
  17892. * Stores the z offset value
  17893. */
  17894. zOffset: number;
  17895. /**
  17896. * Gets a value specifying if wireframe mode is enabled
  17897. */
  17898. /**
  17899. * Sets the state of wireframe mode
  17900. */
  17901. wireframe: boolean;
  17902. /**
  17903. * Gets the value specifying if point clouds are enabled
  17904. */
  17905. /**
  17906. * Sets the state of point cloud mode
  17907. */
  17908. pointsCloud: boolean;
  17909. /**
  17910. * Gets the material fill mode
  17911. */
  17912. /**
  17913. * Sets the material fill mode
  17914. */
  17915. fillMode: number;
  17916. /**
  17917. * @hidden
  17918. * Stores the effects for the material
  17919. */
  17920. _effect: Nullable<Effect>;
  17921. /**
  17922. * @hidden
  17923. * Specifies if the material was previously ready
  17924. */
  17925. _wasPreviouslyReady: boolean;
  17926. /**
  17927. * Specifies if uniform buffers should be used
  17928. */
  17929. private _useUBO;
  17930. /**
  17931. * Stores a reference to the scene
  17932. */
  17933. private _scene;
  17934. /**
  17935. * Stores the fill mode state
  17936. */
  17937. private _fillMode;
  17938. /**
  17939. * Specifies if the depth write state should be cached
  17940. */
  17941. private _cachedDepthWriteState;
  17942. /**
  17943. * Stores the uniform buffer
  17944. */
  17945. protected _uniformBuffer: UniformBuffer;
  17946. /** @hidden */
  17947. _indexInSceneMaterialArray: number;
  17948. /** @hidden */
  17949. meshMap: Nullable<{
  17950. [id: string]: AbstractMesh | undefined;
  17951. }>;
  17952. /**
  17953. * Creates a material instance
  17954. * @param name defines the name of the material
  17955. * @param scene defines the scene to reference
  17956. * @param doNotAdd specifies if the material should be added to the scene
  17957. */
  17958. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17959. /**
  17960. * Returns a string representation of the current material
  17961. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17962. * @returns a string with material information
  17963. */
  17964. toString(fullDetails?: boolean): string;
  17965. /**
  17966. * Gets the class name of the material
  17967. * @returns a string with the class name of the material
  17968. */
  17969. getClassName(): string;
  17970. /**
  17971. * Specifies if updates for the material been locked
  17972. */
  17973. readonly isFrozen: boolean;
  17974. /**
  17975. * Locks updates for the material
  17976. */
  17977. freeze(): void;
  17978. /**
  17979. * Unlocks updates for the material
  17980. */
  17981. unfreeze(): void;
  17982. /**
  17983. * Specifies if the material is ready to be used
  17984. * @param mesh defines the mesh to check
  17985. * @param useInstances specifies if instances should be used
  17986. * @returns a boolean indicating if the material is ready to be used
  17987. */
  17988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17989. /**
  17990. * Specifies that the submesh is ready to be used
  17991. * @param mesh defines the mesh to check
  17992. * @param subMesh defines which submesh to check
  17993. * @param useInstances specifies that instances should be used
  17994. * @returns a boolean indicating that the submesh is ready or not
  17995. */
  17996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17997. /**
  17998. * Returns the material effect
  17999. * @returns the effect associated with the material
  18000. */
  18001. getEffect(): Nullable<Effect>;
  18002. /**
  18003. * Returns the current scene
  18004. * @returns a Scene
  18005. */
  18006. getScene(): Scene;
  18007. /**
  18008. * Specifies if the material will require alpha blending
  18009. * @returns a boolean specifying if alpha blending is needed
  18010. */
  18011. needAlphaBlending(): boolean;
  18012. /**
  18013. * Specifies if the mesh will require alpha blending
  18014. * @param mesh defines the mesh to check
  18015. * @returns a boolean specifying if alpha blending is needed for the mesh
  18016. */
  18017. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18018. /**
  18019. * Specifies if this material should be rendered in alpha test mode
  18020. * @returns a boolean specifying if an alpha test is needed.
  18021. */
  18022. needAlphaTesting(): boolean;
  18023. /**
  18024. * Gets the texture used for the alpha test
  18025. * @returns the texture to use for alpha testing
  18026. */
  18027. getAlphaTestTexture(): Nullable<BaseTexture>;
  18028. /**
  18029. * Marks the material to indicate that it needs to be re-calculated
  18030. */
  18031. markDirty(): void;
  18032. /** @hidden */
  18033. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18034. /**
  18035. * Binds the material to the mesh
  18036. * @param world defines the world transformation matrix
  18037. * @param mesh defines the mesh to bind the material to
  18038. */
  18039. bind(world: Matrix, mesh?: Mesh): void;
  18040. /**
  18041. * Binds the submesh to the material
  18042. * @param world defines the world transformation matrix
  18043. * @param mesh defines the mesh containing the submesh
  18044. * @param subMesh defines the submesh to bind the material to
  18045. */
  18046. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18047. /**
  18048. * Binds the world matrix to the material
  18049. * @param world defines the world transformation matrix
  18050. */
  18051. bindOnlyWorldMatrix(world: Matrix): void;
  18052. /**
  18053. * Binds the scene's uniform buffer to the effect.
  18054. * @param effect defines the effect to bind to the scene uniform buffer
  18055. * @param sceneUbo defines the uniform buffer storing scene data
  18056. */
  18057. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18058. /**
  18059. * Binds the view matrix to the effect
  18060. * @param effect defines the effect to bind the view matrix to
  18061. */
  18062. bindView(effect: Effect): void;
  18063. /**
  18064. * Binds the view projection matrix to the effect
  18065. * @param effect defines the effect to bind the view projection matrix to
  18066. */
  18067. bindViewProjection(effect: Effect): void;
  18068. /**
  18069. * Specifies if material alpha testing should be turned on for the mesh
  18070. * @param mesh defines the mesh to check
  18071. */
  18072. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18073. /**
  18074. * Processes to execute after binding the material to a mesh
  18075. * @param mesh defines the rendered mesh
  18076. */
  18077. protected _afterBind(mesh?: Mesh): void;
  18078. /**
  18079. * Unbinds the material from the mesh
  18080. */
  18081. unbind(): void;
  18082. /**
  18083. * Gets the active textures from the material
  18084. * @returns an array of textures
  18085. */
  18086. getActiveTextures(): BaseTexture[];
  18087. /**
  18088. * Specifies if the material uses a texture
  18089. * @param texture defines the texture to check against the material
  18090. * @returns a boolean specifying if the material uses the texture
  18091. */
  18092. hasTexture(texture: BaseTexture): boolean;
  18093. /**
  18094. * Makes a duplicate of the material, and gives it a new name
  18095. * @param name defines the new name for the duplicated material
  18096. * @returns the cloned material
  18097. */
  18098. clone(name: string): Nullable<Material>;
  18099. /**
  18100. * Gets the meshes bound to the material
  18101. * @returns an array of meshes bound to the material
  18102. */
  18103. getBindedMeshes(): AbstractMesh[];
  18104. /**
  18105. * Force shader compilation
  18106. * @param mesh defines the mesh associated with this material
  18107. * @param onCompiled defines a function to execute once the material is compiled
  18108. * @param options defines the options to configure the compilation
  18109. */
  18110. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18111. clipPlane: boolean;
  18112. }>): void;
  18113. /**
  18114. * Force shader compilation
  18115. * @param mesh defines the mesh that will use this material
  18116. * @param options defines additional options for compiling the shaders
  18117. * @returns a promise that resolves when the compilation completes
  18118. */
  18119. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18120. clipPlane: boolean;
  18121. }>): Promise<void>;
  18122. private static readonly _ImageProcessingDirtyCallBack;
  18123. private static readonly _TextureDirtyCallBack;
  18124. private static readonly _FresnelDirtyCallBack;
  18125. private static readonly _MiscDirtyCallBack;
  18126. private static readonly _LightsDirtyCallBack;
  18127. private static readonly _AttributeDirtyCallBack;
  18128. private static _FresnelAndMiscDirtyCallBack;
  18129. private static _TextureAndMiscDirtyCallBack;
  18130. private static readonly _DirtyCallbackArray;
  18131. private static readonly _RunDirtyCallBacks;
  18132. /**
  18133. * Marks a define in the material to indicate that it needs to be re-computed
  18134. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18135. */
  18136. markAsDirty(flag: number): void;
  18137. /**
  18138. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18139. * @param func defines a function which checks material defines against the submeshes
  18140. */
  18141. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18142. /**
  18143. * Indicates that image processing needs to be re-calculated for all submeshes
  18144. */
  18145. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18146. /**
  18147. * Indicates that textures need to be re-calculated for all submeshes
  18148. */
  18149. protected _markAllSubMeshesAsTexturesDirty(): void;
  18150. /**
  18151. * Indicates that fresnel needs to be re-calculated for all submeshes
  18152. */
  18153. protected _markAllSubMeshesAsFresnelDirty(): void;
  18154. /**
  18155. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18156. */
  18157. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18158. /**
  18159. * Indicates that lights need to be re-calculated for all submeshes
  18160. */
  18161. protected _markAllSubMeshesAsLightsDirty(): void;
  18162. /**
  18163. * Indicates that attributes need to be re-calculated for all submeshes
  18164. */
  18165. protected _markAllSubMeshesAsAttributesDirty(): void;
  18166. /**
  18167. * Indicates that misc needs to be re-calculated for all submeshes
  18168. */
  18169. protected _markAllSubMeshesAsMiscDirty(): void;
  18170. /**
  18171. * Indicates that textures and misc need to be re-calculated for all submeshes
  18172. */
  18173. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18174. /**
  18175. * Disposes the material
  18176. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18177. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18178. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18179. */
  18180. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18181. /** @hidden */
  18182. private releaseVertexArrayObject;
  18183. /**
  18184. * Serializes this material
  18185. * @returns the serialized material object
  18186. */
  18187. serialize(): any;
  18188. /**
  18189. * Creates a material from parsed material data
  18190. * @param parsedMaterial defines parsed material data
  18191. * @param scene defines the hosting scene
  18192. * @param rootUrl defines the root URL to use to load textures
  18193. * @returns a new material
  18194. */
  18195. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18196. }
  18197. }
  18198. declare module "babylonjs/Loading/sceneLoaderFlags" {
  18199. /**
  18200. * Class used to represent data loading progression
  18201. */
  18202. export class SceneLoaderFlags {
  18203. private static _ForceFullSceneLoadingForIncremental;
  18204. private static _ShowLoadingScreen;
  18205. private static _CleanBoneMatrixWeights;
  18206. private static _loggingLevel;
  18207. /**
  18208. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  18209. */
  18210. static ForceFullSceneLoadingForIncremental: boolean;
  18211. /**
  18212. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  18213. */
  18214. static ShowLoadingScreen: boolean;
  18215. /**
  18216. * Defines the current logging level (while loading the scene)
  18217. * @ignorenaming
  18218. */
  18219. static loggingLevel: number;
  18220. /**
  18221. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  18222. */
  18223. static CleanBoneMatrixWeights: boolean;
  18224. }
  18225. }
  18226. declare module "babylonjs/Morph/morphTarget" {
  18227. import { IAnimatable } from "babylonjs/Misc/tools";
  18228. import { Observable } from "babylonjs/Misc/observable";
  18229. import { Nullable, FloatArray } from "babylonjs/types";
  18230. import { Scene } from "babylonjs/scene";
  18231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18232. import { Animation } from "babylonjs/Animations/animation";
  18233. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18234. /**
  18235. * Defines a target to use with MorphTargetManager
  18236. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18237. */
  18238. export class MorphTarget implements IAnimatable {
  18239. /** defines the name of the target */
  18240. name: string;
  18241. /**
  18242. * Gets or sets the list of animations
  18243. */
  18244. animations: Animation[];
  18245. private _scene;
  18246. private _positions;
  18247. private _normals;
  18248. private _tangents;
  18249. private _influence;
  18250. /**
  18251. * Observable raised when the influence changes
  18252. */
  18253. onInfluenceChanged: Observable<boolean>;
  18254. /** @hidden */
  18255. _onDataLayoutChanged: Observable<void>;
  18256. /**
  18257. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18258. */
  18259. influence: number;
  18260. /**
  18261. * Gets or sets the id of the morph Target
  18262. */
  18263. id: string;
  18264. private _animationPropertiesOverride;
  18265. /**
  18266. * Gets or sets the animation properties override
  18267. */
  18268. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18269. /**
  18270. * Creates a new MorphTarget
  18271. * @param name defines the name of the target
  18272. * @param influence defines the influence to use
  18273. * @param scene defines the scene the morphtarget belongs to
  18274. */
  18275. constructor(
  18276. /** defines the name of the target */
  18277. name: string, influence?: number, scene?: Nullable<Scene>);
  18278. /**
  18279. * Gets a boolean defining if the target contains position data
  18280. */
  18281. readonly hasPositions: boolean;
  18282. /**
  18283. * Gets a boolean defining if the target contains normal data
  18284. */
  18285. readonly hasNormals: boolean;
  18286. /**
  18287. * Gets a boolean defining if the target contains tangent data
  18288. */
  18289. readonly hasTangents: boolean;
  18290. /**
  18291. * Affects position data to this target
  18292. * @param data defines the position data to use
  18293. */
  18294. setPositions(data: Nullable<FloatArray>): void;
  18295. /**
  18296. * Gets the position data stored in this target
  18297. * @returns a FloatArray containing the position data (or null if not present)
  18298. */
  18299. getPositions(): Nullable<FloatArray>;
  18300. /**
  18301. * Affects normal data to this target
  18302. * @param data defines the normal data to use
  18303. */
  18304. setNormals(data: Nullable<FloatArray>): void;
  18305. /**
  18306. * Gets the normal data stored in this target
  18307. * @returns a FloatArray containing the normal data (or null if not present)
  18308. */
  18309. getNormals(): Nullable<FloatArray>;
  18310. /**
  18311. * Affects tangent data to this target
  18312. * @param data defines the tangent data to use
  18313. */
  18314. setTangents(data: Nullable<FloatArray>): void;
  18315. /**
  18316. * Gets the tangent data stored in this target
  18317. * @returns a FloatArray containing the tangent data (or null if not present)
  18318. */
  18319. getTangents(): Nullable<FloatArray>;
  18320. /**
  18321. * Serializes the current target into a Serialization object
  18322. * @returns the serialized object
  18323. */
  18324. serialize(): any;
  18325. /**
  18326. * Returns the string "MorphTarget"
  18327. * @returns "MorphTarget"
  18328. */
  18329. getClassName(): string;
  18330. /**
  18331. * Creates a new target from serialized data
  18332. * @param serializationObject defines the serialized data to use
  18333. * @returns a new MorphTarget
  18334. */
  18335. static Parse(serializationObject: any): MorphTarget;
  18336. /**
  18337. * Creates a MorphTarget from mesh data
  18338. * @param mesh defines the source mesh
  18339. * @param name defines the name to use for the new target
  18340. * @param influence defines the influence to attach to the target
  18341. * @returns a new MorphTarget
  18342. */
  18343. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18344. }
  18345. }
  18346. declare module "babylonjs/Morph/morphTargetManager" {
  18347. import { Nullable } from "babylonjs/types";
  18348. import { Scene } from "babylonjs/scene";
  18349. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  18350. /**
  18351. * This class is used to deform meshes using morphing between different targets
  18352. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18353. */
  18354. export class MorphTargetManager {
  18355. private _targets;
  18356. private _targetInfluenceChangedObservers;
  18357. private _targetDataLayoutChangedObservers;
  18358. private _activeTargets;
  18359. private _scene;
  18360. private _influences;
  18361. private _supportsNormals;
  18362. private _supportsTangents;
  18363. private _vertexCount;
  18364. private _uniqueId;
  18365. private _tempInfluences;
  18366. /**
  18367. * Creates a new MorphTargetManager
  18368. * @param scene defines the current scene
  18369. */
  18370. constructor(scene?: Nullable<Scene>);
  18371. /**
  18372. * Gets the unique ID of this manager
  18373. */
  18374. readonly uniqueId: number;
  18375. /**
  18376. * Gets the number of vertices handled by this manager
  18377. */
  18378. readonly vertexCount: number;
  18379. /**
  18380. * Gets a boolean indicating if this manager supports morphing of normals
  18381. */
  18382. readonly supportsNormals: boolean;
  18383. /**
  18384. * Gets a boolean indicating if this manager supports morphing of tangents
  18385. */
  18386. readonly supportsTangents: boolean;
  18387. /**
  18388. * Gets the number of targets stored in this manager
  18389. */
  18390. readonly numTargets: number;
  18391. /**
  18392. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18393. */
  18394. readonly numInfluencers: number;
  18395. /**
  18396. * Gets the list of influences (one per target)
  18397. */
  18398. readonly influences: Float32Array;
  18399. /**
  18400. * Gets the active target at specified index. An active target is a target with an influence > 0
  18401. * @param index defines the index to check
  18402. * @returns the requested target
  18403. */
  18404. getActiveTarget(index: number): MorphTarget;
  18405. /**
  18406. * Gets the target at specified index
  18407. * @param index defines the index to check
  18408. * @returns the requested target
  18409. */
  18410. getTarget(index: number): MorphTarget;
  18411. /**
  18412. * Add a new target to this manager
  18413. * @param target defines the target to add
  18414. */
  18415. addTarget(target: MorphTarget): void;
  18416. /**
  18417. * Removes a target from the manager
  18418. * @param target defines the target to remove
  18419. */
  18420. removeTarget(target: MorphTarget): void;
  18421. /**
  18422. * Serializes the current manager into a Serialization object
  18423. * @returns the serialized object
  18424. */
  18425. serialize(): any;
  18426. private _syncActiveTargets;
  18427. /**
  18428. * Syncrhonize the targets with all the meshes using this morph target manager
  18429. */
  18430. synchronize(): void;
  18431. /**
  18432. * Creates a new MorphTargetManager from serialized data
  18433. * @param serializationObject defines the serialized data
  18434. * @param scene defines the hosting scene
  18435. * @returns the new MorphTargetManager
  18436. */
  18437. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18438. }
  18439. }
  18440. declare module "babylonjs/Physics/physicsJoint" {
  18441. import { Vector3 } from "babylonjs/Maths/math";
  18442. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  18443. /**
  18444. * Interface for Physics-Joint data
  18445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18446. */
  18447. export interface PhysicsJointData {
  18448. /**
  18449. * The main pivot of the joint
  18450. */
  18451. mainPivot?: Vector3;
  18452. /**
  18453. * The connected pivot of the joint
  18454. */
  18455. connectedPivot?: Vector3;
  18456. /**
  18457. * The main axis of the joint
  18458. */
  18459. mainAxis?: Vector3;
  18460. /**
  18461. * The connected axis of the joint
  18462. */
  18463. connectedAxis?: Vector3;
  18464. /**
  18465. * The collision of the joint
  18466. */
  18467. collision?: boolean;
  18468. /**
  18469. * Native Oimo/Cannon/Energy data
  18470. */
  18471. nativeParams?: any;
  18472. }
  18473. /**
  18474. * This is a holder class for the physics joint created by the physics plugin
  18475. * It holds a set of functions to control the underlying joint
  18476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18477. */
  18478. export class PhysicsJoint {
  18479. /**
  18480. * The type of the physics joint
  18481. */
  18482. type: number;
  18483. /**
  18484. * The data for the physics joint
  18485. */
  18486. jointData: PhysicsJointData;
  18487. private _physicsJoint;
  18488. protected _physicsPlugin: IPhysicsEnginePlugin;
  18489. /**
  18490. * Initializes the physics joint
  18491. * @param type The type of the physics joint
  18492. * @param jointData The data for the physics joint
  18493. */
  18494. constructor(
  18495. /**
  18496. * The type of the physics joint
  18497. */
  18498. type: number,
  18499. /**
  18500. * The data for the physics joint
  18501. */
  18502. jointData: PhysicsJointData);
  18503. /**
  18504. * Gets the physics joint
  18505. */
  18506. /**
  18507. * Sets the physics joint
  18508. */
  18509. physicsJoint: any;
  18510. /**
  18511. * Sets the physics plugin
  18512. */
  18513. physicsPlugin: IPhysicsEnginePlugin;
  18514. /**
  18515. * Execute a function that is physics-plugin specific.
  18516. * @param {Function} func the function that will be executed.
  18517. * It accepts two parameters: the physics world and the physics joint
  18518. */
  18519. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18520. /**
  18521. * Distance-Joint type
  18522. */
  18523. static DistanceJoint: number;
  18524. /**
  18525. * Hinge-Joint type
  18526. */
  18527. static HingeJoint: number;
  18528. /**
  18529. * Ball-and-Socket joint type
  18530. */
  18531. static BallAndSocketJoint: number;
  18532. /**
  18533. * Wheel-Joint type
  18534. */
  18535. static WheelJoint: number;
  18536. /**
  18537. * Slider-Joint type
  18538. */
  18539. static SliderJoint: number;
  18540. /**
  18541. * Prismatic-Joint type
  18542. */
  18543. static PrismaticJoint: number;
  18544. /**
  18545. * Universal-Joint type
  18546. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18547. */
  18548. static UniversalJoint: number;
  18549. /**
  18550. * Hinge-Joint 2 type
  18551. */
  18552. static Hinge2Joint: number;
  18553. /**
  18554. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18555. */
  18556. static PointToPointJoint: number;
  18557. /**
  18558. * Spring-Joint type
  18559. */
  18560. static SpringJoint: number;
  18561. /**
  18562. * Lock-Joint type
  18563. */
  18564. static LockJoint: number;
  18565. }
  18566. /**
  18567. * A class representing a physics distance joint
  18568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18569. */
  18570. export class DistanceJoint extends PhysicsJoint {
  18571. /**
  18572. *
  18573. * @param jointData The data for the Distance-Joint
  18574. */
  18575. constructor(jointData: DistanceJointData);
  18576. /**
  18577. * Update the predefined distance.
  18578. * @param maxDistance The maximum preferred distance
  18579. * @param minDistance The minimum preferred distance
  18580. */
  18581. updateDistance(maxDistance: number, minDistance?: number): void;
  18582. }
  18583. /**
  18584. * Represents a Motor-Enabled Joint
  18585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18586. */
  18587. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18588. /**
  18589. * Initializes the Motor-Enabled Joint
  18590. * @param type The type of the joint
  18591. * @param jointData The physica joint data for the joint
  18592. */
  18593. constructor(type: number, jointData: PhysicsJointData);
  18594. /**
  18595. * Set the motor values.
  18596. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18597. * @param force the force to apply
  18598. * @param maxForce max force for this motor.
  18599. */
  18600. setMotor(force?: number, maxForce?: number): void;
  18601. /**
  18602. * Set the motor's limits.
  18603. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18604. * @param upperLimit The upper limit of the motor
  18605. * @param lowerLimit The lower limit of the motor
  18606. */
  18607. setLimit(upperLimit: number, lowerLimit?: number): void;
  18608. }
  18609. /**
  18610. * This class represents a single physics Hinge-Joint
  18611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18612. */
  18613. export class HingeJoint extends MotorEnabledJoint {
  18614. /**
  18615. * Initializes the Hinge-Joint
  18616. * @param jointData The joint data for the Hinge-Joint
  18617. */
  18618. constructor(jointData: PhysicsJointData);
  18619. /**
  18620. * Set the motor values.
  18621. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18622. * @param {number} force the force to apply
  18623. * @param {number} maxForce max force for this motor.
  18624. */
  18625. setMotor(force?: number, maxForce?: number): void;
  18626. /**
  18627. * Set the motor's limits.
  18628. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18629. * @param upperLimit The upper limit of the motor
  18630. * @param lowerLimit The lower limit of the motor
  18631. */
  18632. setLimit(upperLimit: number, lowerLimit?: number): void;
  18633. }
  18634. /**
  18635. * This class represents a dual hinge physics joint (same as wheel joint)
  18636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18637. */
  18638. export class Hinge2Joint extends MotorEnabledJoint {
  18639. /**
  18640. * Initializes the Hinge2-Joint
  18641. * @param jointData The joint data for the Hinge2-Joint
  18642. */
  18643. constructor(jointData: PhysicsJointData);
  18644. /**
  18645. * Set the motor values.
  18646. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18647. * @param {number} force the force to apply
  18648. * @param {number} maxForce max force for this motor.
  18649. * @param {motorIndex} the motor's index, 0 or 1.
  18650. */
  18651. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18652. /**
  18653. * Set the motor limits.
  18654. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18655. * @param {number} upperLimit the upper limit
  18656. * @param {number} lowerLimit lower limit
  18657. * @param {motorIndex} the motor's index, 0 or 1.
  18658. */
  18659. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18660. }
  18661. /**
  18662. * Interface for a motor enabled joint
  18663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18664. */
  18665. export interface IMotorEnabledJoint {
  18666. /**
  18667. * Physics joint
  18668. */
  18669. physicsJoint: any;
  18670. /**
  18671. * Sets the motor of the motor-enabled joint
  18672. * @param force The force of the motor
  18673. * @param maxForce The maximum force of the motor
  18674. * @param motorIndex The index of the motor
  18675. */
  18676. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18677. /**
  18678. * Sets the limit of the motor
  18679. * @param upperLimit The upper limit of the motor
  18680. * @param lowerLimit The lower limit of the motor
  18681. * @param motorIndex The index of the motor
  18682. */
  18683. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18684. }
  18685. /**
  18686. * Joint data for a Distance-Joint
  18687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18688. */
  18689. export interface DistanceJointData extends PhysicsJointData {
  18690. /**
  18691. * Max distance the 2 joint objects can be apart
  18692. */
  18693. maxDistance: number;
  18694. }
  18695. /**
  18696. * Joint data from a spring joint
  18697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18698. */
  18699. export interface SpringJointData extends PhysicsJointData {
  18700. /**
  18701. * Length of the spring
  18702. */
  18703. length: number;
  18704. /**
  18705. * Stiffness of the spring
  18706. */
  18707. stiffness: number;
  18708. /**
  18709. * Damping of the spring
  18710. */
  18711. damping: number;
  18712. /** this callback will be called when applying the force to the impostors. */
  18713. forceApplicationCallback: () => void;
  18714. }
  18715. }
  18716. declare module "babylonjs/Physics/IPhysicsEngine" {
  18717. import { Nullable } from "babylonjs/types";
  18718. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18720. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18721. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18722. /**
  18723. * Interface used to describe a physics joint
  18724. */
  18725. export interface PhysicsImpostorJoint {
  18726. /** Defines the main impostor to which the joint is linked */
  18727. mainImpostor: PhysicsImpostor;
  18728. /** Defines the impostor that is connected to the main impostor using this joint */
  18729. connectedImpostor: PhysicsImpostor;
  18730. /** Defines the joint itself */
  18731. joint: PhysicsJoint;
  18732. }
  18733. /** @hidden */
  18734. export interface IPhysicsEnginePlugin {
  18735. world: any;
  18736. name: string;
  18737. setGravity(gravity: Vector3): void;
  18738. setTimeStep(timeStep: number): void;
  18739. getTimeStep(): number;
  18740. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18741. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18743. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18744. removePhysicsBody(impostor: PhysicsImpostor): void;
  18745. generateJoint(joint: PhysicsImpostorJoint): void;
  18746. removeJoint(joint: PhysicsImpostorJoint): void;
  18747. isSupported(): boolean;
  18748. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18749. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18750. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18751. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18752. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18753. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18754. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18755. getBodyMass(impostor: PhysicsImpostor): number;
  18756. getBodyFriction(impostor: PhysicsImpostor): number;
  18757. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18758. getBodyRestitution(impostor: PhysicsImpostor): number;
  18759. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18760. sleepBody(impostor: PhysicsImpostor): void;
  18761. wakeUpBody(impostor: PhysicsImpostor): void;
  18762. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18763. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18764. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18765. getRadius(impostor: PhysicsImpostor): number;
  18766. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18767. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18768. dispose(): void;
  18769. }
  18770. /**
  18771. * Interface used to define a physics engine
  18772. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18773. */
  18774. export interface IPhysicsEngine {
  18775. /**
  18776. * Gets the gravity vector used by the simulation
  18777. */
  18778. gravity: Vector3;
  18779. /**
  18780. * Sets the gravity vector used by the simulation
  18781. * @param gravity defines the gravity vector to use
  18782. */
  18783. setGravity(gravity: Vector3): void;
  18784. /**
  18785. * Set the time step of the physics engine.
  18786. * Default is 1/60.
  18787. * To slow it down, enter 1/600 for example.
  18788. * To speed it up, 1/30
  18789. * @param newTimeStep the new timestep to apply to this world.
  18790. */
  18791. setTimeStep(newTimeStep: number): void;
  18792. /**
  18793. * Get the time step of the physics engine.
  18794. * @returns the current time step
  18795. */
  18796. getTimeStep(): number;
  18797. /**
  18798. * Release all resources
  18799. */
  18800. dispose(): void;
  18801. /**
  18802. * Gets the name of the current physics plugin
  18803. * @returns the name of the plugin
  18804. */
  18805. getPhysicsPluginName(): string;
  18806. /**
  18807. * Adding a new impostor for the impostor tracking.
  18808. * This will be done by the impostor itself.
  18809. * @param impostor the impostor to add
  18810. */
  18811. addImpostor(impostor: PhysicsImpostor): void;
  18812. /**
  18813. * Remove an impostor from the engine.
  18814. * This impostor and its mesh will not longer be updated by the physics engine.
  18815. * @param impostor the impostor to remove
  18816. */
  18817. removeImpostor(impostor: PhysicsImpostor): void;
  18818. /**
  18819. * Add a joint to the physics engine
  18820. * @param mainImpostor defines the main impostor to which the joint is added.
  18821. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18822. * @param joint defines the joint that will connect both impostors.
  18823. */
  18824. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18825. /**
  18826. * Removes a joint from the simulation
  18827. * @param mainImpostor defines the impostor used with the joint
  18828. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18829. * @param joint defines the joint to remove
  18830. */
  18831. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18832. /**
  18833. * Gets the current plugin used to run the simulation
  18834. * @returns current plugin
  18835. */
  18836. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18837. /**
  18838. * Gets the list of physic impostors
  18839. * @returns an array of PhysicsImpostor
  18840. */
  18841. getImpostors(): Array<PhysicsImpostor>;
  18842. /**
  18843. * Gets the impostor for a physics enabled object
  18844. * @param object defines the object impersonated by the impostor
  18845. * @returns the PhysicsImpostor or null if not found
  18846. */
  18847. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18848. /**
  18849. * Gets the impostor for a physics body object
  18850. * @param body defines physics body used by the impostor
  18851. * @returns the PhysicsImpostor or null if not found
  18852. */
  18853. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18854. /**
  18855. * Called by the scene. No need to call it.
  18856. * @param delta defines the timespam between frames
  18857. */
  18858. _step(delta: number): void;
  18859. }
  18860. }
  18861. declare module "babylonjs/Physics/physicsImpostor" {
  18862. import { Nullable, IndicesArray } from "babylonjs/types";
  18863. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  18864. import { TransformNode } from "babylonjs/Meshes/transformNode";
  18865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18866. import { Scene } from "babylonjs/scene";
  18867. import { Bone } from "babylonjs/Bones/bone";
  18868. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  18869. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  18870. /**
  18871. * The interface for the physics imposter parameters
  18872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18873. */
  18874. export interface PhysicsImpostorParameters {
  18875. /**
  18876. * The mass of the physics imposter
  18877. */
  18878. mass: number;
  18879. /**
  18880. * The friction of the physics imposter
  18881. */
  18882. friction?: number;
  18883. /**
  18884. * The coefficient of restitution of the physics imposter
  18885. */
  18886. restitution?: number;
  18887. /**
  18888. * The native options of the physics imposter
  18889. */
  18890. nativeOptions?: any;
  18891. /**
  18892. * Specifies if the parent should be ignored
  18893. */
  18894. ignoreParent?: boolean;
  18895. /**
  18896. * Specifies if bi-directional transformations should be disabled
  18897. */
  18898. disableBidirectionalTransformation?: boolean;
  18899. }
  18900. /**
  18901. * Interface for a physics-enabled object
  18902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18903. */
  18904. export interface IPhysicsEnabledObject {
  18905. /**
  18906. * The position of the physics-enabled object
  18907. */
  18908. position: Vector3;
  18909. /**
  18910. * The rotation of the physics-enabled object
  18911. */
  18912. rotationQuaternion: Nullable<Quaternion>;
  18913. /**
  18914. * The scale of the physics-enabled object
  18915. */
  18916. scaling: Vector3;
  18917. /**
  18918. * The rotation of the physics-enabled object
  18919. */
  18920. rotation?: Vector3;
  18921. /**
  18922. * The parent of the physics-enabled object
  18923. */
  18924. parent?: any;
  18925. /**
  18926. * The bounding info of the physics-enabled object
  18927. * @returns The bounding info of the physics-enabled object
  18928. */
  18929. getBoundingInfo(): BoundingInfo;
  18930. /**
  18931. * Computes the world matrix
  18932. * @param force Specifies if the world matrix should be computed by force
  18933. * @returns A world matrix
  18934. */
  18935. computeWorldMatrix(force: boolean): Matrix;
  18936. /**
  18937. * Gets the world matrix
  18938. * @returns A world matrix
  18939. */
  18940. getWorldMatrix?(): Matrix;
  18941. /**
  18942. * Gets the child meshes
  18943. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18944. * @returns An array of abstract meshes
  18945. */
  18946. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18947. /**
  18948. * Gets the vertex data
  18949. * @param kind The type of vertex data
  18950. * @returns A nullable array of numbers, or a float32 array
  18951. */
  18952. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18953. /**
  18954. * Gets the indices from the mesh
  18955. * @returns A nullable array of index arrays
  18956. */
  18957. getIndices?(): Nullable<IndicesArray>;
  18958. /**
  18959. * Gets the scene from the mesh
  18960. * @returns the indices array or null
  18961. */
  18962. getScene?(): Scene;
  18963. /**
  18964. * Gets the absolute position from the mesh
  18965. * @returns the absolute position
  18966. */
  18967. getAbsolutePosition(): Vector3;
  18968. /**
  18969. * Gets the absolute pivot point from the mesh
  18970. * @returns the absolute pivot point
  18971. */
  18972. getAbsolutePivotPoint(): Vector3;
  18973. /**
  18974. * Rotates the mesh
  18975. * @param axis The axis of rotation
  18976. * @param amount The amount of rotation
  18977. * @param space The space of the rotation
  18978. * @returns The rotation transform node
  18979. */
  18980. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18981. /**
  18982. * Translates the mesh
  18983. * @param axis The axis of translation
  18984. * @param distance The distance of translation
  18985. * @param space The space of the translation
  18986. * @returns The transform node
  18987. */
  18988. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18989. /**
  18990. * Sets the absolute position of the mesh
  18991. * @param absolutePosition The absolute position of the mesh
  18992. * @returns The transform node
  18993. */
  18994. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18995. /**
  18996. * Gets the class name of the mesh
  18997. * @returns The class name
  18998. */
  18999. getClassName(): string;
  19000. }
  19001. /**
  19002. * Represents a physics imposter
  19003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19004. */
  19005. export class PhysicsImpostor {
  19006. /**
  19007. * The physics-enabled object used as the physics imposter
  19008. */
  19009. object: IPhysicsEnabledObject;
  19010. /**
  19011. * The type of the physics imposter
  19012. */
  19013. type: number;
  19014. private _options;
  19015. private _scene?;
  19016. /**
  19017. * The default object size of the imposter
  19018. */
  19019. static DEFAULT_OBJECT_SIZE: Vector3;
  19020. /**
  19021. * The identity quaternion of the imposter
  19022. */
  19023. static IDENTITY_QUATERNION: Quaternion;
  19024. /** @hidden */
  19025. _pluginData: any;
  19026. private _physicsEngine;
  19027. private _physicsBody;
  19028. private _bodyUpdateRequired;
  19029. private _onBeforePhysicsStepCallbacks;
  19030. private _onAfterPhysicsStepCallbacks;
  19031. /** @hidden */
  19032. _onPhysicsCollideCallbacks: Array<{
  19033. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19034. otherImpostors: Array<PhysicsImpostor>;
  19035. }>;
  19036. private _deltaPosition;
  19037. private _deltaRotation;
  19038. private _deltaRotationConjugated;
  19039. private _parent;
  19040. private _isDisposed;
  19041. private static _tmpVecs;
  19042. private static _tmpQuat;
  19043. /**
  19044. * Specifies if the physics imposter is disposed
  19045. */
  19046. readonly isDisposed: boolean;
  19047. /**
  19048. * Gets the mass of the physics imposter
  19049. */
  19050. mass: number;
  19051. /**
  19052. * Gets the coefficient of friction
  19053. */
  19054. /**
  19055. * Sets the coefficient of friction
  19056. */
  19057. friction: number;
  19058. /**
  19059. * Gets the coefficient of restitution
  19060. */
  19061. /**
  19062. * Sets the coefficient of restitution
  19063. */
  19064. restitution: number;
  19065. /**
  19066. * The unique id of the physics imposter
  19067. * set by the physics engine when adding this impostor to the array
  19068. */
  19069. uniqueId: number;
  19070. private _joints;
  19071. /**
  19072. * Initializes the physics imposter
  19073. * @param object The physics-enabled object used as the physics imposter
  19074. * @param type The type of the physics imposter
  19075. * @param _options The options for the physics imposter
  19076. * @param _scene The Babylon scene
  19077. */
  19078. constructor(
  19079. /**
  19080. * The physics-enabled object used as the physics imposter
  19081. */
  19082. object: IPhysicsEnabledObject,
  19083. /**
  19084. * The type of the physics imposter
  19085. */
  19086. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19087. /**
  19088. * This function will completly initialize this impostor.
  19089. * It will create a new body - but only if this mesh has no parent.
  19090. * If it has, this impostor will not be used other than to define the impostor
  19091. * of the child mesh.
  19092. * @hidden
  19093. */
  19094. _init(): void;
  19095. private _getPhysicsParent;
  19096. /**
  19097. * Should a new body be generated.
  19098. * @returns boolean specifying if body initialization is required
  19099. */
  19100. isBodyInitRequired(): boolean;
  19101. /**
  19102. * Sets the updated scaling
  19103. * @param updated Specifies if the scaling is updated
  19104. */
  19105. setScalingUpdated(): void;
  19106. /**
  19107. * Force a regeneration of this or the parent's impostor's body.
  19108. * Use under cautious - This will remove all joints already implemented.
  19109. */
  19110. forceUpdate(): void;
  19111. /**
  19112. * Gets the body that holds this impostor. Either its own, or its parent.
  19113. */
  19114. /**
  19115. * Set the physics body. Used mainly by the physics engine/plugin
  19116. */
  19117. physicsBody: any;
  19118. /**
  19119. * Get the parent of the physics imposter
  19120. * @returns Physics imposter or null
  19121. */
  19122. /**
  19123. * Sets the parent of the physics imposter
  19124. */
  19125. parent: Nullable<PhysicsImpostor>;
  19126. /**
  19127. * Resets the update flags
  19128. */
  19129. resetUpdateFlags(): void;
  19130. /**
  19131. * Gets the object extend size
  19132. * @returns the object extend size
  19133. */
  19134. getObjectExtendSize(): Vector3;
  19135. /**
  19136. * Gets the object center
  19137. * @returns The object center
  19138. */
  19139. getObjectCenter(): Vector3;
  19140. /**
  19141. * Get a specific parametes from the options parameter
  19142. * @param paramName The object parameter name
  19143. * @returns The object parameter
  19144. */
  19145. getParam(paramName: string): any;
  19146. /**
  19147. * Sets a specific parameter in the options given to the physics plugin
  19148. * @param paramName The parameter name
  19149. * @param value The value of the parameter
  19150. */
  19151. setParam(paramName: string, value: number): void;
  19152. /**
  19153. * Specifically change the body's mass option. Won't recreate the physics body object
  19154. * @param mass The mass of the physics imposter
  19155. */
  19156. setMass(mass: number): void;
  19157. /**
  19158. * Gets the linear velocity
  19159. * @returns linear velocity or null
  19160. */
  19161. getLinearVelocity(): Nullable<Vector3>;
  19162. /**
  19163. * Sets the linear velocity
  19164. * @param velocity linear velocity or null
  19165. */
  19166. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19167. /**
  19168. * Gets the angular velocity
  19169. * @returns angular velocity or null
  19170. */
  19171. getAngularVelocity(): Nullable<Vector3>;
  19172. /**
  19173. * Sets the angular velocity
  19174. * @param velocity The velocity or null
  19175. */
  19176. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19177. /**
  19178. * Execute a function with the physics plugin native code
  19179. * Provide a function the will have two variables - the world object and the physics body object
  19180. * @param func The function to execute with the physics plugin native code
  19181. */
  19182. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19183. /**
  19184. * Register a function that will be executed before the physics world is stepping forward
  19185. * @param func The function to execute before the physics world is stepped forward
  19186. */
  19187. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19188. /**
  19189. * Unregister a function that will be executed before the physics world is stepping forward
  19190. * @param func The function to execute before the physics world is stepped forward
  19191. */
  19192. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19193. /**
  19194. * Register a function that will be executed after the physics step
  19195. * @param func The function to execute after physics step
  19196. */
  19197. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19198. /**
  19199. * Unregisters a function that will be executed after the physics step
  19200. * @param func The function to execute after physics step
  19201. */
  19202. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19203. /**
  19204. * register a function that will be executed when this impostor collides against a different body
  19205. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19206. * @param func Callback that is executed on collision
  19207. */
  19208. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19209. /**
  19210. * Unregisters the physics imposter on contact
  19211. * @param collideAgainst The physics object to collide against
  19212. * @param func Callback to execute on collision
  19213. */
  19214. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19215. private _tmpQuat;
  19216. private _tmpQuat2;
  19217. /**
  19218. * Get the parent rotation
  19219. * @returns The parent rotation
  19220. */
  19221. getParentsRotation(): Quaternion;
  19222. /**
  19223. * this function is executed by the physics engine.
  19224. */
  19225. beforeStep: () => void;
  19226. /**
  19227. * this function is executed by the physics engine
  19228. */
  19229. afterStep: () => void;
  19230. /**
  19231. * Legacy collision detection event support
  19232. */
  19233. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19234. /**
  19235. * event and body object due to cannon's event-based architecture.
  19236. */
  19237. onCollide: (e: {
  19238. body: any;
  19239. }) => void;
  19240. /**
  19241. * Apply a force
  19242. * @param force The force to apply
  19243. * @param contactPoint The contact point for the force
  19244. * @returns The physics imposter
  19245. */
  19246. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19247. /**
  19248. * Apply an impulse
  19249. * @param force The impulse force
  19250. * @param contactPoint The contact point for the impulse force
  19251. * @returns The physics imposter
  19252. */
  19253. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19254. /**
  19255. * A help function to create a joint
  19256. * @param otherImpostor A physics imposter used to create a joint
  19257. * @param jointType The type of joint
  19258. * @param jointData The data for the joint
  19259. * @returns The physics imposter
  19260. */
  19261. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19262. /**
  19263. * Add a joint to this impostor with a different impostor
  19264. * @param otherImpostor A physics imposter used to add a joint
  19265. * @param joint The joint to add
  19266. * @returns The physics imposter
  19267. */
  19268. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19269. /**
  19270. * Will keep this body still, in a sleep mode.
  19271. * @returns the physics imposter
  19272. */
  19273. sleep(): PhysicsImpostor;
  19274. /**
  19275. * Wake the body up.
  19276. * @returns The physics imposter
  19277. */
  19278. wakeUp(): PhysicsImpostor;
  19279. /**
  19280. * Clones the physics imposter
  19281. * @param newObject The physics imposter clones to this physics-enabled object
  19282. * @returns A nullable physics imposter
  19283. */
  19284. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19285. /**
  19286. * Disposes the physics imposter
  19287. */
  19288. dispose(): void;
  19289. /**
  19290. * Sets the delta position
  19291. * @param position The delta position amount
  19292. */
  19293. setDeltaPosition(position: Vector3): void;
  19294. /**
  19295. * Sets the delta rotation
  19296. * @param rotation The delta rotation amount
  19297. */
  19298. setDeltaRotation(rotation: Quaternion): void;
  19299. /**
  19300. * Gets the box size of the physics imposter and stores the result in the input parameter
  19301. * @param result Stores the box size
  19302. * @returns The physics imposter
  19303. */
  19304. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19305. /**
  19306. * Gets the radius of the physics imposter
  19307. * @returns Radius of the physics imposter
  19308. */
  19309. getRadius(): number;
  19310. /**
  19311. * Sync a bone with this impostor
  19312. * @param bone The bone to sync to the impostor.
  19313. * @param boneMesh The mesh that the bone is influencing.
  19314. * @param jointPivot The pivot of the joint / bone in local space.
  19315. * @param distToJoint Optional distance from the impostor to the joint.
  19316. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19317. */
  19318. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19319. /**
  19320. * Sync impostor to a bone
  19321. * @param bone The bone that the impostor will be synced to.
  19322. * @param boneMesh The mesh that the bone is influencing.
  19323. * @param jointPivot The pivot of the joint / bone in local space.
  19324. * @param distToJoint Optional distance from the impostor to the joint.
  19325. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19326. * @param boneAxis Optional vector3 axis the bone is aligned with
  19327. */
  19328. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19329. /**
  19330. * No-Imposter type
  19331. */
  19332. static NoImpostor: number;
  19333. /**
  19334. * Sphere-Imposter type
  19335. */
  19336. static SphereImpostor: number;
  19337. /**
  19338. * Box-Imposter type
  19339. */
  19340. static BoxImpostor: number;
  19341. /**
  19342. * Plane-Imposter type
  19343. */
  19344. static PlaneImpostor: number;
  19345. /**
  19346. * Mesh-imposter type
  19347. */
  19348. static MeshImpostor: number;
  19349. /**
  19350. * Cylinder-Imposter type
  19351. */
  19352. static CylinderImpostor: number;
  19353. /**
  19354. * Particle-Imposter type
  19355. */
  19356. static ParticleImpostor: number;
  19357. /**
  19358. * Heightmap-Imposter type
  19359. */
  19360. static HeightmapImpostor: number;
  19361. }
  19362. }
  19363. declare module "babylonjs/Meshes/groundMesh" {
  19364. import { Scene } from "babylonjs/scene";
  19365. import { Vector3 } from "babylonjs/Maths/math";
  19366. import { Mesh } from "babylonjs/Meshes/mesh";
  19367. /**
  19368. * Mesh representing the gorund
  19369. */
  19370. export class GroundMesh extends Mesh {
  19371. /** If octree should be generated */
  19372. generateOctree: boolean;
  19373. private _heightQuads;
  19374. /** @hidden */
  19375. _subdivisionsX: number;
  19376. /** @hidden */
  19377. _subdivisionsY: number;
  19378. /** @hidden */
  19379. _width: number;
  19380. /** @hidden */
  19381. _height: number;
  19382. /** @hidden */
  19383. _minX: number;
  19384. /** @hidden */
  19385. _maxX: number;
  19386. /** @hidden */
  19387. _minZ: number;
  19388. /** @hidden */
  19389. _maxZ: number;
  19390. constructor(name: string, scene: Scene);
  19391. /**
  19392. * "GroundMesh"
  19393. * @returns "GroundMesh"
  19394. */
  19395. getClassName(): string;
  19396. /**
  19397. * The minimum of x and y subdivisions
  19398. */
  19399. readonly subdivisions: number;
  19400. /**
  19401. * X subdivisions
  19402. */
  19403. readonly subdivisionsX: number;
  19404. /**
  19405. * Y subdivisions
  19406. */
  19407. readonly subdivisionsY: number;
  19408. /**
  19409. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19410. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19411. * @param chunksCount the number of subdivisions for x and y
  19412. * @param octreeBlocksSize (Default: 32)
  19413. */
  19414. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19415. /**
  19416. * Returns a height (y) value in the Worl system :
  19417. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19418. * @param x x coordinate
  19419. * @param z z coordinate
  19420. * @returns the ground y position if (x, z) are outside the ground surface.
  19421. */
  19422. getHeightAtCoordinates(x: number, z: number): number;
  19423. /**
  19424. * Returns a normalized vector (Vector3) orthogonal to the ground
  19425. * at the ground coordinates (x, z) expressed in the World system.
  19426. * @param x x coordinate
  19427. * @param z z coordinate
  19428. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19429. */
  19430. getNormalAtCoordinates(x: number, z: number): Vector3;
  19431. /**
  19432. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19433. * at the ground coordinates (x, z) expressed in the World system.
  19434. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19435. * @param x x coordinate
  19436. * @param z z coordinate
  19437. * @param ref vector to store the result
  19438. * @returns the GroundMesh.
  19439. */
  19440. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19441. /**
  19442. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19443. * if the ground has been updated.
  19444. * This can be used in the render loop.
  19445. * @returns the GroundMesh.
  19446. */
  19447. updateCoordinateHeights(): GroundMesh;
  19448. private _getFacetAt;
  19449. private _initHeightQuads;
  19450. private _computeHeightQuads;
  19451. /**
  19452. * Serializes this ground mesh
  19453. * @param serializationObject object to write serialization to
  19454. */
  19455. serialize(serializationObject: any): void;
  19456. /**
  19457. * Parses a serialized ground mesh
  19458. * @param parsedMesh the serialized mesh
  19459. * @param scene the scene to create the ground mesh in
  19460. * @returns the created ground mesh
  19461. */
  19462. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19463. }
  19464. }
  19465. declare module "babylonjs/Meshes/mesh" {
  19466. import { Observable } from "babylonjs/Misc/observable";
  19467. import { IAnimatable } from "babylonjs/Misc/tools";
  19468. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19469. import { Camera } from "babylonjs/Cameras/camera";
  19470. import { Scene } from "babylonjs/scene";
  19471. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  19472. import { Engine } from "babylonjs/Engines/engine";
  19473. import { Node } from "babylonjs/node";
  19474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19475. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  19476. import { Buffer } from "babylonjs/Meshes/buffer";
  19477. import { Geometry } from "babylonjs/Meshes/geometry";
  19478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19479. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19480. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  19481. import { Effect } from "babylonjs/Materials/effect";
  19482. import { Material } from "babylonjs/Materials/material";
  19483. import { Skeleton } from "babylonjs/Bones/skeleton";
  19484. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  19485. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  19486. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19487. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  19488. /**
  19489. * Class used to represent a specific level of detail of a mesh
  19490. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19491. */
  19492. export class MeshLODLevel {
  19493. /** Defines the distance where this level should star being displayed */
  19494. distance: number;
  19495. /** Defines the mesh to use to render this level */
  19496. mesh: Nullable<Mesh>;
  19497. /**
  19498. * Creates a new LOD level
  19499. * @param distance defines the distance where this level should star being displayed
  19500. * @param mesh defines the mesh to use to render this level
  19501. */
  19502. constructor(
  19503. /** Defines the distance where this level should star being displayed */
  19504. distance: number,
  19505. /** Defines the mesh to use to render this level */
  19506. mesh: Nullable<Mesh>);
  19507. }
  19508. /**
  19509. * @hidden
  19510. **/
  19511. export class _CreationDataStorage {
  19512. closePath?: boolean;
  19513. closeArray?: boolean;
  19514. idx: number[];
  19515. dashSize: number;
  19516. gapSize: number;
  19517. path3D: Path3D;
  19518. pathArray: Vector3[][];
  19519. arc: number;
  19520. radius: number;
  19521. cap: number;
  19522. tessellation: number;
  19523. }
  19524. /**
  19525. * @hidden
  19526. **/
  19527. class _InstanceDataStorage {
  19528. visibleInstances: any;
  19529. renderIdForInstances: number[];
  19530. batchCache: _InstancesBatch;
  19531. instancesBufferSize: number;
  19532. instancesBuffer: Nullable<Buffer>;
  19533. instancesData: Float32Array;
  19534. overridenInstanceCount: number;
  19535. }
  19536. /**
  19537. * @hidden
  19538. **/
  19539. export class _InstancesBatch {
  19540. mustReturn: boolean;
  19541. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  19542. renderSelf: boolean[];
  19543. }
  19544. /**
  19545. * Class used to represent renderable models
  19546. */
  19547. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19548. /**
  19549. * Mesh side orientation : usually the external or front surface
  19550. */
  19551. static readonly FRONTSIDE: number;
  19552. /**
  19553. * Mesh side orientation : usually the internal or back surface
  19554. */
  19555. static readonly BACKSIDE: number;
  19556. /**
  19557. * Mesh side orientation : both internal and external or front and back surfaces
  19558. */
  19559. static readonly DOUBLESIDE: number;
  19560. /**
  19561. * Mesh side orientation : by default, `FRONTSIDE`
  19562. */
  19563. static readonly DEFAULTSIDE: number;
  19564. /**
  19565. * Mesh cap setting : no cap
  19566. */
  19567. static readonly NO_CAP: number;
  19568. /**
  19569. * Mesh cap setting : one cap at the beginning of the mesh
  19570. */
  19571. static readonly CAP_START: number;
  19572. /**
  19573. * Mesh cap setting : one cap at the end of the mesh
  19574. */
  19575. static readonly CAP_END: number;
  19576. /**
  19577. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19578. */
  19579. static readonly CAP_ALL: number;
  19580. /**
  19581. * Gets the default side orientation.
  19582. * @param orientation the orientation to value to attempt to get
  19583. * @returns the default orientation
  19584. * @hidden
  19585. */
  19586. static _GetDefaultSideOrientation(orientation?: number): number;
  19587. private _onBeforeRenderObservable;
  19588. private _onBeforeBindObservable;
  19589. private _onAfterRenderObservable;
  19590. private _onBeforeDrawObservable;
  19591. /**
  19592. * An event triggered before rendering the mesh
  19593. */
  19594. readonly onBeforeRenderObservable: Observable<Mesh>;
  19595. /**
  19596. * An event triggered before binding the mesh
  19597. */
  19598. readonly onBeforeBindObservable: Observable<Mesh>;
  19599. /**
  19600. * An event triggered after rendering the mesh
  19601. */
  19602. readonly onAfterRenderObservable: Observable<Mesh>;
  19603. /**
  19604. * An event triggered before drawing the mesh
  19605. */
  19606. readonly onBeforeDrawObservable: Observable<Mesh>;
  19607. private _onBeforeDrawObserver;
  19608. /**
  19609. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19610. */
  19611. onBeforeDraw: () => void;
  19612. /**
  19613. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19614. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19615. */
  19616. delayLoadState: number;
  19617. /**
  19618. * Gets the list of instances created from this mesh
  19619. * it is not supposed to be modified manually.
  19620. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19621. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19622. */
  19623. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  19624. /**
  19625. * Gets the file containing delay loading data for this mesh
  19626. */
  19627. delayLoadingFile: string;
  19628. /** @hidden */
  19629. _binaryInfo: any;
  19630. private _LODLevels;
  19631. /**
  19632. * User defined function used to change how LOD level selection is done
  19633. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19634. */
  19635. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19636. private _morphTargetManager;
  19637. /**
  19638. * Gets or sets the morph target manager
  19639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19640. */
  19641. morphTargetManager: Nullable<MorphTargetManager>;
  19642. /** @hidden */
  19643. _creationDataStorage: Nullable<_CreationDataStorage>;
  19644. /** @hidden */
  19645. _geometry: Nullable<Geometry>;
  19646. /** @hidden */
  19647. _delayInfo: Array<string>;
  19648. /** @hidden */
  19649. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19650. /** @hidden */
  19651. _instanceDataStorage: _InstanceDataStorage;
  19652. private _effectiveMaterial;
  19653. /** @hidden */
  19654. _shouldGenerateFlatShading: boolean;
  19655. private _preActivateId;
  19656. /** @hidden */
  19657. _originalBuilderSideOrientation: number;
  19658. /**
  19659. * Use this property to change the original side orientation defined at construction time
  19660. */
  19661. overrideMaterialSideOrientation: Nullable<number>;
  19662. private _areNormalsFrozen;
  19663. private _sourcePositions;
  19664. private _sourceNormals;
  19665. private _source;
  19666. private meshMap;
  19667. /**
  19668. * Gets the source mesh (the one used to clone this one from)
  19669. */
  19670. readonly source: Nullable<Mesh>;
  19671. /**
  19672. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19673. */
  19674. isUnIndexed: boolean;
  19675. /**
  19676. * @constructor
  19677. * @param name The value used by scene.getMeshByName() to do a lookup.
  19678. * @param scene The scene to add this mesh to.
  19679. * @param parent The parent of this mesh, if it has one
  19680. * @param source An optional Mesh from which geometry is shared, cloned.
  19681. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19682. * When false, achieved by calling a clone(), also passing False.
  19683. * This will make creation of children, recursive.
  19684. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19685. */
  19686. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19687. /**
  19688. * Gets the class name
  19689. * @returns the string "Mesh".
  19690. */
  19691. getClassName(): string;
  19692. /** @hidden */
  19693. readonly _isMesh: boolean;
  19694. /**
  19695. * Returns a description of this mesh
  19696. * @param fullDetails define if full details about this mesh must be used
  19697. * @returns a descriptive string representing this mesh
  19698. */
  19699. toString(fullDetails?: boolean): string;
  19700. /** @hidden */
  19701. _unBindEffect(): void;
  19702. /**
  19703. * Gets a boolean indicating if this mesh has LOD
  19704. */
  19705. readonly hasLODLevels: boolean;
  19706. /**
  19707. * Gets the list of MeshLODLevel associated with the current mesh
  19708. * @returns an array of MeshLODLevel
  19709. */
  19710. getLODLevels(): MeshLODLevel[];
  19711. private _sortLODLevels;
  19712. /**
  19713. * Add a mesh as LOD level triggered at the given distance.
  19714. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19715. * @param distance The distance from the center of the object to show this level
  19716. * @param mesh The mesh to be added as LOD level (can be null)
  19717. * @return This mesh (for chaining)
  19718. */
  19719. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19720. /**
  19721. * Returns the LOD level mesh at the passed distance or null if not found.
  19722. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19723. * @param distance The distance from the center of the object to show this level
  19724. * @returns a Mesh or `null`
  19725. */
  19726. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19727. /**
  19728. * Remove a mesh from the LOD array
  19729. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19730. * @param mesh defines the mesh to be removed
  19731. * @return This mesh (for chaining)
  19732. */
  19733. removeLODLevel(mesh: Mesh): Mesh;
  19734. /**
  19735. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19736. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19737. * @param camera defines the camera to use to compute distance
  19738. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19739. * @return This mesh (for chaining)
  19740. */
  19741. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19742. /**
  19743. * Gets the mesh internal Geometry object
  19744. */
  19745. readonly geometry: Nullable<Geometry>;
  19746. /**
  19747. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19748. * @returns the total number of vertices
  19749. */
  19750. getTotalVertices(): number;
  19751. /**
  19752. * Returns the content of an associated vertex buffer
  19753. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19754. * - VertexBuffer.PositionKind
  19755. * - VertexBuffer.UVKind
  19756. * - VertexBuffer.UV2Kind
  19757. * - VertexBuffer.UV3Kind
  19758. * - VertexBuffer.UV4Kind
  19759. * - VertexBuffer.UV5Kind
  19760. * - VertexBuffer.UV6Kind
  19761. * - VertexBuffer.ColorKind
  19762. * - VertexBuffer.MatricesIndicesKind
  19763. * - VertexBuffer.MatricesIndicesExtraKind
  19764. * - VertexBuffer.MatricesWeightsKind
  19765. * - VertexBuffer.MatricesWeightsExtraKind
  19766. * @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
  19767. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19768. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19769. */
  19770. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19771. /**
  19772. * Returns the mesh VertexBuffer object from the requested `kind`
  19773. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19774. * - VertexBuffer.PositionKind
  19775. * - VertexBuffer.UVKind
  19776. * - VertexBuffer.UV2Kind
  19777. * - VertexBuffer.UV3Kind
  19778. * - VertexBuffer.UV4Kind
  19779. * - VertexBuffer.UV5Kind
  19780. * - VertexBuffer.UV6Kind
  19781. * - VertexBuffer.ColorKind
  19782. * - VertexBuffer.MatricesIndicesKind
  19783. * - VertexBuffer.MatricesIndicesExtraKind
  19784. * - VertexBuffer.MatricesWeightsKind
  19785. * - VertexBuffer.MatricesWeightsExtraKind
  19786. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19787. */
  19788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19789. /**
  19790. * Tests if a specific vertex buffer is associated with this mesh
  19791. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19792. * - VertexBuffer.PositionKind
  19793. * - VertexBuffer.UVKind
  19794. * - VertexBuffer.UV2Kind
  19795. * - VertexBuffer.UV3Kind
  19796. * - VertexBuffer.UV4Kind
  19797. * - VertexBuffer.UV5Kind
  19798. * - VertexBuffer.UV6Kind
  19799. * - VertexBuffer.ColorKind
  19800. * - VertexBuffer.MatricesIndicesKind
  19801. * - VertexBuffer.MatricesIndicesExtraKind
  19802. * - VertexBuffer.MatricesWeightsKind
  19803. * - VertexBuffer.MatricesWeightsExtraKind
  19804. * @returns a boolean
  19805. */
  19806. isVerticesDataPresent(kind: string): boolean;
  19807. /**
  19808. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19809. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19810. * - VertexBuffer.PositionKind
  19811. * - VertexBuffer.UVKind
  19812. * - VertexBuffer.UV2Kind
  19813. * - VertexBuffer.UV3Kind
  19814. * - VertexBuffer.UV4Kind
  19815. * - VertexBuffer.UV5Kind
  19816. * - VertexBuffer.UV6Kind
  19817. * - VertexBuffer.ColorKind
  19818. * - VertexBuffer.MatricesIndicesKind
  19819. * - VertexBuffer.MatricesIndicesExtraKind
  19820. * - VertexBuffer.MatricesWeightsKind
  19821. * - VertexBuffer.MatricesWeightsExtraKind
  19822. * @returns a boolean
  19823. */
  19824. isVertexBufferUpdatable(kind: string): boolean;
  19825. /**
  19826. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19827. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19828. * - VertexBuffer.PositionKind
  19829. * - VertexBuffer.UVKind
  19830. * - VertexBuffer.UV2Kind
  19831. * - VertexBuffer.UV3Kind
  19832. * - VertexBuffer.UV4Kind
  19833. * - VertexBuffer.UV5Kind
  19834. * - VertexBuffer.UV6Kind
  19835. * - VertexBuffer.ColorKind
  19836. * - VertexBuffer.MatricesIndicesKind
  19837. * - VertexBuffer.MatricesIndicesExtraKind
  19838. * - VertexBuffer.MatricesWeightsKind
  19839. * - VertexBuffer.MatricesWeightsExtraKind
  19840. * @returns an array of strings
  19841. */
  19842. getVerticesDataKinds(): string[];
  19843. /**
  19844. * Returns a positive integer : the total number of indices in this mesh geometry.
  19845. * @returns the numner of indices or zero if the mesh has no geometry.
  19846. */
  19847. getTotalIndices(): number;
  19848. /**
  19849. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19850. * @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.
  19851. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19852. * @returns the indices array or an empty array if the mesh has no geometry
  19853. */
  19854. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19855. readonly isBlocked: boolean;
  19856. /**
  19857. * Determine if the current mesh is ready to be rendered
  19858. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19859. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19860. * @returns true if all associated assets are ready (material, textures, shaders)
  19861. */
  19862. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19863. /**
  19864. * 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.
  19865. */
  19866. readonly areNormalsFrozen: boolean;
  19867. /**
  19868. * 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.
  19869. * @returns the current mesh
  19870. */
  19871. freezeNormals(): Mesh;
  19872. /**
  19873. * 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
  19874. * @returns the current mesh
  19875. */
  19876. unfreezeNormals(): Mesh;
  19877. /**
  19878. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19879. */
  19880. overridenInstanceCount: number;
  19881. /** @hidden */
  19882. _preActivate(): Mesh;
  19883. /** @hidden */
  19884. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19885. /** @hidden */
  19886. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19887. /**
  19888. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19889. * This means the mesh underlying bounding box and sphere are recomputed.
  19890. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19891. * @returns the current mesh
  19892. */
  19893. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19894. /** @hidden */
  19895. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19896. /**
  19897. * This function will subdivide the mesh into multiple submeshes
  19898. * @param count defines the expected number of submeshes
  19899. */
  19900. subdivide(count: number): void;
  19901. /**
  19902. * Copy a FloatArray into a specific associated vertex buffer
  19903. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19904. * - VertexBuffer.PositionKind
  19905. * - VertexBuffer.UVKind
  19906. * - VertexBuffer.UV2Kind
  19907. * - VertexBuffer.UV3Kind
  19908. * - VertexBuffer.UV4Kind
  19909. * - VertexBuffer.UV5Kind
  19910. * - VertexBuffer.UV6Kind
  19911. * - VertexBuffer.ColorKind
  19912. * - VertexBuffer.MatricesIndicesKind
  19913. * - VertexBuffer.MatricesIndicesExtraKind
  19914. * - VertexBuffer.MatricesWeightsKind
  19915. * - VertexBuffer.MatricesWeightsExtraKind
  19916. * @param data defines the data source
  19917. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19918. * @param stride defines the data stride size (can be null)
  19919. * @returns the current mesh
  19920. */
  19921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19922. /**
  19923. * Flags an associated vertex buffer as updatable
  19924. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19925. * - VertexBuffer.PositionKind
  19926. * - VertexBuffer.UVKind
  19927. * - VertexBuffer.UV2Kind
  19928. * - VertexBuffer.UV3Kind
  19929. * - VertexBuffer.UV4Kind
  19930. * - VertexBuffer.UV5Kind
  19931. * - VertexBuffer.UV6Kind
  19932. * - VertexBuffer.ColorKind
  19933. * - VertexBuffer.MatricesIndicesKind
  19934. * - VertexBuffer.MatricesIndicesExtraKind
  19935. * - VertexBuffer.MatricesWeightsKind
  19936. * - VertexBuffer.MatricesWeightsExtraKind
  19937. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19938. */
  19939. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19940. /**
  19941. * Sets the mesh global Vertex Buffer
  19942. * @param buffer defines the buffer to use
  19943. * @returns the current mesh
  19944. */
  19945. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19946. /**
  19947. * Update a specific associated vertex buffer
  19948. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19949. * - VertexBuffer.PositionKind
  19950. * - VertexBuffer.UVKind
  19951. * - VertexBuffer.UV2Kind
  19952. * - VertexBuffer.UV3Kind
  19953. * - VertexBuffer.UV4Kind
  19954. * - VertexBuffer.UV5Kind
  19955. * - VertexBuffer.UV6Kind
  19956. * - VertexBuffer.ColorKind
  19957. * - VertexBuffer.MatricesIndicesKind
  19958. * - VertexBuffer.MatricesIndicesExtraKind
  19959. * - VertexBuffer.MatricesWeightsKind
  19960. * - VertexBuffer.MatricesWeightsExtraKind
  19961. * @param data defines the data source
  19962. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19963. * @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)
  19964. * @returns the current mesh
  19965. */
  19966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19967. /**
  19968. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19969. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19970. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19971. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19972. * @returns the current mesh
  19973. */
  19974. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19975. /**
  19976. * Creates a un-shared specific occurence of the geometry for the mesh.
  19977. * @returns the current mesh
  19978. */
  19979. makeGeometryUnique(): Mesh;
  19980. /**
  19981. * Set the index buffer of this mesh
  19982. * @param indices defines the source data
  19983. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19984. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19985. * @returns the current mesh
  19986. */
  19987. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19988. /**
  19989. * Update the current index buffer
  19990. * @param indices defines the source data
  19991. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19992. * @returns the current mesh
  19993. */
  19994. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19995. /**
  19996. * Invert the geometry to move from a right handed system to a left handed one.
  19997. * @returns the current mesh
  19998. */
  19999. toLeftHanded(): Mesh;
  20000. /** @hidden */
  20001. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20002. /** @hidden */
  20003. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20004. /**
  20005. * Registers for this mesh a javascript function called just before the rendering process
  20006. * @param func defines the function to call before rendering this mesh
  20007. * @returns the current mesh
  20008. */
  20009. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20010. /**
  20011. * Disposes a previously registered javascript function called before the rendering
  20012. * @param func defines the function to remove
  20013. * @returns the current mesh
  20014. */
  20015. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20016. /**
  20017. * Registers for this mesh a javascript function called just after the rendering is complete
  20018. * @param func defines the function to call after rendering this mesh
  20019. * @returns the current mesh
  20020. */
  20021. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20022. /**
  20023. * Disposes a previously registered javascript function called after the rendering.
  20024. * @param func defines the function to remove
  20025. * @returns the current mesh
  20026. */
  20027. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20028. /** @hidden */
  20029. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20030. /** @hidden */
  20031. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20032. /** @hidden */
  20033. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20034. /**
  20035. * 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
  20036. * @param subMesh defines the subMesh to render
  20037. * @param enableAlphaMode defines if alpha mode can be changed
  20038. * @returns the current mesh
  20039. */
  20040. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20041. private _onBeforeDraw;
  20042. /**
  20043. * Renormalize the mesh and patch it up if there are no weights
  20044. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20045. * However in the case of zero weights then we set just a single influence to 1.
  20046. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20047. */
  20048. cleanMatrixWeights(): void;
  20049. private normalizeSkinFourWeights;
  20050. private normalizeSkinWeightsAndExtra;
  20051. /**
  20052. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20053. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20054. * the user know there was an issue with importing the mesh
  20055. * @returns a validation object with skinned, valid and report string
  20056. */
  20057. validateSkinning(): {
  20058. skinned: boolean;
  20059. valid: boolean;
  20060. report: string;
  20061. };
  20062. /** @hidden */
  20063. _checkDelayState(): Mesh;
  20064. private _queueLoad;
  20065. /**
  20066. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20067. * A mesh is in the frustum if its bounding box intersects the frustum
  20068. * @param frustumPlanes defines the frustum to test
  20069. * @returns true if the mesh is in the frustum planes
  20070. */
  20071. isInFrustum(frustumPlanes: Plane[]): boolean;
  20072. /**
  20073. * Sets the mesh material by the material or multiMaterial `id` property
  20074. * @param id is a string identifying the material or the multiMaterial
  20075. * @returns the current mesh
  20076. */
  20077. setMaterialByID(id: string): Mesh;
  20078. /**
  20079. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20080. * @returns an array of IAnimatable
  20081. */
  20082. getAnimatables(): IAnimatable[];
  20083. /**
  20084. * Modifies the mesh geometry according to the passed transformation matrix.
  20085. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20086. * The mesh normals are modified using the same transformation.
  20087. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20088. * @param transform defines the transform matrix to use
  20089. * @see http://doc.babylonjs.com/resources/baking_transformations
  20090. * @returns the current mesh
  20091. */
  20092. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20093. /**
  20094. * Modifies the mesh geometry according to its own current World Matrix.
  20095. * The mesh World Matrix is then reset.
  20096. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20097. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20098. * @see http://doc.babylonjs.com/resources/baking_transformations
  20099. * @returns the current mesh
  20100. */
  20101. bakeCurrentTransformIntoVertices(): Mesh;
  20102. /** @hidden */
  20103. readonly _positions: Nullable<Vector3[]>;
  20104. /** @hidden */
  20105. _resetPointsArrayCache(): Mesh;
  20106. /** @hidden */
  20107. _generatePointsArray(): boolean;
  20108. /**
  20109. * Returns a new Mesh object generated from the current mesh properties.
  20110. * This method must not get confused with createInstance()
  20111. * @param name is a string, the name given to the new mesh
  20112. * @param newParent can be any Node object (default `null`)
  20113. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20114. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20115. * @returns a new mesh
  20116. */
  20117. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20118. /**
  20119. * Releases resources associated with this mesh.
  20120. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20121. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20122. */
  20123. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20124. /**
  20125. * Modifies the mesh geometry according to a displacement map.
  20126. * 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.
  20127. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20128. * @param url is a string, the URL from the image file is to be downloaded.
  20129. * @param minHeight is the lower limit of the displacement.
  20130. * @param maxHeight is the upper limit of the displacement.
  20131. * @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.
  20132. * @param uvOffset is an optional vector2 used to offset UV.
  20133. * @param uvScale is an optional vector2 used to scale UV.
  20134. * @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.
  20135. * @returns the Mesh.
  20136. */
  20137. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20138. /**
  20139. * Modifies the mesh geometry according to a displacementMap buffer.
  20140. * 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.
  20141. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20142. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20143. * @param heightMapWidth is the width of the buffer image.
  20144. * @param heightMapHeight is the height of the buffer image.
  20145. * @param minHeight is the lower limit of the displacement.
  20146. * @param maxHeight is the upper limit of the displacement.
  20147. * @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.
  20148. * @param uvOffset is an optional vector2 used to offset UV.
  20149. * @param uvScale is an optional vector2 used to scale UV.
  20150. * @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.
  20151. * @returns the Mesh.
  20152. */
  20153. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20154. /**
  20155. * Modify the mesh to get a flat shading rendering.
  20156. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20157. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20158. * @returns current mesh
  20159. */
  20160. convertToFlatShadedMesh(): Mesh;
  20161. /**
  20162. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20163. * In other words, more vertices, no more indices and a single bigger VBO.
  20164. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20165. * @returns current mesh
  20166. */
  20167. convertToUnIndexedMesh(): Mesh;
  20168. /**
  20169. * Inverses facet orientations.
  20170. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20171. * @param flipNormals will also inverts the normals
  20172. * @returns current mesh
  20173. */
  20174. flipFaces(flipNormals?: boolean): Mesh;
  20175. /** @hidden */
  20176. static _instancedMeshFactory: (name: string, mesh: Mesh) => import("babylonjs/Meshes/instancedMesh").InstancedMesh;
  20177. /**
  20178. * Creates a new InstancedMesh object from the mesh model.
  20179. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20180. * @param name defines the name of the new instance
  20181. * @returns a new InstancedMesh
  20182. */
  20183. createInstance(name: string): InstancedMesh;
  20184. /**
  20185. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20186. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20187. * @returns the current mesh
  20188. */
  20189. synchronizeInstances(): Mesh;
  20190. /**
  20191. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20192. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20193. * This should be used together with the simplification to avoid disappearing triangles.
  20194. * @param successCallback an optional success callback to be called after the optimization finished.
  20195. * @returns the current mesh
  20196. */
  20197. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20198. /**
  20199. * Serialize current mesh
  20200. * @param serializationObject defines the object which will receive the serialization data
  20201. */
  20202. serialize(serializationObject: any): void;
  20203. /** @hidden */
  20204. _syncGeometryWithMorphTargetManager(): void;
  20205. /** @hidden */
  20206. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20207. /**
  20208. * Returns a new Mesh object parsed from the source provided.
  20209. * @param parsedMesh is the source
  20210. * @param scene defines the hosting scene
  20211. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20212. * @returns a new Mesh
  20213. */
  20214. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20215. /**
  20216. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20217. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20218. * @param name defines the name of the mesh to create
  20219. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20220. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20221. * @param closePath creates a seam between the first and the last points of each path of the path array
  20222. * @param offset is taken in account only if the `pathArray` is containing a single path
  20223. * @param scene defines the hosting scene
  20224. * @param updatable defines if the mesh must be flagged as updatable
  20225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20226. * @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)
  20227. * @returns a new Mesh
  20228. */
  20229. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20230. /**
  20231. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20232. * @param name defines the name of the mesh to create
  20233. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20234. * @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
  20235. * @param scene defines the hosting scene
  20236. * @param updatable defines if the mesh must be flagged as updatable
  20237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20238. * @returns a new Mesh
  20239. */
  20240. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20241. /**
  20242. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20243. * @param name defines the name of the mesh to create
  20244. * @param size sets the size (float) of each box side (default 1)
  20245. * @param scene defines the hosting scene
  20246. * @param updatable defines if the mesh must be flagged as updatable
  20247. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20248. * @returns a new Mesh
  20249. */
  20250. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20251. /**
  20252. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20253. * @param name defines the name of the mesh to create
  20254. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20255. * @param diameter sets the diameter size (float) of the sphere (default 1)
  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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20262. /**
  20263. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  20266. * @param diameterTop set the top cap diameter (floats, default 1)
  20267. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20268. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20269. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20270. * @param scene defines the hosting scene
  20271. * @param updatable defines if the mesh must be flagged as updatable
  20272. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20273. * @returns a new Mesh
  20274. */
  20275. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20276. /**
  20277. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20278. * @param name defines the name of the mesh to create
  20279. * @param diameter sets the diameter size (float) of the torus (default 1)
  20280. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20281. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20282. * @param scene defines the hosting scene
  20283. * @param updatable defines if the mesh must be flagged as updatable
  20284. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20285. * @returns a new Mesh
  20286. */
  20287. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20288. /**
  20289. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20290. * @param name defines the name of the mesh to create
  20291. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20292. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20293. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20294. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20295. * @param p the number of windings on X axis (positive integers, default 2)
  20296. * @param q the number of windings on Y axis (positive integers, default 3)
  20297. * @param scene defines the hosting scene
  20298. * @param updatable defines if the mesh must be flagged as updatable
  20299. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20300. * @returns a new Mesh
  20301. */
  20302. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20303. /**
  20304. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20305. * @param name defines the name of the mesh to create
  20306. * @param points is an array successive Vector3
  20307. * @param scene defines the hosting scene
  20308. * @param updatable defines if the mesh must be flagged as updatable
  20309. * @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).
  20310. * @returns a new Mesh
  20311. */
  20312. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20313. /**
  20314. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20315. * @param name defines the name of the mesh to create
  20316. * @param points is an array successive Vector3
  20317. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20318. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20319. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20320. * @param scene defines the hosting scene
  20321. * @param updatable defines if the mesh must be flagged as updatable
  20322. * @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)
  20323. * @returns a new Mesh
  20324. */
  20325. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20326. /**
  20327. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20328. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20329. * 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.
  20330. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20331. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20332. * Remember you can only change the shape positions, not their number when updating a polygon.
  20333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20334. * @param name defines the name of the mesh to create
  20335. * @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
  20336. * @param scene defines the hosting scene
  20337. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20338. * @param updatable defines if the mesh must be flagged as updatable
  20339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20340. * @param earcutInjection can be used to inject your own earcut reference
  20341. * @returns a new Mesh
  20342. */
  20343. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20344. /**
  20345. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20346. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20347. * @param name defines the name of the mesh to create
  20348. * @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
  20349. * @param depth defines the height of extrusion
  20350. * @param scene defines the hosting scene
  20351. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20352. * @param updatable defines if the mesh must be flagged as updatable
  20353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20354. * @param earcutInjection can be used to inject your own earcut reference
  20355. * @returns a new Mesh
  20356. */
  20357. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20358. /**
  20359. * Creates an extruded shape mesh.
  20360. * 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
  20361. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20362. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20363. * @param name defines the name of the mesh to create
  20364. * @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
  20365. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20366. * @param scale is the value to scale the shape
  20367. * @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
  20368. * @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
  20369. * @param scene defines the hosting scene
  20370. * @param updatable defines if the mesh must be flagged as updatable
  20371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20372. * @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)
  20373. * @returns a new Mesh
  20374. */
  20375. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20376. /**
  20377. * Creates an custom extruded shape mesh.
  20378. * The custom extrusion is a parametric shape.
  20379. * It has no predefined shape. Its final shape will depend on the input parameters.
  20380. * Please consider using the same method from the MeshBuilder class instead
  20381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20382. * @param name defines the name of the mesh to create
  20383. * @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
  20384. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20385. * @param scaleFunction is a custom Javascript function called on each path point
  20386. * @param rotationFunction is a custom Javascript function called on each path point
  20387. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20388. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20389. * @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
  20390. * @param scene defines the hosting scene
  20391. * @param updatable defines if the mesh must be flagged as updatable
  20392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20393. * @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)
  20394. * @returns a new Mesh
  20395. */
  20396. 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;
  20397. /**
  20398. * Creates lathe mesh.
  20399. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20400. * Please consider using the same method from the MeshBuilder class instead
  20401. * @param name defines the name of the mesh to create
  20402. * @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
  20403. * @param radius is the radius value of the lathe
  20404. * @param tessellation is the side number of the lathe.
  20405. * @param scene defines the hosting scene
  20406. * @param updatable defines if the mesh must be flagged as updatable
  20407. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20408. * @returns a new Mesh
  20409. */
  20410. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20411. /**
  20412. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20413. * @param name defines the name of the mesh to create
  20414. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20415. * @param scene defines the hosting scene
  20416. * @param updatable defines if the mesh must be flagged as updatable
  20417. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20418. * @returns a new Mesh
  20419. */
  20420. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20421. /**
  20422. * Creates a ground mesh.
  20423. * Please consider using the same method from the MeshBuilder class instead
  20424. * @param name defines the name of the mesh to create
  20425. * @param width set the width of the ground
  20426. * @param height set the height of the ground
  20427. * @param subdivisions sets the number of subdivisions per side
  20428. * @param scene defines the hosting scene
  20429. * @param updatable defines if the mesh must be flagged as updatable
  20430. * @returns a new Mesh
  20431. */
  20432. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20433. /**
  20434. * Creates a tiled ground mesh.
  20435. * Please consider using the same method from the MeshBuilder class instead
  20436. * @param name defines the name of the mesh to create
  20437. * @param xmin set the ground minimum X coordinate
  20438. * @param zmin set the ground minimum Y coordinate
  20439. * @param xmax set the ground maximum X coordinate
  20440. * @param zmax set the ground maximum Z coordinate
  20441. * @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
  20442. * @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
  20443. * @param scene defines the hosting scene
  20444. * @param updatable defines if the mesh must be flagged as updatable
  20445. * @returns a new Mesh
  20446. */
  20447. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20448. w: number;
  20449. h: number;
  20450. }, precision: {
  20451. w: number;
  20452. h: number;
  20453. }, scene: Scene, updatable?: boolean): Mesh;
  20454. /**
  20455. * Creates a ground mesh from a height map.
  20456. * Please consider using the same method from the MeshBuilder class instead
  20457. * @see http://doc.babylonjs.com/babylon101/height_map
  20458. * @param name defines the name of the mesh to create
  20459. * @param url sets the URL of the height map image resource
  20460. * @param width set the ground width size
  20461. * @param height set the ground height size
  20462. * @param subdivisions sets the number of subdivision per side
  20463. * @param minHeight is the minimum altitude on the ground
  20464. * @param maxHeight is the maximum altitude on the ground
  20465. * @param scene defines the hosting scene
  20466. * @param updatable defines if the mesh must be flagged as updatable
  20467. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20468. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20469. * @returns a new Mesh
  20470. */
  20471. 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;
  20472. /**
  20473. * Creates a tube mesh.
  20474. * The tube is a parametric shape.
  20475. * It has no predefined shape. Its final shape will depend on the input parameters.
  20476. * Please consider using the same method from the MeshBuilder class instead
  20477. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20478. * @param name defines the name of the mesh to create
  20479. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20480. * @param radius sets the tube radius size
  20481. * @param tessellation is the number of sides on the tubular surface
  20482. * @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
  20483. * @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
  20484. * @param scene defines the hosting scene
  20485. * @param updatable defines if the mesh must be flagged as updatable
  20486. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20487. * @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)
  20488. * @returns a new Mesh
  20489. */
  20490. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20491. (i: number, distance: number): number;
  20492. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20493. /**
  20494. * Creates a polyhedron mesh.
  20495. * Please consider using the same method from the MeshBuilder class instead.
  20496. * * 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
  20497. * * The parameter `size` (positive float, default 1) sets the polygon size
  20498. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20499. * * 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`
  20500. * * 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
  20501. * * 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)`)
  20502. * * 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
  20503. * * 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
  20504. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20505. * * If you create a double-sided mesh, you can choose what parts of 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
  20506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20507. * @param name defines the name of the mesh to create
  20508. * @param options defines the options used to create the mesh
  20509. * @param scene defines the hosting scene
  20510. * @returns a new Mesh
  20511. */
  20512. static CreatePolyhedron(name: string, options: {
  20513. type?: number;
  20514. size?: number;
  20515. sizeX?: number;
  20516. sizeY?: number;
  20517. sizeZ?: number;
  20518. custom?: any;
  20519. faceUV?: Vector4[];
  20520. faceColors?: Color4[];
  20521. updatable?: boolean;
  20522. sideOrientation?: number;
  20523. }, scene: Scene): Mesh;
  20524. /**
  20525. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20526. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20527. * * 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`)
  20528. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20529. * * 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
  20530. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20531. * * If you create a double-sided mesh, you can choose what parts of 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
  20532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20533. * @param name defines the name of the mesh
  20534. * @param options defines the options used to create the mesh
  20535. * @param scene defines the hosting scene
  20536. * @returns a new Mesh
  20537. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20538. */
  20539. static CreateIcoSphere(name: string, options: {
  20540. radius?: number;
  20541. flat?: boolean;
  20542. subdivisions?: number;
  20543. sideOrientation?: number;
  20544. updatable?: boolean;
  20545. }, scene: Scene): Mesh;
  20546. /**
  20547. * Creates a decal mesh.
  20548. * Please consider using the same method from the MeshBuilder class instead.
  20549. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20550. * @param name defines the name of the mesh
  20551. * @param sourceMesh defines the mesh receiving the decal
  20552. * @param position sets the position of the decal in world coordinates
  20553. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20554. * @param size sets the decal scaling
  20555. * @param angle sets the angle to rotate the decal
  20556. * @returns a new Mesh
  20557. */
  20558. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20559. /**
  20560. * Prepare internal position array for software CPU skinning
  20561. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20562. */
  20563. setPositionsForCPUSkinning(): Float32Array;
  20564. /**
  20565. * Prepare internal normal array for software CPU skinning
  20566. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20567. */
  20568. setNormalsForCPUSkinning(): Float32Array;
  20569. /**
  20570. * Updates the vertex buffer by applying transformation from the bones
  20571. * @param skeleton defines the skeleton to apply to current mesh
  20572. * @returns the current mesh
  20573. */
  20574. applySkeleton(skeleton: Skeleton): Mesh;
  20575. /**
  20576. * 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
  20577. * @param meshes defines the list of meshes to scan
  20578. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20579. */
  20580. static MinMax(meshes: AbstractMesh[]): {
  20581. min: Vector3;
  20582. max: Vector3;
  20583. };
  20584. /**
  20585. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20586. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20587. * @returns a vector3
  20588. */
  20589. static Center(meshesOrMinMaxVector: {
  20590. min: Vector3;
  20591. max: Vector3;
  20592. } | AbstractMesh[]): Vector3;
  20593. /**
  20594. * Merge the array of meshes into a single mesh for performance reasons.
  20595. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20596. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20597. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20598. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20599. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20600. * @returns a new mesh
  20601. */
  20602. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  20603. /** @hidden */
  20604. addInstance(instance: InstancedMesh): void;
  20605. /** @hidden */
  20606. removeInstance(instance: InstancedMesh): void;
  20607. }
  20608. }
  20609. declare module "babylonjs/Actions/action" {
  20610. import { Observable } from "babylonjs/Misc/observable";
  20611. import { Condition } from "babylonjs/Actions/condition";
  20612. import { ActionManager } from "babylonjs/Actions/actionManager";
  20613. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20614. /**
  20615. * Interface used to define Action
  20616. */
  20617. export interface IAction {
  20618. /**
  20619. * Trigger for the action
  20620. */
  20621. trigger: number;
  20622. /** the trigger, with or without parameters, for the action */
  20623. triggerOptions: any;
  20624. /**
  20625. * Gets the trigger parameters
  20626. * @returns the trigger parameters
  20627. */
  20628. getTriggerParameter(): any;
  20629. /**
  20630. * Internal only - executes current action event
  20631. * @hidden
  20632. */
  20633. _executeCurrent(evt?: ActionEvent): void;
  20634. /**
  20635. * Serialize placeholder for child classes
  20636. * @param parent of child
  20637. * @returns the serialized object
  20638. */
  20639. serialize(parent: any): any;
  20640. }
  20641. /**
  20642. * The action to be carried out following a trigger
  20643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  20644. */
  20645. export class Action implements IAction {
  20646. /** the trigger, with or without parameters, for the action */
  20647. triggerOptions: any;
  20648. /**
  20649. * Trigger for the action
  20650. */
  20651. trigger: number;
  20652. /**
  20653. * Internal only - manager for action
  20654. * @hidden
  20655. */
  20656. _actionManager: ActionManager;
  20657. private _nextActiveAction;
  20658. private _child;
  20659. private _condition?;
  20660. private _triggerParameter;
  20661. /**
  20662. * An event triggered prior to action being executed.
  20663. */
  20664. onBeforeExecuteObservable: Observable<Action>;
  20665. /**
  20666. * Creates a new Action
  20667. * @param triggerOptions the trigger, with or without parameters, for the action
  20668. * @param condition an optional determinant of action
  20669. */
  20670. constructor(
  20671. /** the trigger, with or without parameters, for the action */
  20672. triggerOptions: any, condition?: Condition);
  20673. /**
  20674. * Internal only
  20675. * @hidden
  20676. */
  20677. _prepare(): void;
  20678. /**
  20679. * Gets the trigger parameters
  20680. * @returns the trigger parameters
  20681. */
  20682. getTriggerParameter(): any;
  20683. /**
  20684. * Internal only - executes current action event
  20685. * @hidden
  20686. */
  20687. _executeCurrent(evt?: ActionEvent): void;
  20688. /**
  20689. * Execute placeholder for child classes
  20690. * @param evt optional action event
  20691. */
  20692. execute(evt?: ActionEvent): void;
  20693. /**
  20694. * Skips to next active action
  20695. */
  20696. skipToNextActiveAction(): void;
  20697. /**
  20698. * Adds action to chain of actions, may be a DoNothingAction
  20699. * @param action defines the next action to execute
  20700. * @returns The action passed in
  20701. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20702. */
  20703. then(action: Action): Action;
  20704. /**
  20705. * Internal only
  20706. * @hidden
  20707. */
  20708. _getProperty(propertyPath: string): string;
  20709. /**
  20710. * Internal only
  20711. * @hidden
  20712. */
  20713. _getEffectiveTarget(target: any, propertyPath: string): any;
  20714. /**
  20715. * Serialize placeholder for child classes
  20716. * @param parent of child
  20717. * @returns the serialized object
  20718. */
  20719. serialize(parent: any): any;
  20720. /**
  20721. * Internal only called by serialize
  20722. * @hidden
  20723. */
  20724. protected _serialize(serializedAction: any, parent?: any): any;
  20725. /**
  20726. * Internal only
  20727. * @hidden
  20728. */
  20729. static _SerializeValueAsString: (value: any) => string;
  20730. /**
  20731. * Internal only
  20732. * @hidden
  20733. */
  20734. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  20735. name: string;
  20736. targetType: string;
  20737. value: string;
  20738. };
  20739. }
  20740. }
  20741. declare module "babylonjs/Actions/condition" {
  20742. import { ActionManager } from "babylonjs/Actions/actionManager";
  20743. /**
  20744. * A Condition applied to an Action
  20745. */
  20746. export class Condition {
  20747. /**
  20748. * Internal only - manager for action
  20749. * @hidden
  20750. */
  20751. _actionManager: ActionManager;
  20752. /**
  20753. * Internal only
  20754. * @hidden
  20755. */
  20756. _evaluationId: number;
  20757. /**
  20758. * Internal only
  20759. * @hidden
  20760. */
  20761. _currentResult: boolean;
  20762. /**
  20763. * Creates a new Condition
  20764. * @param actionManager the manager of the action the condition is applied to
  20765. */
  20766. constructor(actionManager: ActionManager);
  20767. /**
  20768. * Check if the current condition is valid
  20769. * @returns a boolean
  20770. */
  20771. isValid(): boolean;
  20772. /**
  20773. * Internal only
  20774. * @hidden
  20775. */
  20776. _getProperty(propertyPath: string): string;
  20777. /**
  20778. * Internal only
  20779. * @hidden
  20780. */
  20781. _getEffectiveTarget(target: any, propertyPath: string): any;
  20782. /**
  20783. * Serialize placeholder for child classes
  20784. * @returns the serialized object
  20785. */
  20786. serialize(): any;
  20787. /**
  20788. * Internal only
  20789. * @hidden
  20790. */
  20791. protected _serialize(serializedCondition: any): any;
  20792. }
  20793. /**
  20794. * Defines specific conditional operators as extensions of Condition
  20795. */
  20796. export class ValueCondition extends Condition {
  20797. /** path to specify the property of the target the conditional operator uses */
  20798. propertyPath: string;
  20799. /** the value compared by the conditional operator against the current value of the property */
  20800. value: any;
  20801. /** the conditional operator, default ValueCondition.IsEqual */
  20802. operator: number;
  20803. /**
  20804. * Internal only
  20805. * @hidden
  20806. */
  20807. private static _IsEqual;
  20808. /**
  20809. * Internal only
  20810. * @hidden
  20811. */
  20812. private static _IsDifferent;
  20813. /**
  20814. * Internal only
  20815. * @hidden
  20816. */
  20817. private static _IsGreater;
  20818. /**
  20819. * Internal only
  20820. * @hidden
  20821. */
  20822. private static _IsLesser;
  20823. /**
  20824. * returns the number for IsEqual
  20825. */
  20826. static readonly IsEqual: number;
  20827. /**
  20828. * Returns the number for IsDifferent
  20829. */
  20830. static readonly IsDifferent: number;
  20831. /**
  20832. * Returns the number for IsGreater
  20833. */
  20834. static readonly IsGreater: number;
  20835. /**
  20836. * Returns the number for IsLesser
  20837. */
  20838. static readonly IsLesser: number;
  20839. /**
  20840. * Internal only The action manager for the condition
  20841. * @hidden
  20842. */
  20843. _actionManager: ActionManager;
  20844. /**
  20845. * Internal only
  20846. * @hidden
  20847. */
  20848. private _target;
  20849. /**
  20850. * Internal only
  20851. * @hidden
  20852. */
  20853. private _effectiveTarget;
  20854. /**
  20855. * Internal only
  20856. * @hidden
  20857. */
  20858. private _property;
  20859. /**
  20860. * Creates a new ValueCondition
  20861. * @param actionManager manager for the action the condition applies to
  20862. * @param target for the action
  20863. * @param propertyPath path to specify the property of the target the conditional operator uses
  20864. * @param value the value compared by the conditional operator against the current value of the property
  20865. * @param operator the conditional operator, default ValueCondition.IsEqual
  20866. */
  20867. constructor(actionManager: ActionManager, target: any,
  20868. /** path to specify the property of the target the conditional operator uses */
  20869. propertyPath: string,
  20870. /** the value compared by the conditional operator against the current value of the property */
  20871. value: any,
  20872. /** the conditional operator, default ValueCondition.IsEqual */
  20873. operator?: number);
  20874. /**
  20875. * Compares the given value with the property value for the specified conditional operator
  20876. * @returns the result of the comparison
  20877. */
  20878. isValid(): boolean;
  20879. /**
  20880. * Serialize the ValueCondition into a JSON compatible object
  20881. * @returns serialization object
  20882. */
  20883. serialize(): any;
  20884. /**
  20885. * Gets the name of the conditional operator for the ValueCondition
  20886. * @param operator the conditional operator
  20887. * @returns the name
  20888. */
  20889. static GetOperatorName(operator: number): string;
  20890. }
  20891. /**
  20892. * Defines a predicate condition as an extension of Condition
  20893. */
  20894. export class PredicateCondition extends Condition {
  20895. /** defines the predicate function used to validate the condition */
  20896. predicate: () => boolean;
  20897. /**
  20898. * Internal only - manager for action
  20899. * @hidden
  20900. */
  20901. _actionManager: ActionManager;
  20902. /**
  20903. * Creates a new PredicateCondition
  20904. * @param actionManager manager for the action the condition applies to
  20905. * @param predicate defines the predicate function used to validate the condition
  20906. */
  20907. constructor(actionManager: ActionManager,
  20908. /** defines the predicate function used to validate the condition */
  20909. predicate: () => boolean);
  20910. /**
  20911. * @returns the validity of the predicate condition
  20912. */
  20913. isValid(): boolean;
  20914. }
  20915. /**
  20916. * Defines a state condition as an extension of Condition
  20917. */
  20918. export class StateCondition extends Condition {
  20919. /** Value to compare with target state */
  20920. value: string;
  20921. /**
  20922. * Internal only - manager for action
  20923. * @hidden
  20924. */
  20925. _actionManager: ActionManager;
  20926. /**
  20927. * Internal only
  20928. * @hidden
  20929. */
  20930. private _target;
  20931. /**
  20932. * Creates a new StateCondition
  20933. * @param actionManager manager for the action the condition applies to
  20934. * @param target of the condition
  20935. * @param value to compare with target state
  20936. */
  20937. constructor(actionManager: ActionManager, target: any,
  20938. /** Value to compare with target state */
  20939. value: string);
  20940. /**
  20941. * Gets a boolean indicating if the current condition is met
  20942. * @returns the validity of the state
  20943. */
  20944. isValid(): boolean;
  20945. /**
  20946. * Serialize the StateCondition into a JSON compatible object
  20947. * @returns serialization object
  20948. */
  20949. serialize(): any;
  20950. }
  20951. }
  20952. declare module "babylonjs/Actions/directActions" {
  20953. import { Action } from "babylonjs/Actions/action";
  20954. import { Condition } from "babylonjs/Actions/condition";
  20955. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20956. /**
  20957. * This defines an action responsible to toggle a boolean once triggered.
  20958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20959. */
  20960. export class SwitchBooleanAction extends Action {
  20961. /**
  20962. * The path to the boolean property in the target object
  20963. */
  20964. propertyPath: string;
  20965. private _target;
  20966. private _effectiveTarget;
  20967. private _property;
  20968. /**
  20969. * Instantiate the action
  20970. * @param triggerOptions defines the trigger options
  20971. * @param target defines the object containing the boolean
  20972. * @param propertyPath defines the path to the boolean property in the target object
  20973. * @param condition defines the trigger related conditions
  20974. */
  20975. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20976. /** @hidden */
  20977. _prepare(): void;
  20978. /**
  20979. * Execute the action toggle the boolean value.
  20980. */
  20981. execute(): void;
  20982. /**
  20983. * Serializes the actions and its related information.
  20984. * @param parent defines the object to serialize in
  20985. * @returns the serialized object
  20986. */
  20987. serialize(parent: any): any;
  20988. }
  20989. /**
  20990. * This defines an action responsible to set a the state field of the target
  20991. * to a desired value once triggered.
  20992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20993. */
  20994. export class SetStateAction extends Action {
  20995. /**
  20996. * The value to store in the state field.
  20997. */
  20998. value: string;
  20999. private _target;
  21000. /**
  21001. * Instantiate the action
  21002. * @param triggerOptions defines the trigger options
  21003. * @param target defines the object containing the state property
  21004. * @param value defines the value to store in the state field
  21005. * @param condition defines the trigger related conditions
  21006. */
  21007. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  21008. /**
  21009. * Execute the action and store the value on the target state property.
  21010. */
  21011. execute(): void;
  21012. /**
  21013. * Serializes the actions and its related information.
  21014. * @param parent defines the object to serialize in
  21015. * @returns the serialized object
  21016. */
  21017. serialize(parent: any): any;
  21018. }
  21019. /**
  21020. * This defines an action responsible to set a property of the target
  21021. * to a desired value once triggered.
  21022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21023. */
  21024. export class SetValueAction extends Action {
  21025. /**
  21026. * The path of the property to set in the target.
  21027. */
  21028. propertyPath: string;
  21029. /**
  21030. * The value to set in the property
  21031. */
  21032. value: any;
  21033. private _target;
  21034. private _effectiveTarget;
  21035. private _property;
  21036. /**
  21037. * Instantiate the action
  21038. * @param triggerOptions defines the trigger options
  21039. * @param target defines the object containing the property
  21040. * @param propertyPath defines the path of the property to set in the target
  21041. * @param value defines the value to set in the property
  21042. * @param condition defines the trigger related conditions
  21043. */
  21044. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  21045. /** @hidden */
  21046. _prepare(): void;
  21047. /**
  21048. * Execute the action and set the targetted property to the desired value.
  21049. */
  21050. execute(): void;
  21051. /**
  21052. * Serializes the actions and its related information.
  21053. * @param parent defines the object to serialize in
  21054. * @returns the serialized object
  21055. */
  21056. serialize(parent: any): any;
  21057. }
  21058. /**
  21059. * This defines an action responsible to increment the target value
  21060. * to a desired value once triggered.
  21061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21062. */
  21063. export class IncrementValueAction extends Action {
  21064. /**
  21065. * The path of the property to increment in the target.
  21066. */
  21067. propertyPath: string;
  21068. /**
  21069. * The value we should increment the property by.
  21070. */
  21071. value: any;
  21072. private _target;
  21073. private _effectiveTarget;
  21074. private _property;
  21075. /**
  21076. * Instantiate the action
  21077. * @param triggerOptions defines the trigger options
  21078. * @param target defines the object containing the property
  21079. * @param propertyPath defines the path of the property to increment in the target
  21080. * @param value defines the value value we should increment the property by
  21081. * @param condition defines the trigger related conditions
  21082. */
  21083. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  21084. /** @hidden */
  21085. _prepare(): void;
  21086. /**
  21087. * Execute the action and increment the target of the value amount.
  21088. */
  21089. execute(): void;
  21090. /**
  21091. * Serializes the actions and its related information.
  21092. * @param parent defines the object to serialize in
  21093. * @returns the serialized object
  21094. */
  21095. serialize(parent: any): any;
  21096. }
  21097. /**
  21098. * This defines an action responsible to start an animation once triggered.
  21099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21100. */
  21101. export class PlayAnimationAction extends Action {
  21102. /**
  21103. * Where the animation should start (animation frame)
  21104. */
  21105. from: number;
  21106. /**
  21107. * Where the animation should stop (animation frame)
  21108. */
  21109. to: number;
  21110. /**
  21111. * Define if the animation should loop or stop after the first play.
  21112. */
  21113. loop?: boolean;
  21114. private _target;
  21115. /**
  21116. * Instantiate the action
  21117. * @param triggerOptions defines the trigger options
  21118. * @param target defines the target animation or animation name
  21119. * @param from defines from where the animation should start (animation frame)
  21120. * @param end defines where the animation should stop (animation frame)
  21121. * @param loop defines if the animation should loop or stop after the first play
  21122. * @param condition defines the trigger related conditions
  21123. */
  21124. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  21125. /** @hidden */
  21126. _prepare(): void;
  21127. /**
  21128. * Execute the action and play the animation.
  21129. */
  21130. execute(): void;
  21131. /**
  21132. * Serializes the actions and its related information.
  21133. * @param parent defines the object to serialize in
  21134. * @returns the serialized object
  21135. */
  21136. serialize(parent: any): any;
  21137. }
  21138. /**
  21139. * This defines an action responsible to stop an animation once triggered.
  21140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21141. */
  21142. export class StopAnimationAction extends Action {
  21143. private _target;
  21144. /**
  21145. * Instantiate the action
  21146. * @param triggerOptions defines the trigger options
  21147. * @param target defines the target animation or animation name
  21148. * @param condition defines the trigger related conditions
  21149. */
  21150. constructor(triggerOptions: any, target: any, condition?: Condition);
  21151. /** @hidden */
  21152. _prepare(): void;
  21153. /**
  21154. * Execute the action and stop the animation.
  21155. */
  21156. execute(): void;
  21157. /**
  21158. * Serializes the actions and its related information.
  21159. * @param parent defines the object to serialize in
  21160. * @returns the serialized object
  21161. */
  21162. serialize(parent: any): any;
  21163. }
  21164. /**
  21165. * This defines an action responsible that does nothing once triggered.
  21166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21167. */
  21168. export class DoNothingAction extends Action {
  21169. /**
  21170. * Instantiate the action
  21171. * @param triggerOptions defines the trigger options
  21172. * @param condition defines the trigger related conditions
  21173. */
  21174. constructor(triggerOptions?: any, condition?: Condition);
  21175. /**
  21176. * Execute the action and do nothing.
  21177. */
  21178. execute(): void;
  21179. /**
  21180. * Serializes the actions and its related information.
  21181. * @param parent defines the object to serialize in
  21182. * @returns the serialized object
  21183. */
  21184. serialize(parent: any): any;
  21185. }
  21186. /**
  21187. * This defines an action responsible to trigger several actions once triggered.
  21188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21189. */
  21190. export class CombineAction extends Action {
  21191. /**
  21192. * The list of aggregated animations to run.
  21193. */
  21194. children: Action[];
  21195. /**
  21196. * Instantiate the action
  21197. * @param triggerOptions defines the trigger options
  21198. * @param children defines the list of aggregated animations to run
  21199. * @param condition defines the trigger related conditions
  21200. */
  21201. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  21202. /** @hidden */
  21203. _prepare(): void;
  21204. /**
  21205. * Execute the action and executes all the aggregated actions.
  21206. */
  21207. execute(evt: ActionEvent): void;
  21208. /**
  21209. * Serializes the actions and its related information.
  21210. * @param parent defines the object to serialize in
  21211. * @returns the serialized object
  21212. */
  21213. serialize(parent: any): any;
  21214. }
  21215. /**
  21216. * This defines an action responsible to run code (external event) once triggered.
  21217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21218. */
  21219. export class ExecuteCodeAction extends Action {
  21220. /**
  21221. * The callback function to run.
  21222. */
  21223. func: (evt: ActionEvent) => void;
  21224. /**
  21225. * Instantiate the action
  21226. * @param triggerOptions defines the trigger options
  21227. * @param func defines the callback function to run
  21228. * @param condition defines the trigger related conditions
  21229. */
  21230. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  21231. /**
  21232. * Execute the action and run the attached code.
  21233. */
  21234. execute(evt: ActionEvent): void;
  21235. }
  21236. /**
  21237. * This defines an action responsible to set the parent property of the target once triggered.
  21238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21239. */
  21240. export class SetParentAction extends Action {
  21241. private _parent;
  21242. private _target;
  21243. /**
  21244. * Instantiate the action
  21245. * @param triggerOptions defines the trigger options
  21246. * @param target defines the target containing the parent property
  21247. * @param parent defines from where the animation should start (animation frame)
  21248. * @param condition defines the trigger related conditions
  21249. */
  21250. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  21251. /** @hidden */
  21252. _prepare(): void;
  21253. /**
  21254. * Execute the action and set the parent property.
  21255. */
  21256. execute(): void;
  21257. /**
  21258. * Serializes the actions and its related information.
  21259. * @param parent defines the object to serialize in
  21260. * @returns the serialized object
  21261. */
  21262. serialize(parent: any): any;
  21263. }
  21264. }
  21265. declare module "babylonjs/Actions/abstractActionManager" {
  21266. import { IDisposable } from "babylonjs/scene";
  21267. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  21268. import { IAction } from "babylonjs/Actions/action";
  21269. /**
  21270. * Abstract class used to decouple action Manager from scene and meshes.
  21271. * Do not instantiate.
  21272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21273. */
  21274. export abstract class AbstractActionManager implements IDisposable {
  21275. /** Gets the list of active triggers */
  21276. static Triggers: {
  21277. [key: string]: number;
  21278. };
  21279. /** Gets the cursor to use when hovering items */
  21280. hoverCursor: string;
  21281. /** Gets the list of actions */
  21282. actions: IAction[];
  21283. /**
  21284. * Releases all associated resources
  21285. */
  21286. abstract dispose(): void;
  21287. /**
  21288. * Does this action manager has pointer triggers
  21289. */
  21290. abstract readonly hasPointerTriggers: boolean;
  21291. /**
  21292. * Does this action manager has pick triggers
  21293. */
  21294. abstract readonly hasPickTriggers: boolean;
  21295. /**
  21296. * Process a specific trigger
  21297. * @param trigger defines the trigger to process
  21298. * @param evt defines the event details to be processed
  21299. */
  21300. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  21301. /**
  21302. * Does this action manager handles actions of any of the given triggers
  21303. * @param triggers defines the triggers to be tested
  21304. * @return a boolean indicating whether one (or more) of the triggers is handled
  21305. */
  21306. abstract hasSpecificTriggers(triggers: number[]): boolean;
  21307. /**
  21308. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  21309. * speed.
  21310. * @param triggerA defines the trigger to be tested
  21311. * @param triggerB defines the trigger to be tested
  21312. * @return a boolean indicating whether one (or more) of the triggers is handled
  21313. */
  21314. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  21315. /**
  21316. * Does this action manager handles actions of a given trigger
  21317. * @param trigger defines the trigger to be tested
  21318. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  21319. * @return whether the trigger is handled
  21320. */
  21321. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  21322. /**
  21323. * Serialize this manager to a JSON object
  21324. * @param name defines the property name to store this manager
  21325. * @returns a JSON representation of this manager
  21326. */
  21327. abstract serialize(name: string): any;
  21328. /**
  21329. * Does exist one action manager with at least one trigger
  21330. **/
  21331. static readonly HasTriggers: boolean;
  21332. /**
  21333. * Does exist one action manager with at least one pick trigger
  21334. **/
  21335. static readonly HasPickTriggers: boolean;
  21336. /**
  21337. * Does exist one action manager that handles actions of a given trigger
  21338. * @param trigger defines the trigger to be tested
  21339. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  21340. **/
  21341. static HasSpecificTrigger(trigger: number): boolean;
  21342. }
  21343. }
  21344. declare module "babylonjs/Actions/actionManager" {
  21345. import { Nullable } from "babylonjs/types";
  21346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21347. import { Scene } from "babylonjs/scene";
  21348. import { Action } from "babylonjs/Actions/action";
  21349. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  21350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  21351. /**
  21352. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  21353. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  21354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  21355. */
  21356. export class ActionManager extends AbstractActionManager {
  21357. /**
  21358. * Nothing
  21359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21360. */
  21361. static readonly NothingTrigger: number;
  21362. /**
  21363. * On pick
  21364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21365. */
  21366. static readonly OnPickTrigger: number;
  21367. /**
  21368. * On left pick
  21369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21370. */
  21371. static readonly OnLeftPickTrigger: number;
  21372. /**
  21373. * On right pick
  21374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21375. */
  21376. static readonly OnRightPickTrigger: number;
  21377. /**
  21378. * On center pick
  21379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21380. */
  21381. static readonly OnCenterPickTrigger: number;
  21382. /**
  21383. * On pick down
  21384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21385. */
  21386. static readonly OnPickDownTrigger: number;
  21387. /**
  21388. * On double pick
  21389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21390. */
  21391. static readonly OnDoublePickTrigger: number;
  21392. /**
  21393. * On pick up
  21394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21395. */
  21396. static readonly OnPickUpTrigger: number;
  21397. /**
  21398. * On pick out.
  21399. * This trigger will only be raised if you also declared a OnPickDown
  21400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21401. */
  21402. static readonly OnPickOutTrigger: number;
  21403. /**
  21404. * On long press
  21405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21406. */
  21407. static readonly OnLongPressTrigger: number;
  21408. /**
  21409. * On pointer over
  21410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21411. */
  21412. static readonly OnPointerOverTrigger: number;
  21413. /**
  21414. * On pointer out
  21415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21416. */
  21417. static readonly OnPointerOutTrigger: number;
  21418. /**
  21419. * On every frame
  21420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21421. */
  21422. static readonly OnEveryFrameTrigger: number;
  21423. /**
  21424. * On intersection enter
  21425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21426. */
  21427. static readonly OnIntersectionEnterTrigger: number;
  21428. /**
  21429. * On intersection exit
  21430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21431. */
  21432. static readonly OnIntersectionExitTrigger: number;
  21433. /**
  21434. * On key down
  21435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21436. */
  21437. static readonly OnKeyDownTrigger: number;
  21438. /**
  21439. * On key up
  21440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  21441. */
  21442. static readonly OnKeyUpTrigger: number;
  21443. private _scene;
  21444. /**
  21445. * Creates a new action manager
  21446. * @param scene defines the hosting scene
  21447. */
  21448. constructor(scene: Scene);
  21449. /**
  21450. * Releases all associated resources
  21451. */
  21452. dispose(): void;
  21453. /**
  21454. * Gets hosting scene
  21455. * @returns the hosting scene
  21456. */
  21457. getScene(): Scene;
  21458. /**
  21459. * Does this action manager handles actions of any of the given triggers
  21460. * @param triggers defines the triggers to be tested
  21461. * @return a boolean indicating whether one (or more) of the triggers is handled
  21462. */
  21463. hasSpecificTriggers(triggers: number[]): boolean;
  21464. /**
  21465. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  21466. * speed.
  21467. * @param triggerA defines the trigger to be tested
  21468. * @param triggerB defines the trigger to be tested
  21469. * @return a boolean indicating whether one (or more) of the triggers is handled
  21470. */
  21471. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  21472. /**
  21473. * Does this action manager handles actions of a given trigger
  21474. * @param trigger defines the trigger to be tested
  21475. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  21476. * @return whether the trigger is handled
  21477. */
  21478. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  21479. /**
  21480. * Does this action manager has pointer triggers
  21481. */
  21482. readonly hasPointerTriggers: boolean;
  21483. /**
  21484. * Does this action manager has pick triggers
  21485. */
  21486. readonly hasPickTriggers: boolean;
  21487. /**
  21488. * Registers an action to this action manager
  21489. * @param action defines the action to be registered
  21490. * @return the action amended (prepared) after registration
  21491. */
  21492. registerAction(action: Action): Nullable<Action>;
  21493. /**
  21494. * Unregisters an action to this action manager
  21495. * @param action defines the action to be unregistered
  21496. * @return a boolean indicating whether the action has been unregistered
  21497. */
  21498. unregisterAction(action: Action): Boolean;
  21499. /**
  21500. * Process a specific trigger
  21501. * @param trigger defines the trigger to process
  21502. * @param evt defines the event details to be processed
  21503. */
  21504. processTrigger(trigger: number, evt?: IActionEvent): void;
  21505. /** @hidden */
  21506. _getEffectiveTarget(target: any, propertyPath: string): any;
  21507. /** @hidden */
  21508. _getProperty(propertyPath: string): string;
  21509. /**
  21510. * Serialize this manager to a JSON object
  21511. * @param name defines the property name to store this manager
  21512. * @returns a JSON representation of this manager
  21513. */
  21514. serialize(name: string): any;
  21515. /**
  21516. * Creates a new ActionManager from a JSON data
  21517. * @param parsedActions defines the JSON data to read from
  21518. * @param object defines the hosting mesh
  21519. * @param scene defines the hosting scene
  21520. */
  21521. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  21522. /**
  21523. * Get a trigger name by index
  21524. * @param trigger defines the trigger index
  21525. * @returns a trigger name
  21526. */
  21527. static GetTriggerName(trigger: number): string;
  21528. }
  21529. }
  21530. declare module "babylonjs/Sprites/sprite" {
  21531. import { Vector3, Color4 } from "babylonjs/Maths/math";
  21532. import { Nullable } from "babylonjs/types";
  21533. import { ActionManager } from "babylonjs/Actions/actionManager";
  21534. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  21535. /**
  21536. * Class used to represent a sprite
  21537. * @see http://doc.babylonjs.com/babylon101/sprites
  21538. */
  21539. export class Sprite {
  21540. /** defines the name */
  21541. name: string;
  21542. /** Gets or sets the current world position */
  21543. position: Vector3;
  21544. /** Gets or sets the main color */
  21545. color: Color4;
  21546. /** Gets or sets the width */
  21547. width: number;
  21548. /** Gets or sets the height */
  21549. height: number;
  21550. /** Gets or sets rotation angle */
  21551. angle: number;
  21552. /** Gets or sets the cell index in the sprite sheet */
  21553. cellIndex: number;
  21554. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  21555. invertU: number;
  21556. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  21557. invertV: number;
  21558. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  21559. disposeWhenFinishedAnimating: boolean;
  21560. /** Gets the list of attached animations */
  21561. animations: Animation[];
  21562. /** Gets or sets a boolean indicating if the sprite can be picked */
  21563. isPickable: boolean;
  21564. /**
  21565. * Gets or sets the associated action manager
  21566. */
  21567. actionManager: Nullable<ActionManager>;
  21568. private _animationStarted;
  21569. private _loopAnimation;
  21570. private _fromIndex;
  21571. private _toIndex;
  21572. private _delay;
  21573. private _direction;
  21574. private _manager;
  21575. private _time;
  21576. private _onAnimationEnd;
  21577. /**
  21578. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  21579. */
  21580. isVisible: boolean;
  21581. /**
  21582. * Gets or sets the sprite size
  21583. */
  21584. size: number;
  21585. /**
  21586. * Creates a new Sprite
  21587. * @param name defines the name
  21588. * @param manager defines the manager
  21589. */
  21590. constructor(
  21591. /** defines the name */
  21592. name: string, manager: ISpriteManager);
  21593. /**
  21594. * Starts an animation
  21595. * @param from defines the initial key
  21596. * @param to defines the end key
  21597. * @param loop defines if the animation must loop
  21598. * @param delay defines the start delay (in ms)
  21599. * @param onAnimationEnd defines a callback to call when animation ends
  21600. */
  21601. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  21602. /** Stops current animation (if any) */
  21603. stopAnimation(): void;
  21604. /** @hidden */
  21605. _animate(deltaTime: number): void;
  21606. /** Release associated resources */
  21607. dispose(): void;
  21608. }
  21609. }
  21610. declare module "babylonjs/Collisions/pickingInfo" {
  21611. import { Nullable } from "babylonjs/types";
  21612. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21614. import { Ray } from "babylonjs/Culling/ray";
  21615. import { Sprite } from "babylonjs/Sprites/sprite";
  21616. /**
  21617. * Information about the result of picking within a scene
  21618. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  21619. */
  21620. export class PickingInfo {
  21621. /**
  21622. * If the pick collided with an object
  21623. */
  21624. hit: boolean;
  21625. /**
  21626. * Distance away where the pick collided
  21627. */
  21628. distance: number;
  21629. /**
  21630. * The location of pick collision
  21631. */
  21632. pickedPoint: Nullable<Vector3>;
  21633. /**
  21634. * The mesh corresponding the the pick collision
  21635. */
  21636. pickedMesh: Nullable<AbstractMesh>;
  21637. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  21638. bu: number;
  21639. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  21640. bv: number;
  21641. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  21642. faceId: number;
  21643. /** Id of the the submesh that was picked */
  21644. subMeshId: number;
  21645. /** If a sprite was picked, this will be the sprite the pick collided with */
  21646. pickedSprite: Nullable<Sprite>;
  21647. /**
  21648. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  21649. */
  21650. originMesh: Nullable<AbstractMesh>;
  21651. /**
  21652. * The ray that was used to perform the picking.
  21653. */
  21654. ray: Nullable<Ray>;
  21655. /**
  21656. * Gets the normal correspodning to the face the pick collided with
  21657. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  21658. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  21659. * @returns The normal correspodning to the face the pick collided with
  21660. */
  21661. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  21662. /**
  21663. * Gets the texture coordinates of where the pick occured
  21664. * @returns the vector containing the coordnates of the texture
  21665. */
  21666. getTextureCoordinates(): Nullable<Vector2>;
  21667. }
  21668. }
  21669. declare module "babylonjs/Culling/ray" {
  21670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  21671. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  21674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  21676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21677. /**
  21678. * Class representing a ray with position and direction
  21679. */
  21680. export class Ray {
  21681. /** origin point */
  21682. origin: Vector3;
  21683. /** direction */
  21684. direction: Vector3;
  21685. /** length of the ray */
  21686. length: number;
  21687. private static readonly TmpVector3;
  21688. private _tmpRay;
  21689. /**
  21690. * Creates a new ray
  21691. * @param origin origin point
  21692. * @param direction direction
  21693. * @param length length of the ray
  21694. */
  21695. constructor(
  21696. /** origin point */
  21697. origin: Vector3,
  21698. /** direction */
  21699. direction: Vector3,
  21700. /** length of the ray */
  21701. length?: number);
  21702. /**
  21703. * Checks if the ray intersects a box
  21704. * @param minimum bound of the box
  21705. * @param maximum bound of the box
  21706. * @param intersectionTreshold extra extend to be added to the box in all direction
  21707. * @returns if the box was hit
  21708. */
  21709. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21710. /**
  21711. * Checks if the ray intersects a box
  21712. * @param box the bounding box to check
  21713. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21714. * @returns if the box was hit
  21715. */
  21716. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21717. /**
  21718. * If the ray hits a sphere
  21719. * @param sphere the bounding sphere to check
  21720. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21721. * @returns true if it hits the sphere
  21722. */
  21723. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21724. /**
  21725. * If the ray hits a triange
  21726. * @param vertex0 triangle vertex
  21727. * @param vertex1 triangle vertex
  21728. * @param vertex2 triangle vertex
  21729. * @returns intersection information if hit
  21730. */
  21731. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21732. /**
  21733. * Checks if ray intersects a plane
  21734. * @param plane the plane to check
  21735. * @returns the distance away it was hit
  21736. */
  21737. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21738. /**
  21739. * Checks if ray intersects a mesh
  21740. * @param mesh the mesh to check
  21741. * @param fastCheck if only the bounding box should checked
  21742. * @returns picking info of the intersecton
  21743. */
  21744. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21745. /**
  21746. * Checks if ray intersects a mesh
  21747. * @param meshes the meshes to check
  21748. * @param fastCheck if only the bounding box should checked
  21749. * @param results array to store result in
  21750. * @returns Array of picking infos
  21751. */
  21752. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21753. private _comparePickingInfo;
  21754. private static smallnum;
  21755. private static rayl;
  21756. /**
  21757. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21758. * @param sega the first point of the segment to test the intersection against
  21759. * @param segb the second point of the segment to test the intersection against
  21760. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21761. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21762. */
  21763. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21764. /**
  21765. * Update the ray from viewport position
  21766. * @param x position
  21767. * @param y y position
  21768. * @param viewportWidth viewport width
  21769. * @param viewportHeight viewport height
  21770. * @param world world matrix
  21771. * @param view view matrix
  21772. * @param projection projection matrix
  21773. * @returns this ray updated
  21774. */
  21775. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21776. /**
  21777. * Creates a ray with origin and direction of 0,0,0
  21778. * @returns the new ray
  21779. */
  21780. static Zero(): Ray;
  21781. /**
  21782. * Creates a new ray from screen space and viewport
  21783. * @param x position
  21784. * @param y y position
  21785. * @param viewportWidth viewport width
  21786. * @param viewportHeight viewport height
  21787. * @param world world matrix
  21788. * @param view view matrix
  21789. * @param projection projection matrix
  21790. * @returns new ray
  21791. */
  21792. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21793. /**
  21794. * 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
  21795. * transformed to the given world matrix.
  21796. * @param origin The origin point
  21797. * @param end The end point
  21798. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21799. * @returns the new ray
  21800. */
  21801. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21802. /**
  21803. * Transforms a ray by a matrix
  21804. * @param ray ray to transform
  21805. * @param matrix matrix to apply
  21806. * @returns the resulting new ray
  21807. */
  21808. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21809. /**
  21810. * Transforms a ray by a matrix
  21811. * @param ray ray to transform
  21812. * @param matrix matrix to apply
  21813. * @param result ray to store result in
  21814. */
  21815. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21816. /**
  21817. * Unproject a ray from screen space to object space
  21818. * @param sourceX defines the screen space x coordinate to use
  21819. * @param sourceY defines the screen space y coordinate to use
  21820. * @param viewportWidth defines the current width of the viewport
  21821. * @param viewportHeight defines the current height of the viewport
  21822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21823. * @param view defines the view matrix to use
  21824. * @param projection defines the projection matrix to use
  21825. */
  21826. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21827. }
  21828. }
  21829. declare module "babylonjs/Materials/multiMaterial" {
  21830. import { Nullable } from "babylonjs/types";
  21831. import { Scene } from "babylonjs/scene";
  21832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21833. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21835. import { Material } from "babylonjs/Materials/material";
  21836. /**
  21837. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21838. * separate meshes. This can be use to improve performances.
  21839. * @see http://doc.babylonjs.com/how_to/multi_materials
  21840. */
  21841. export class MultiMaterial extends Material {
  21842. private _subMaterials;
  21843. /**
  21844. * Gets or Sets the list of Materials used within the multi material.
  21845. * They need to be ordered according to the submeshes order in the associated mesh
  21846. */
  21847. subMaterials: Nullable<Material>[];
  21848. /**
  21849. * Function used to align with Node.getChildren()
  21850. * @returns the list of Materials used within the multi material
  21851. */
  21852. getChildren(): Nullable<Material>[];
  21853. /**
  21854. * Instantiates a new Multi Material
  21855. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21856. * separate meshes. This can be use to improve performances.
  21857. * @see http://doc.babylonjs.com/how_to/multi_materials
  21858. * @param name Define the name in the scene
  21859. * @param scene Define the scene the material belongs to
  21860. */
  21861. constructor(name: string, scene: Scene);
  21862. private _hookArray;
  21863. /**
  21864. * Get one of the submaterial by its index in the submaterials array
  21865. * @param index The index to look the sub material at
  21866. * @returns The Material if the index has been defined
  21867. */
  21868. getSubMaterial(index: number): Nullable<Material>;
  21869. /**
  21870. * Get the list of active textures for the whole sub materials list.
  21871. * @returns All the textures that will be used during the rendering
  21872. */
  21873. getActiveTextures(): BaseTexture[];
  21874. /**
  21875. * Gets the current class name of the material e.g. "MultiMaterial"
  21876. * Mainly use in serialization.
  21877. * @returns the class name
  21878. */
  21879. getClassName(): string;
  21880. /**
  21881. * Checks if the material is ready to render the requested sub mesh
  21882. * @param mesh Define the mesh the submesh belongs to
  21883. * @param subMesh Define the sub mesh to look readyness for
  21884. * @param useInstances Define whether or not the material is used with instances
  21885. * @returns true if ready, otherwise false
  21886. */
  21887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21888. /**
  21889. * Clones the current material and its related sub materials
  21890. * @param name Define the name of the newly cloned material
  21891. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21892. * @returns the cloned material
  21893. */
  21894. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21895. /**
  21896. * Serializes the materials into a JSON representation.
  21897. * @returns the JSON representation
  21898. */
  21899. serialize(): any;
  21900. /**
  21901. * Dispose the material and release its associated resources
  21902. * @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)
  21903. * @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)
  21904. * @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)
  21905. */
  21906. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21907. /**
  21908. * Creates a MultiMaterial from parsed MultiMaterial data.
  21909. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21910. * @param scene defines the hosting scene
  21911. * @returns a new MultiMaterial
  21912. */
  21913. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21914. }
  21915. }
  21916. declare module "babylonjs/Meshes/subMesh" {
  21917. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21918. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21919. import { Engine } from "babylonjs/Engines/engine";
  21920. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21921. import { Ray } from "babylonjs/Culling/ray";
  21922. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21923. import { Effect } from "babylonjs/Materials/effect";
  21924. import { Collider } from "babylonjs/Collisions/collider";
  21925. import { Material } from "babylonjs/Materials/material";
  21926. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21928. import { Mesh } from "babylonjs/Meshes/mesh";
  21929. /**
  21930. * Base class for submeshes
  21931. */
  21932. export class BaseSubMesh {
  21933. /** @hidden */
  21934. _materialDefines: Nullable<MaterialDefines>;
  21935. /** @hidden */
  21936. _materialEffect: Nullable<Effect>;
  21937. /**
  21938. * Gets associated effect
  21939. */
  21940. readonly effect: Nullable<Effect>;
  21941. /**
  21942. * Sets associated effect (effect used to render this submesh)
  21943. * @param effect defines the effect to associate with
  21944. * @param defines defines the set of defines used to compile this effect
  21945. */
  21946. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21947. }
  21948. /**
  21949. * Defines a subdivision inside a mesh
  21950. */
  21951. export class SubMesh extends BaseSubMesh implements ICullable {
  21952. /** the material index to use */
  21953. materialIndex: number;
  21954. /** vertex index start */
  21955. verticesStart: number;
  21956. /** vertices count */
  21957. verticesCount: number;
  21958. /** index start */
  21959. indexStart: number;
  21960. /** indices count */
  21961. indexCount: number;
  21962. /** @hidden */
  21963. _linesIndexCount: number;
  21964. private _mesh;
  21965. private _renderingMesh;
  21966. private _boundingInfo;
  21967. private _linesIndexBuffer;
  21968. /** @hidden */
  21969. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21970. /** @hidden */
  21971. _trianglePlanes: Plane[];
  21972. /** @hidden */
  21973. _lastColliderTransformMatrix: Matrix;
  21974. /** @hidden */
  21975. _renderId: number;
  21976. /** @hidden */
  21977. _alphaIndex: number;
  21978. /** @hidden */
  21979. _distanceToCamera: number;
  21980. /** @hidden */
  21981. _id: number;
  21982. private _currentMaterial;
  21983. /**
  21984. * Add a new submesh to a mesh
  21985. * @param materialIndex defines the material index to use
  21986. * @param verticesStart defines vertex index start
  21987. * @param verticesCount defines vertices count
  21988. * @param indexStart defines index start
  21989. * @param indexCount defines indices count
  21990. * @param mesh defines the parent mesh
  21991. * @param renderingMesh defines an optional rendering mesh
  21992. * @param createBoundingBox defines if bounding box should be created for this submesh
  21993. * @returns the new submesh
  21994. */
  21995. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21996. /**
  21997. * Creates a new submesh
  21998. * @param materialIndex defines the material index to use
  21999. * @param verticesStart defines vertex index start
  22000. * @param verticesCount defines vertices count
  22001. * @param indexStart defines index start
  22002. * @param indexCount defines indices count
  22003. * @param mesh defines the parent mesh
  22004. * @param renderingMesh defines an optional rendering mesh
  22005. * @param createBoundingBox defines if bounding box should be created for this submesh
  22006. */
  22007. constructor(
  22008. /** the material index to use */
  22009. materialIndex: number,
  22010. /** vertex index start */
  22011. verticesStart: number,
  22012. /** vertices count */
  22013. verticesCount: number,
  22014. /** index start */
  22015. indexStart: number,
  22016. /** indices count */
  22017. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22018. /**
  22019. * Returns true if this submesh covers the entire parent mesh
  22020. * @ignorenaming
  22021. */
  22022. readonly IsGlobal: boolean;
  22023. /**
  22024. * Returns the submesh BoudingInfo object
  22025. * @returns current bounding info (or mesh's one if the submesh is global)
  22026. */
  22027. getBoundingInfo(): BoundingInfo;
  22028. /**
  22029. * Sets the submesh BoundingInfo
  22030. * @param boundingInfo defines the new bounding info to use
  22031. * @returns the SubMesh
  22032. */
  22033. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22034. /**
  22035. * Returns the mesh of the current submesh
  22036. * @return the parent mesh
  22037. */
  22038. getMesh(): AbstractMesh;
  22039. /**
  22040. * Returns the rendering mesh of the submesh
  22041. * @returns the rendering mesh (could be different from parent mesh)
  22042. */
  22043. getRenderingMesh(): Mesh;
  22044. /**
  22045. * Returns the submesh material
  22046. * @returns null or the current material
  22047. */
  22048. getMaterial(): Nullable<Material>;
  22049. /**
  22050. * Sets a new updated BoundingInfo object to the submesh
  22051. * @returns the SubMesh
  22052. */
  22053. refreshBoundingInfo(): SubMesh;
  22054. /** @hidden */
  22055. _checkCollision(collider: Collider): boolean;
  22056. /**
  22057. * Updates the submesh BoundingInfo
  22058. * @param world defines the world matrix to use to update the bounding info
  22059. * @returns the submesh
  22060. */
  22061. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22062. /**
  22063. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22064. * @param frustumPlanes defines the frustum planes
  22065. * @returns true if the submesh is intersecting with the frustum
  22066. */
  22067. isInFrustum(frustumPlanes: Plane[]): boolean;
  22068. /**
  22069. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22070. * @param frustumPlanes defines the frustum planes
  22071. * @returns true if the submesh is inside the frustum
  22072. */
  22073. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22074. /**
  22075. * Renders the submesh
  22076. * @param enableAlphaMode defines if alpha needs to be used
  22077. * @returns the submesh
  22078. */
  22079. render(enableAlphaMode: boolean): SubMesh;
  22080. /**
  22081. * @hidden
  22082. */
  22083. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22084. /**
  22085. * Checks if the submesh intersects with a ray
  22086. * @param ray defines the ray to test
  22087. * @returns true is the passed ray intersects the submesh bounding box
  22088. */
  22089. canIntersects(ray: Ray): boolean;
  22090. /**
  22091. * Intersects current submesh with a ray
  22092. * @param ray defines the ray to test
  22093. * @param positions defines mesh's positions array
  22094. * @param indices defines mesh's indices array
  22095. * @param fastCheck defines if only bounding info should be used
  22096. * @returns intersection info or null if no intersection
  22097. */
  22098. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22099. /** @hidden */
  22100. private _intersectLines;
  22101. /** @hidden */
  22102. private _intersectTriangles;
  22103. /** @hidden */
  22104. _rebuild(): void;
  22105. /**
  22106. * Creates a new submesh from the passed mesh
  22107. * @param newMesh defines the new hosting mesh
  22108. * @param newRenderingMesh defines an optional rendering mesh
  22109. * @returns the new submesh
  22110. */
  22111. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22112. /**
  22113. * Release associated resources
  22114. */
  22115. dispose(): void;
  22116. /**
  22117. * Gets the class name
  22118. * @returns the string "SubMesh".
  22119. */
  22120. getClassName(): string;
  22121. /**
  22122. * Creates a new submesh from indices data
  22123. * @param materialIndex the index of the main mesh material
  22124. * @param startIndex the index where to start the copy in the mesh indices array
  22125. * @param indexCount the number of indices to copy then from the startIndex
  22126. * @param mesh the main mesh to create the submesh from
  22127. * @param renderingMesh the optional rendering mesh
  22128. * @returns a new submesh
  22129. */
  22130. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22131. }
  22132. }
  22133. declare module "babylonjs/Meshes/geometry" {
  22134. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22135. import { Scene } from "babylonjs/scene";
  22136. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22137. import { Engine } from "babylonjs/Engines/engine";
  22138. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22139. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22140. import { Effect } from "babylonjs/Materials/effect";
  22141. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22142. import { Mesh } from "babylonjs/Meshes/mesh";
  22143. /**
  22144. * Class used to store geometry data (vertex buffers + index buffer)
  22145. */
  22146. export class Geometry implements IGetSetVerticesData {
  22147. /**
  22148. * Gets or sets the ID of the geometry
  22149. */
  22150. id: string;
  22151. /**
  22152. * Gets or sets the unique ID of the geometry
  22153. */
  22154. uniqueId: number;
  22155. /**
  22156. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22157. */
  22158. delayLoadState: number;
  22159. /**
  22160. * Gets the file containing the data to load when running in delay load state
  22161. */
  22162. delayLoadingFile: Nullable<string>;
  22163. /**
  22164. * Callback called when the geometry is updated
  22165. */
  22166. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22167. private _scene;
  22168. private _engine;
  22169. private _meshes;
  22170. private _totalVertices;
  22171. /** @hidden */
  22172. _indices: IndicesArray;
  22173. /** @hidden */
  22174. _vertexBuffers: {
  22175. [key: string]: VertexBuffer;
  22176. };
  22177. private _isDisposed;
  22178. private _extend;
  22179. private _boundingBias;
  22180. /** @hidden */
  22181. _delayInfo: Array<string>;
  22182. private _indexBuffer;
  22183. private _indexBufferIsUpdatable;
  22184. /** @hidden */
  22185. _boundingInfo: Nullable<BoundingInfo>;
  22186. /** @hidden */
  22187. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22188. /** @hidden */
  22189. _softwareSkinningFrameId: number;
  22190. private _vertexArrayObjects;
  22191. private _updatable;
  22192. /** @hidden */
  22193. _positions: Nullable<Vector3[]>;
  22194. /**
  22195. * 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
  22196. */
  22197. /**
  22198. * 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
  22199. */
  22200. boundingBias: Vector2;
  22201. /**
  22202. * Static function used to attach a new empty geometry to a mesh
  22203. * @param mesh defines the mesh to attach the geometry to
  22204. * @returns the new Geometry
  22205. */
  22206. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22207. /**
  22208. * Creates a new geometry
  22209. * @param id defines the unique ID
  22210. * @param scene defines the hosting scene
  22211. * @param vertexData defines the VertexData used to get geometry data
  22212. * @param updatable defines if geometry must be updatable (false by default)
  22213. * @param mesh defines the mesh that will be associated with the geometry
  22214. */
  22215. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22216. /**
  22217. * Gets the current extend of the geometry
  22218. */
  22219. readonly extend: {
  22220. minimum: Vector3;
  22221. maximum: Vector3;
  22222. };
  22223. /**
  22224. * Gets the hosting scene
  22225. * @returns the hosting Scene
  22226. */
  22227. getScene(): Scene;
  22228. /**
  22229. * Gets the hosting engine
  22230. * @returns the hosting Engine
  22231. */
  22232. getEngine(): Engine;
  22233. /**
  22234. * Defines if the geometry is ready to use
  22235. * @returns true if the geometry is ready to be used
  22236. */
  22237. isReady(): boolean;
  22238. /**
  22239. * Gets a value indicating that the geometry should not be serialized
  22240. */
  22241. readonly doNotSerialize: boolean;
  22242. /** @hidden */
  22243. _rebuild(): void;
  22244. /**
  22245. * Affects all geometry data in one call
  22246. * @param vertexData defines the geometry data
  22247. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22248. */
  22249. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22250. /**
  22251. * Set specific vertex data
  22252. * @param kind defines the data kind (Position, normal, etc...)
  22253. * @param data defines the vertex data to use
  22254. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22255. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22256. */
  22257. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22258. /**
  22259. * Removes a specific vertex data
  22260. * @param kind defines the data kind (Position, normal, etc...)
  22261. */
  22262. removeVerticesData(kind: string): void;
  22263. /**
  22264. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22265. * @param buffer defines the vertex buffer to use
  22266. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22267. */
  22268. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22269. /**
  22270. * Update a specific vertex buffer
  22271. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22272. * It will do nothing if the buffer is not updatable
  22273. * @param kind defines the data kind (Position, normal, etc...)
  22274. * @param data defines the data to use
  22275. * @param offset defines the offset in the target buffer where to store the data
  22276. * @param useBytes set to true if the offset is in bytes
  22277. */
  22278. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22279. /**
  22280. * Update a specific vertex buffer
  22281. * This function will create a new buffer if the current one is not updatable
  22282. * @param kind defines the data kind (Position, normal, etc...)
  22283. * @param data defines the data to use
  22284. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22285. */
  22286. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22287. private _updateBoundingInfo;
  22288. /** @hidden */
  22289. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22290. /**
  22291. * Gets total number of vertices
  22292. * @returns the total number of vertices
  22293. */
  22294. getTotalVertices(): number;
  22295. /**
  22296. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22297. * @param kind defines the data kind (Position, normal, etc...)
  22298. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22300. * @returns a float array containing vertex data
  22301. */
  22302. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22303. /**
  22304. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22305. * @param kind defines the data kind (Position, normal, etc...)
  22306. * @returns true if the vertex buffer with the specified kind is updatable
  22307. */
  22308. isVertexBufferUpdatable(kind: string): boolean;
  22309. /**
  22310. * Gets a specific vertex buffer
  22311. * @param kind defines the data kind (Position, normal, etc...)
  22312. * @returns a VertexBuffer
  22313. */
  22314. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22315. /**
  22316. * Returns all vertex buffers
  22317. * @return an object holding all vertex buffers indexed by kind
  22318. */
  22319. getVertexBuffers(): Nullable<{
  22320. [key: string]: VertexBuffer;
  22321. }>;
  22322. /**
  22323. * Gets a boolean indicating if specific vertex buffer is present
  22324. * @param kind defines the data kind (Position, normal, etc...)
  22325. * @returns true if data is present
  22326. */
  22327. isVerticesDataPresent(kind: string): boolean;
  22328. /**
  22329. * Gets a list of all attached data kinds (Position, normal, etc...)
  22330. * @returns a list of string containing all kinds
  22331. */
  22332. getVerticesDataKinds(): string[];
  22333. /**
  22334. * Update index buffer
  22335. * @param indices defines the indices to store in the index buffer
  22336. * @param offset defines the offset in the target buffer where to store the data
  22337. */
  22338. updateIndices(indices: IndicesArray, offset?: number): void;
  22339. /**
  22340. * Creates a new index buffer
  22341. * @param indices defines the indices to store in the index buffer
  22342. * @param totalVertices defines the total number of vertices (could be null)
  22343. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22344. */
  22345. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22346. /**
  22347. * Return the total number of indices
  22348. * @returns the total number of indices
  22349. */
  22350. getTotalIndices(): number;
  22351. /**
  22352. * Gets the index buffer array
  22353. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22354. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22355. * @returns the index buffer array
  22356. */
  22357. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22358. /**
  22359. * Gets the index buffer
  22360. * @return the index buffer
  22361. */
  22362. getIndexBuffer(): Nullable<WebGLBuffer>;
  22363. /** @hidden */
  22364. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22365. /**
  22366. * Release the associated resources for a specific mesh
  22367. * @param mesh defines the source mesh
  22368. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22369. */
  22370. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22371. /**
  22372. * Apply current geometry to a given mesh
  22373. * @param mesh defines the mesh to apply geometry to
  22374. */
  22375. applyToMesh(mesh: Mesh): void;
  22376. private _updateExtend;
  22377. private _applyToMesh;
  22378. private notifyUpdate;
  22379. /**
  22380. * Load the geometry if it was flagged as delay loaded
  22381. * @param scene defines the hosting scene
  22382. * @param onLoaded defines a callback called when the geometry is loaded
  22383. */
  22384. load(scene: Scene, onLoaded?: () => void): void;
  22385. private _queueLoad;
  22386. /**
  22387. * Invert the geometry to move from a right handed system to a left handed one.
  22388. */
  22389. toLeftHanded(): void;
  22390. /** @hidden */
  22391. _resetPointsArrayCache(): void;
  22392. /** @hidden */
  22393. _generatePointsArray(): boolean;
  22394. /**
  22395. * Gets a value indicating if the geometry is disposed
  22396. * @returns true if the geometry was disposed
  22397. */
  22398. isDisposed(): boolean;
  22399. private _disposeVertexArrayObjects;
  22400. /**
  22401. * Free all associated resources
  22402. */
  22403. dispose(): void;
  22404. /**
  22405. * Clone the current geometry into a new geometry
  22406. * @param id defines the unique ID of the new geometry
  22407. * @returns a new geometry object
  22408. */
  22409. copy(id: string): Geometry;
  22410. /**
  22411. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22412. * @return a JSON representation of the current geometry data (without the vertices data)
  22413. */
  22414. serialize(): any;
  22415. private toNumberArray;
  22416. /**
  22417. * Serialize all vertices data into a JSON oject
  22418. * @returns a JSON representation of the current geometry data
  22419. */
  22420. serializeVerticeData(): any;
  22421. /**
  22422. * Extracts a clone of a mesh geometry
  22423. * @param mesh defines the source mesh
  22424. * @param id defines the unique ID of the new geometry object
  22425. * @returns the new geometry object
  22426. */
  22427. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22428. /**
  22429. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22430. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22431. * Be aware Math.random() could cause collisions, but:
  22432. * "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"
  22433. * @returns a string containing a new GUID
  22434. */
  22435. static RandomId(): string;
  22436. /** @hidden */
  22437. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22438. private static _CleanMatricesWeights;
  22439. /**
  22440. * Create a new geometry from persisted data (Using .babylon file format)
  22441. * @param parsedVertexData defines the persisted data
  22442. * @param scene defines the hosting scene
  22443. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22444. * @returns the new geometry object
  22445. */
  22446. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22447. }
  22448. }
  22449. declare module "babylonjs/Meshes/mesh.vertexData" {
  22450. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22451. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22452. import { Geometry } from "babylonjs/Meshes/geometry";
  22453. import { Mesh } from "babylonjs/Meshes/mesh";
  22454. /**
  22455. * Define an interface for all classes that will get and set the data on vertices
  22456. */
  22457. export interface IGetSetVerticesData {
  22458. /**
  22459. * Gets a boolean indicating if specific vertex data is present
  22460. * @param kind defines the vertex data kind to use
  22461. * @returns true is data kind is present
  22462. */
  22463. isVerticesDataPresent(kind: string): boolean;
  22464. /**
  22465. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22466. * @param kind defines the data kind (Position, normal, etc...)
  22467. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22468. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22469. * @returns a float array containing vertex data
  22470. */
  22471. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22472. /**
  22473. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22474. * @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.
  22475. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22476. * @returns the indices array or an empty array if the mesh has no geometry
  22477. */
  22478. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22479. /**
  22480. * Set specific vertex data
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @param data defines the vertex data to use
  22483. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22484. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22485. */
  22486. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22487. /**
  22488. * Update a specific associated vertex buffer
  22489. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22490. * - VertexBuffer.PositionKind
  22491. * - VertexBuffer.UVKind
  22492. * - VertexBuffer.UV2Kind
  22493. * - VertexBuffer.UV3Kind
  22494. * - VertexBuffer.UV4Kind
  22495. * - VertexBuffer.UV5Kind
  22496. * - VertexBuffer.UV6Kind
  22497. * - VertexBuffer.ColorKind
  22498. * - VertexBuffer.MatricesIndicesKind
  22499. * - VertexBuffer.MatricesIndicesExtraKind
  22500. * - VertexBuffer.MatricesWeightsKind
  22501. * - VertexBuffer.MatricesWeightsExtraKind
  22502. * @param data defines the data source
  22503. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22504. * @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)
  22505. */
  22506. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22507. /**
  22508. * Creates a new index buffer
  22509. * @param indices defines the indices to store in the index buffer
  22510. * @param totalVertices defines the total number of vertices (could be null)
  22511. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22512. */
  22513. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22514. }
  22515. /**
  22516. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22517. */
  22518. export class VertexData {
  22519. /**
  22520. * Mesh side orientation : usually the external or front surface
  22521. */
  22522. static readonly FRONTSIDE: number;
  22523. /**
  22524. * Mesh side orientation : usually the internal or back surface
  22525. */
  22526. static readonly BACKSIDE: number;
  22527. /**
  22528. * Mesh side orientation : both internal and external or front and back surfaces
  22529. */
  22530. static readonly DOUBLESIDE: number;
  22531. /**
  22532. * Mesh side orientation : by default, `FRONTSIDE`
  22533. */
  22534. static readonly DEFAULTSIDE: number;
  22535. /**
  22536. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22537. */
  22538. positions: Nullable<FloatArray>;
  22539. /**
  22540. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22541. */
  22542. normals: Nullable<FloatArray>;
  22543. /**
  22544. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22545. */
  22546. tangents: Nullable<FloatArray>;
  22547. /**
  22548. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22549. */
  22550. uvs: Nullable<FloatArray>;
  22551. /**
  22552. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22553. */
  22554. uvs2: Nullable<FloatArray>;
  22555. /**
  22556. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22557. */
  22558. uvs3: Nullable<FloatArray>;
  22559. /**
  22560. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22561. */
  22562. uvs4: Nullable<FloatArray>;
  22563. /**
  22564. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22565. */
  22566. uvs5: Nullable<FloatArray>;
  22567. /**
  22568. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22569. */
  22570. uvs6: Nullable<FloatArray>;
  22571. /**
  22572. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22573. */
  22574. colors: Nullable<FloatArray>;
  22575. /**
  22576. * 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).
  22577. */
  22578. matricesIndices: Nullable<FloatArray>;
  22579. /**
  22580. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22581. */
  22582. matricesWeights: Nullable<FloatArray>;
  22583. /**
  22584. * An array extending the number of possible indices
  22585. */
  22586. matricesIndicesExtra: Nullable<FloatArray>;
  22587. /**
  22588. * An array extending the number of possible weights when the number of indices is extended
  22589. */
  22590. matricesWeightsExtra: Nullable<FloatArray>;
  22591. /**
  22592. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22593. */
  22594. indices: Nullable<IndicesArray>;
  22595. /**
  22596. * Uses the passed data array to set the set the values for the specified kind of data
  22597. * @param data a linear array of floating numbers
  22598. * @param kind the type of data that is being set, eg positions, colors etc
  22599. */
  22600. set(data: FloatArray, kind: string): void;
  22601. /**
  22602. * Associates the vertexData to the passed Mesh.
  22603. * Sets it as updatable or not (default `false`)
  22604. * @param mesh the mesh the vertexData is applied to
  22605. * @param updatable when used and having the value true allows new data to update the vertexData
  22606. * @returns the VertexData
  22607. */
  22608. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22609. /**
  22610. * Associates the vertexData to the passed Geometry.
  22611. * Sets it as updatable or not (default `false`)
  22612. * @param geometry the geometry the vertexData is applied to
  22613. * @param updatable when used and having the value true allows new data to update the vertexData
  22614. * @returns VertexData
  22615. */
  22616. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22617. /**
  22618. * Updates the associated mesh
  22619. * @param mesh the mesh to be updated
  22620. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22621. * @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
  22622. * @returns VertexData
  22623. */
  22624. updateMesh(mesh: Mesh): VertexData;
  22625. /**
  22626. * Updates the associated geometry
  22627. * @param geometry the geometry to be updated
  22628. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22629. * @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
  22630. * @returns VertexData.
  22631. */
  22632. updateGeometry(geometry: Geometry): VertexData;
  22633. private _applyTo;
  22634. private _update;
  22635. /**
  22636. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22637. * @param matrix the transforming matrix
  22638. * @returns the VertexData
  22639. */
  22640. transform(matrix: Matrix): VertexData;
  22641. /**
  22642. * Merges the passed VertexData into the current one
  22643. * @param other the VertexData to be merged into the current one
  22644. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22645. * @returns the modified VertexData
  22646. */
  22647. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22648. private _mergeElement;
  22649. private _validate;
  22650. /**
  22651. * Serializes the VertexData
  22652. * @returns a serialized object
  22653. */
  22654. serialize(): any;
  22655. /**
  22656. * Extracts the vertexData from a mesh
  22657. * @param mesh the mesh from which to extract the VertexData
  22658. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22659. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22660. * @returns the object VertexData associated to the passed mesh
  22661. */
  22662. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22663. /**
  22664. * Extracts the vertexData from the geometry
  22665. * @param geometry the geometry from which to extract the VertexData
  22666. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22667. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22668. * @returns the object VertexData associated to the passed mesh
  22669. */
  22670. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22671. private static _ExtractFrom;
  22672. /**
  22673. * Creates the VertexData for a Ribbon
  22674. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22675. * * pathArray array of paths, each of which an array of successive Vector3
  22676. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22677. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22678. * * 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
  22679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22680. * * 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)
  22681. * * 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)
  22682. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22683. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22684. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22685. * @returns the VertexData of the ribbon
  22686. */
  22687. static CreateRibbon(options: {
  22688. pathArray: Vector3[][];
  22689. closeArray?: boolean;
  22690. closePath?: boolean;
  22691. offset?: number;
  22692. sideOrientation?: number;
  22693. frontUVs?: Vector4;
  22694. backUVs?: Vector4;
  22695. invertUV?: boolean;
  22696. uvs?: Vector2[];
  22697. colors?: Color4[];
  22698. }): VertexData;
  22699. /**
  22700. * Creates the VertexData for a box
  22701. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22702. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22703. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22704. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22705. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22706. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22707. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22709. * * 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)
  22710. * * 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)
  22711. * @returns the VertexData of the box
  22712. */
  22713. static CreateBox(options: {
  22714. size?: number;
  22715. width?: number;
  22716. height?: number;
  22717. depth?: number;
  22718. faceUV?: Vector4[];
  22719. faceColors?: Color4[];
  22720. sideOrientation?: number;
  22721. frontUVs?: Vector4;
  22722. backUVs?: Vector4;
  22723. }): VertexData;
  22724. /**
  22725. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22726. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22727. * * segments sets the number of horizontal strips optional, default 32
  22728. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22729. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22730. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22731. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22732. * * 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
  22733. * * 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
  22734. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22735. * * 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)
  22736. * * 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)
  22737. * @returns the VertexData of the ellipsoid
  22738. */
  22739. static CreateSphere(options: {
  22740. segments?: number;
  22741. diameter?: number;
  22742. diameterX?: number;
  22743. diameterY?: number;
  22744. diameterZ?: number;
  22745. arc?: number;
  22746. slice?: number;
  22747. sideOrientation?: number;
  22748. frontUVs?: Vector4;
  22749. backUVs?: Vector4;
  22750. }): VertexData;
  22751. /**
  22752. * Creates the VertexData for a cylinder, cone or prism
  22753. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22754. * * height sets the height (y direction) of the cylinder, optional, default 2
  22755. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22756. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22757. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22758. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22759. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22760. * * 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
  22761. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22762. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22763. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22764. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22766. * * 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)
  22767. * * 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)
  22768. * @returns the VertexData of the cylinder, cone or prism
  22769. */
  22770. static CreateCylinder(options: {
  22771. height?: number;
  22772. diameterTop?: number;
  22773. diameterBottom?: number;
  22774. diameter?: number;
  22775. tessellation?: number;
  22776. subdivisions?: number;
  22777. arc?: number;
  22778. faceColors?: Color4[];
  22779. faceUV?: Vector4[];
  22780. hasRings?: boolean;
  22781. enclose?: boolean;
  22782. sideOrientation?: number;
  22783. frontUVs?: Vector4;
  22784. backUVs?: Vector4;
  22785. }): VertexData;
  22786. /**
  22787. * Creates the VertexData for a torus
  22788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22789. * * diameter the diameter of the torus, optional default 1
  22790. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22791. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22793. * * 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)
  22794. * * 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)
  22795. * @returns the VertexData of the torus
  22796. */
  22797. static CreateTorus(options: {
  22798. diameter?: number;
  22799. thickness?: number;
  22800. tessellation?: number;
  22801. sideOrientation?: number;
  22802. frontUVs?: Vector4;
  22803. backUVs?: Vector4;
  22804. }): VertexData;
  22805. /**
  22806. * Creates the VertexData of the LineSystem
  22807. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22808. * - lines an array of lines, each line being an array of successive Vector3
  22809. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22810. * @returns the VertexData of the LineSystem
  22811. */
  22812. static CreateLineSystem(options: {
  22813. lines: Vector3[][];
  22814. colors?: Nullable<Color4[][]>;
  22815. }): VertexData;
  22816. /**
  22817. * Create the VertexData for a DashedLines
  22818. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22819. * - points an array successive Vector3
  22820. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22821. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22822. * - dashNb the intended total number of dashes, optional, default 200
  22823. * @returns the VertexData for the DashedLines
  22824. */
  22825. static CreateDashedLines(options: {
  22826. points: Vector3[];
  22827. dashSize?: number;
  22828. gapSize?: number;
  22829. dashNb?: number;
  22830. }): VertexData;
  22831. /**
  22832. * Creates the VertexData for a Ground
  22833. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22834. * - width the width (x direction) of the ground, optional, default 1
  22835. * - height the height (z direction) of the ground, optional, default 1
  22836. * - subdivisions the number of subdivisions per side, optional, default 1
  22837. * @returns the VertexData of the Ground
  22838. */
  22839. static CreateGround(options: {
  22840. width?: number;
  22841. height?: number;
  22842. subdivisions?: number;
  22843. subdivisionsX?: number;
  22844. subdivisionsY?: number;
  22845. }): VertexData;
  22846. /**
  22847. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22848. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22849. * * xmin the ground minimum X coordinate, optional, default -1
  22850. * * zmin the ground minimum Z coordinate, optional, default -1
  22851. * * xmax the ground maximum X coordinate, optional, default 1
  22852. * * zmax the ground maximum Z coordinate, optional, default 1
  22853. * * 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}
  22854. * * 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}
  22855. * @returns the VertexData of the TiledGround
  22856. */
  22857. static CreateTiledGround(options: {
  22858. xmin: number;
  22859. zmin: number;
  22860. xmax: number;
  22861. zmax: number;
  22862. subdivisions?: {
  22863. w: number;
  22864. h: number;
  22865. };
  22866. precision?: {
  22867. w: number;
  22868. h: number;
  22869. };
  22870. }): VertexData;
  22871. /**
  22872. * Creates the VertexData of the Ground designed from a heightmap
  22873. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22874. * * width the width (x direction) of the ground
  22875. * * height the height (z direction) of the ground
  22876. * * subdivisions the number of subdivisions per side
  22877. * * minHeight the minimum altitude on the ground, optional, default 0
  22878. * * maxHeight the maximum altitude on the ground, optional default 1
  22879. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22880. * * buffer the array holding the image color data
  22881. * * bufferWidth the width of image
  22882. * * bufferHeight the height of image
  22883. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22884. * @returns the VertexData of the Ground designed from a heightmap
  22885. */
  22886. static CreateGroundFromHeightMap(options: {
  22887. width: number;
  22888. height: number;
  22889. subdivisions: number;
  22890. minHeight: number;
  22891. maxHeight: number;
  22892. colorFilter: Color3;
  22893. buffer: Uint8Array;
  22894. bufferWidth: number;
  22895. bufferHeight: number;
  22896. alphaFilter: number;
  22897. }): VertexData;
  22898. /**
  22899. * Creates the VertexData for a Plane
  22900. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22901. * * size sets the width and height of the plane to the value of size, optional default 1
  22902. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22903. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22905. * * 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)
  22906. * * 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)
  22907. * @returns the VertexData of the box
  22908. */
  22909. static CreatePlane(options: {
  22910. size?: number;
  22911. width?: number;
  22912. height?: number;
  22913. sideOrientation?: number;
  22914. frontUVs?: Vector4;
  22915. backUVs?: Vector4;
  22916. }): VertexData;
  22917. /**
  22918. * Creates the VertexData of the Disc or regular Polygon
  22919. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22920. * * radius the radius of the disc, optional default 0.5
  22921. * * tessellation the number of polygon sides, optional, default 64
  22922. * * 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
  22923. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22924. * * 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)
  22925. * * 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)
  22926. * @returns the VertexData of the box
  22927. */
  22928. static CreateDisc(options: {
  22929. radius?: number;
  22930. tessellation?: number;
  22931. arc?: number;
  22932. sideOrientation?: number;
  22933. frontUVs?: Vector4;
  22934. backUVs?: Vector4;
  22935. }): VertexData;
  22936. /**
  22937. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22938. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22939. * @param polygon a mesh built from polygonTriangulation.build()
  22940. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22941. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22942. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22943. * @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)
  22944. * @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)
  22945. * @returns the VertexData of the Polygon
  22946. */
  22947. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22948. /**
  22949. * Creates the VertexData of the IcoSphere
  22950. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22951. * * radius the radius of the IcoSphere, optional default 1
  22952. * * radiusX allows stretching in the x direction, optional, default radius
  22953. * * radiusY allows stretching in the y direction, optional, default radius
  22954. * * radiusZ allows stretching in the z direction, optional, default radius
  22955. * * flat when true creates a flat shaded mesh, optional, default true
  22956. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22958. * * 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)
  22959. * * 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)
  22960. * @returns the VertexData of the IcoSphere
  22961. */
  22962. static CreateIcoSphere(options: {
  22963. radius?: number;
  22964. radiusX?: number;
  22965. radiusY?: number;
  22966. radiusZ?: number;
  22967. flat?: boolean;
  22968. subdivisions?: number;
  22969. sideOrientation?: number;
  22970. frontUVs?: Vector4;
  22971. backUVs?: Vector4;
  22972. }): VertexData;
  22973. /**
  22974. * Creates the VertexData for a Polyhedron
  22975. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22976. * * type provided types are:
  22977. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22978. * * 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)
  22979. * * size the size of the IcoSphere, optional default 1
  22980. * * sizeX allows stretching in the x direction, optional, default size
  22981. * * sizeY allows stretching in the y direction, optional, default size
  22982. * * sizeZ allows stretching in the z direction, optional, default size
  22983. * * 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
  22984. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22985. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22986. * * flat when true creates a flat shaded mesh, optional, default true
  22987. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22989. * * 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)
  22990. * * 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)
  22991. * @returns the VertexData of the Polyhedron
  22992. */
  22993. static CreatePolyhedron(options: {
  22994. type?: number;
  22995. size?: number;
  22996. sizeX?: number;
  22997. sizeY?: number;
  22998. sizeZ?: number;
  22999. custom?: any;
  23000. faceUV?: Vector4[];
  23001. faceColors?: Color4[];
  23002. flat?: boolean;
  23003. sideOrientation?: number;
  23004. frontUVs?: Vector4;
  23005. backUVs?: Vector4;
  23006. }): VertexData;
  23007. /**
  23008. * Creates the VertexData for a TorusKnot
  23009. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23010. * * radius the radius of the torus knot, optional, default 2
  23011. * * tube the thickness of the tube, optional, default 0.5
  23012. * * radialSegments the number of sides on each tube segments, optional, default 32
  23013. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23014. * * p the number of windings around the z axis, optional, default 2
  23015. * * q the number of windings around the x axis, optional, default 3
  23016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23017. * * 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)
  23018. * * 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)
  23019. * @returns the VertexData of the Torus Knot
  23020. */
  23021. static CreateTorusKnot(options: {
  23022. radius?: number;
  23023. tube?: number;
  23024. radialSegments?: number;
  23025. tubularSegments?: number;
  23026. p?: number;
  23027. q?: number;
  23028. sideOrientation?: number;
  23029. frontUVs?: Vector4;
  23030. backUVs?: Vector4;
  23031. }): VertexData;
  23032. /**
  23033. * Compute normals for given positions and indices
  23034. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23035. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23036. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23037. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23038. * * facetNormals : optional array of facet normals (vector3)
  23039. * * facetPositions : optional array of facet positions (vector3)
  23040. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23041. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23042. * * bInfo : optional bounding info, required for facetPartitioning computation
  23043. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23044. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23045. * * useRightHandedSystem: optional boolean to for right handed system computation
  23046. * * depthSort : optional boolean to enable the facet depth sort computation
  23047. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23048. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23049. */
  23050. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23051. facetNormals?: any;
  23052. facetPositions?: any;
  23053. facetPartitioning?: any;
  23054. ratio?: number;
  23055. bInfo?: any;
  23056. bbSize?: Vector3;
  23057. subDiv?: any;
  23058. useRightHandedSystem?: boolean;
  23059. depthSort?: boolean;
  23060. distanceTo?: Vector3;
  23061. depthSortedFacets?: any;
  23062. }): void;
  23063. /** @hidden */
  23064. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23065. /**
  23066. * Applies VertexData created from the imported parameters to the geometry
  23067. * @param parsedVertexData the parsed data from an imported file
  23068. * @param geometry the geometry to apply the VertexData to
  23069. */
  23070. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23071. }
  23072. }
  23073. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23074. import { Nullable } from "babylonjs/types";
  23075. import { Scene } from "babylonjs/scene";
  23076. import { Vector4 } from "babylonjs/Maths/math";
  23077. import { Mesh } from "babylonjs/Meshes/mesh";
  23078. /**
  23079. * Class containing static functions to help procedurally build meshes
  23080. */
  23081. export class DiscBuilder {
  23082. /**
  23083. * Creates a plane polygonal mesh. By default, this is a disc
  23084. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23085. * * 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
  23086. * * 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
  23087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23090. * @param name defines the name of the mesh
  23091. * @param options defines the options used to create the mesh
  23092. * @param scene defines the hosting scene
  23093. * @returns the plane polygonal mesh
  23094. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23095. */
  23096. static CreateDisc(name: string, options: {
  23097. radius?: number;
  23098. tessellation?: number;
  23099. arc?: number;
  23100. updatable?: boolean;
  23101. sideOrientation?: number;
  23102. frontUVs?: Vector4;
  23103. backUVs?: Vector4;
  23104. }, scene?: Nullable<Scene>): Mesh;
  23105. }
  23106. }
  23107. declare module "babylonjs/Particles/solidParticleSystem" {
  23108. import { Vector3 } from "babylonjs/Maths/math";
  23109. import { Mesh } from "babylonjs/Meshes/mesh";
  23110. import { Scene, IDisposable } from "babylonjs/scene";
  23111. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23112. /**
  23113. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23114. *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.
  23115. * The SPS is also a particle system. It provides some methods to manage the particles.
  23116. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23117. *
  23118. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23119. */
  23120. export class SolidParticleSystem implements IDisposable {
  23121. /**
  23122. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23123. * Example : var p = SPS.particles[i];
  23124. */
  23125. particles: SolidParticle[];
  23126. /**
  23127. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23128. */
  23129. nbParticles: number;
  23130. /**
  23131. * If the particles must ever face the camera (default false). Useful for planar particles.
  23132. */
  23133. billboard: boolean;
  23134. /**
  23135. * Recompute normals when adding a shape
  23136. */
  23137. recomputeNormals: boolean;
  23138. /**
  23139. * This a counter ofr your own usage. It's not set by any SPS functions.
  23140. */
  23141. counter: number;
  23142. /**
  23143. * The SPS name. This name is also given to the underlying mesh.
  23144. */
  23145. name: string;
  23146. /**
  23147. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23148. */
  23149. mesh: Mesh;
  23150. /**
  23151. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23152. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23153. */
  23154. vars: any;
  23155. /**
  23156. * This array is populated when the SPS is set as 'pickable'.
  23157. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23158. * Each element of this array is an object `{idx: int, faceId: int}`.
  23159. * `idx` is the picked particle index in the `SPS.particles` array
  23160. * `faceId` is the picked face index counted within this particle.
  23161. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23162. */
  23163. pickedParticles: {
  23164. idx: number;
  23165. faceId: number;
  23166. }[];
  23167. /**
  23168. * This array is populated when `enableDepthSort` is set to true.
  23169. * Each element of this array is an instance of the class DepthSortedParticle.
  23170. */
  23171. depthSortedParticles: DepthSortedParticle[];
  23172. /**
  23173. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23174. * @hidden
  23175. */
  23176. _bSphereOnly: boolean;
  23177. /**
  23178. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23179. * @hidden
  23180. */
  23181. _bSphereRadiusFactor: number;
  23182. private _scene;
  23183. private _positions;
  23184. private _indices;
  23185. private _normals;
  23186. private _colors;
  23187. private _uvs;
  23188. private _indices32;
  23189. private _positions32;
  23190. private _normals32;
  23191. private _fixedNormal32;
  23192. private _colors32;
  23193. private _uvs32;
  23194. private _index;
  23195. private _updatable;
  23196. private _pickable;
  23197. private _isVisibilityBoxLocked;
  23198. private _alwaysVisible;
  23199. private _depthSort;
  23200. private _shapeCounter;
  23201. private _copy;
  23202. private _color;
  23203. private _computeParticleColor;
  23204. private _computeParticleTexture;
  23205. private _computeParticleRotation;
  23206. private _computeParticleVertex;
  23207. private _computeBoundingBox;
  23208. private _depthSortParticles;
  23209. private _camera;
  23210. private _mustUnrotateFixedNormals;
  23211. private _particlesIntersect;
  23212. private _needs32Bits;
  23213. /**
  23214. * Creates a SPS (Solid Particle System) object.
  23215. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23216. * @param scene (Scene) is the scene in which the SPS is added.
  23217. * @param options defines the options of the sps e.g.
  23218. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23219. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23220. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23221. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23222. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23223. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23224. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23225. */
  23226. constructor(name: string, scene: Scene, options?: {
  23227. updatable?: boolean;
  23228. isPickable?: boolean;
  23229. enableDepthSort?: boolean;
  23230. particleIntersection?: boolean;
  23231. boundingSphereOnly?: boolean;
  23232. bSphereRadiusFactor?: number;
  23233. });
  23234. /**
  23235. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23236. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23237. * @returns the created mesh
  23238. */
  23239. buildMesh(): Mesh;
  23240. /**
  23241. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23242. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23243. * Thus the particles generated from `digest()` have their property `position` set yet.
  23244. * @param mesh ( Mesh ) is the mesh to be digested
  23245. * @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
  23246. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23247. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23248. * @returns the current SPS
  23249. */
  23250. digest(mesh: Mesh, options?: {
  23251. facetNb?: number;
  23252. number?: number;
  23253. delta?: number;
  23254. }): SolidParticleSystem;
  23255. private _unrotateFixedNormals;
  23256. private _resetCopy;
  23257. private _meshBuilder;
  23258. private _posToShape;
  23259. private _uvsToShapeUV;
  23260. private _addParticle;
  23261. /**
  23262. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23263. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23264. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23265. * @param nb (positive integer) the number of particles to be created from this model
  23266. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23267. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23268. * @returns the number of shapes in the system
  23269. */
  23270. addShape(mesh: Mesh, nb: number, options?: {
  23271. positionFunction?: any;
  23272. vertexFunction?: any;
  23273. }): number;
  23274. private _rebuildParticle;
  23275. /**
  23276. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23277. * @returns the SPS.
  23278. */
  23279. rebuildMesh(): SolidParticleSystem;
  23280. /**
  23281. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23282. * This method calls `updateParticle()` for each particle of the SPS.
  23283. * For an animated SPS, it is usually called within the render loop.
  23284. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23285. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23286. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23287. * @returns the SPS.
  23288. */
  23289. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23290. /**
  23291. * Disposes the SPS.
  23292. */
  23293. dispose(): void;
  23294. /**
  23295. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23296. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23297. * @returns the SPS.
  23298. */
  23299. refreshVisibleSize(): SolidParticleSystem;
  23300. /**
  23301. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23302. * @param size the size (float) of the visibility box
  23303. * note : this doesn't lock the SPS mesh bounding box.
  23304. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23305. */
  23306. setVisibilityBox(size: number): void;
  23307. /**
  23308. * Gets whether the SPS as always visible or not
  23309. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23310. */
  23311. /**
  23312. * Sets the SPS as always visible or not
  23313. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23314. */
  23315. isAlwaysVisible: boolean;
  23316. /**
  23317. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23318. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23319. */
  23320. /**
  23321. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23322. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23323. */
  23324. isVisibilityBoxLocked: boolean;
  23325. /**
  23326. * Tells to `setParticles()` to compute the particle rotations or not.
  23327. * Default value : true. The SPS is faster when it's set to false.
  23328. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23329. */
  23330. /**
  23331. * Gets if `setParticles()` computes the particle rotations or not.
  23332. * Default value : true. The SPS is faster when it's set to false.
  23333. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23334. */
  23335. computeParticleRotation: boolean;
  23336. /**
  23337. * Tells to `setParticles()` to compute the particle colors or not.
  23338. * Default value : true. The SPS is faster when it's set to false.
  23339. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23340. */
  23341. /**
  23342. * Gets if `setParticles()` computes the particle colors or not.
  23343. * Default value : true. The SPS is faster when it's set to false.
  23344. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23345. */
  23346. computeParticleColor: boolean;
  23347. /**
  23348. * Gets if `setParticles()` computes the particle textures or not.
  23349. * Default value : true. The SPS is faster when it's set to false.
  23350. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23351. */
  23352. computeParticleTexture: boolean;
  23353. /**
  23354. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23355. * Default value : false. The SPS is faster when it's set to false.
  23356. * Note : the particle custom vertex positions aren't stored values.
  23357. */
  23358. /**
  23359. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23360. * Default value : false. The SPS is faster when it's set to false.
  23361. * Note : the particle custom vertex positions aren't stored values.
  23362. */
  23363. computeParticleVertex: boolean;
  23364. /**
  23365. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23366. */
  23367. /**
  23368. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23369. */
  23370. computeBoundingBox: boolean;
  23371. /**
  23372. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23373. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23374. * Default : `true`
  23375. */
  23376. /**
  23377. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23378. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23379. * Default : `true`
  23380. */
  23381. depthSortParticles: boolean;
  23382. /**
  23383. * This function does nothing. It may be overwritten to set all the particle first values.
  23384. * The SPS doesn't call this function, you may have to call it by your own.
  23385. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23386. */
  23387. initParticles(): void;
  23388. /**
  23389. * This function does nothing. It may be overwritten to recycle a particle.
  23390. * The SPS doesn't call this function, you may have to call it by your own.
  23391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23392. * @param particle The particle to recycle
  23393. * @returns the recycled particle
  23394. */
  23395. recycleParticle(particle: SolidParticle): SolidParticle;
  23396. /**
  23397. * Updates a particle : this function should be overwritten by the user.
  23398. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23399. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23400. * @example : just set a particle position or velocity and recycle conditions
  23401. * @param particle The particle to update
  23402. * @returns the updated particle
  23403. */
  23404. updateParticle(particle: SolidParticle): SolidParticle;
  23405. /**
  23406. * Updates a vertex of a particle : it can be overwritten by the user.
  23407. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23408. * @param particle the current particle
  23409. * @param vertex the current index of the current particle
  23410. * @param pt the index of the current vertex in the particle shape
  23411. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23412. * @example : just set a vertex particle position
  23413. * @returns the updated vertex
  23414. */
  23415. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23416. /**
  23417. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23418. * This does nothing and may be overwritten by the user.
  23419. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23420. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23421. * @param update the boolean update value actually passed to setParticles()
  23422. */
  23423. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23424. /**
  23425. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23426. * This will be passed three parameters.
  23427. * This does nothing and may be overwritten by the user.
  23428. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23429. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23430. * @param update the boolean update value actually passed to setParticles()
  23431. */
  23432. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23433. }
  23434. }
  23435. declare module "babylonjs/Particles/solidParticle" {
  23436. import { Nullable } from "babylonjs/types";
  23437. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23438. import { Mesh } from "babylonjs/Meshes/mesh";
  23439. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23440. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23441. /**
  23442. * Represents one particle of a solid particle system.
  23443. */
  23444. export class SolidParticle {
  23445. /**
  23446. * particle global index
  23447. */
  23448. idx: number;
  23449. /**
  23450. * The color of the particle
  23451. */
  23452. color: Nullable<Color4>;
  23453. /**
  23454. * The world space position of the particle.
  23455. */
  23456. position: Vector3;
  23457. /**
  23458. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23459. */
  23460. rotation: Vector3;
  23461. /**
  23462. * The world space rotation quaternion of the particle.
  23463. */
  23464. rotationQuaternion: Nullable<Quaternion>;
  23465. /**
  23466. * The scaling of the particle.
  23467. */
  23468. scaling: Vector3;
  23469. /**
  23470. * The uvs of the particle.
  23471. */
  23472. uvs: Vector4;
  23473. /**
  23474. * The current speed of the particle.
  23475. */
  23476. velocity: Vector3;
  23477. /**
  23478. * The pivot point in the particle local space.
  23479. */
  23480. pivot: Vector3;
  23481. /**
  23482. * Must the particle be translated from its pivot point in its local space ?
  23483. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23484. * Default : false
  23485. */
  23486. translateFromPivot: boolean;
  23487. /**
  23488. * Is the particle active or not ?
  23489. */
  23490. alive: boolean;
  23491. /**
  23492. * Is the particle visible or not ?
  23493. */
  23494. isVisible: boolean;
  23495. /**
  23496. * Index of this particle in the global "positions" array (Internal use)
  23497. * @hidden
  23498. */
  23499. _pos: number;
  23500. /**
  23501. * @hidden Index of this particle in the global "indices" array (Internal use)
  23502. */
  23503. _ind: number;
  23504. /**
  23505. * @hidden ModelShape of this particle (Internal use)
  23506. */
  23507. _model: ModelShape;
  23508. /**
  23509. * ModelShape id of this particle
  23510. */
  23511. shapeId: number;
  23512. /**
  23513. * Index of the particle in its shape id (Internal use)
  23514. */
  23515. idxInShape: number;
  23516. /**
  23517. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23518. */
  23519. _modelBoundingInfo: BoundingInfo;
  23520. /**
  23521. * @hidden Particle BoundingInfo object (Internal use)
  23522. */
  23523. _boundingInfo: BoundingInfo;
  23524. /**
  23525. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23526. */
  23527. _sps: SolidParticleSystem;
  23528. /**
  23529. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23530. */
  23531. _stillInvisible: boolean;
  23532. /**
  23533. * @hidden Last computed particle rotation matrix
  23534. */
  23535. _rotationMatrix: number[];
  23536. /**
  23537. * Parent particle Id, if any.
  23538. * Default null.
  23539. */
  23540. parentId: Nullable<number>;
  23541. /**
  23542. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23543. * The possible values are :
  23544. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23545. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23546. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23547. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23548. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23549. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23550. * */
  23551. cullingStrategy: number;
  23552. /**
  23553. * @hidden Internal global position in the SPS.
  23554. */
  23555. _globalPosition: Vector3;
  23556. /**
  23557. * Creates a Solid Particle object.
  23558. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23559. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23560. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23561. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23562. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23563. * @param shapeId (integer) is the model shape identifier in the SPS.
  23564. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23565. * @param sps defines the sps it is associated to
  23566. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23567. */
  23568. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23569. /**
  23570. * Legacy support, changed scale to scaling
  23571. */
  23572. /**
  23573. * Legacy support, changed scale to scaling
  23574. */
  23575. scale: Vector3;
  23576. /**
  23577. * Legacy support, changed quaternion to rotationQuaternion
  23578. */
  23579. /**
  23580. * Legacy support, changed quaternion to rotationQuaternion
  23581. */
  23582. quaternion: Nullable<Quaternion>;
  23583. /**
  23584. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23585. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23586. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23587. * @returns true if it intersects
  23588. */
  23589. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23590. /**
  23591. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23592. * A particle is in the frustum if its bounding box intersects the frustum
  23593. * @param frustumPlanes defines the frustum to test
  23594. * @returns true if the particle is in the frustum planes
  23595. */
  23596. isInFrustum(frustumPlanes: Plane[]): boolean;
  23597. /**
  23598. * get the rotation matrix of the particle
  23599. * @hidden
  23600. */
  23601. getRotationMatrix(m: Matrix): void;
  23602. }
  23603. /**
  23604. * Represents the shape of the model used by one particle of a solid particle system.
  23605. * SPS internal tool, don't use it manually.
  23606. */
  23607. export class ModelShape {
  23608. /**
  23609. * The shape id
  23610. * @hidden
  23611. */
  23612. shapeID: number;
  23613. /**
  23614. * flat array of model positions (internal use)
  23615. * @hidden
  23616. */
  23617. _shape: Vector3[];
  23618. /**
  23619. * flat array of model UVs (internal use)
  23620. * @hidden
  23621. */
  23622. _shapeUV: number[];
  23623. /**
  23624. * length of the shape in the model indices array (internal use)
  23625. * @hidden
  23626. */
  23627. _indicesLength: number;
  23628. /**
  23629. * Custom position function (internal use)
  23630. * @hidden
  23631. */
  23632. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23633. /**
  23634. * Custom vertex function (internal use)
  23635. * @hidden
  23636. */
  23637. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23638. /**
  23639. * 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.
  23640. * SPS internal tool, don't use it manually.
  23641. * @hidden
  23642. */
  23643. 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>);
  23644. }
  23645. /**
  23646. * Represents a Depth Sorted Particle in the solid particle system.
  23647. */
  23648. export class DepthSortedParticle {
  23649. /**
  23650. * Index of the particle in the "indices" array
  23651. */
  23652. ind: number;
  23653. /**
  23654. * Length of the particle shape in the "indices" array
  23655. */
  23656. indicesLength: number;
  23657. /**
  23658. * Squared distance from the particle to the camera
  23659. */
  23660. sqDistance: number;
  23661. }
  23662. }
  23663. declare module "babylonjs/Meshes/abstractMesh" {
  23664. import { Observable } from "babylonjs/Misc/observable";
  23665. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23666. import { Camera } from "babylonjs/Cameras/camera";
  23667. import { Scene, IDisposable } from "babylonjs/scene";
  23668. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23669. import { Node } from "babylonjs/node";
  23670. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23671. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23674. import { Ray } from "babylonjs/Culling/ray";
  23675. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23676. import { Material } from "babylonjs/Materials/material";
  23677. import { Light } from "babylonjs/Lights/light";
  23678. import { Skeleton } from "babylonjs/Bones/skeleton";
  23679. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23680. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23681. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23682. import { Collider } from "babylonjs/Collisions/collider";
  23683. /**
  23684. * Class used to store all common mesh properties
  23685. */
  23686. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23687. /** No occlusion */
  23688. static OCCLUSION_TYPE_NONE: number;
  23689. /** Occlusion set to optimisitic */
  23690. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23691. /** Occlusion set to strict */
  23692. static OCCLUSION_TYPE_STRICT: number;
  23693. /** Use an accurante occlusion algorithm */
  23694. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23695. /** Use a conservative occlusion algorithm */
  23696. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23697. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23698. * Test order :
  23699. * Is the bounding sphere outside the frustum ?
  23700. * If not, are the bounding box vertices outside the frustum ?
  23701. * It not, then the cullable object is in the frustum.
  23702. */
  23703. static readonly CULLINGSTRATEGY_STANDARD: number;
  23704. /** Culling strategy : Bounding Sphere Only.
  23705. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23706. * It's also less accurate than the standard because some not visible objects can still be selected.
  23707. * Test : is the bounding sphere outside the frustum ?
  23708. * If not, then the cullable object is in the frustum.
  23709. */
  23710. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23711. /** Culling strategy : Optimistic Inclusion.
  23712. * This in an inclusion test first, then the standard exclusion test.
  23713. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23714. * 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.
  23715. * Anyway, it's as accurate as the standard strategy.
  23716. * Test :
  23717. * Is the cullable object bounding sphere center in the frustum ?
  23718. * If not, apply the default culling strategy.
  23719. */
  23720. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23721. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23722. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23723. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23724. * 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.
  23725. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23726. * Test :
  23727. * Is the cullable object bounding sphere center in the frustum ?
  23728. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23729. */
  23730. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23731. /**
  23732. * No billboard
  23733. */
  23734. static readonly BILLBOARDMODE_NONE: number;
  23735. /** Billboard on X axis */
  23736. static readonly BILLBOARDMODE_X: number;
  23737. /** Billboard on Y axis */
  23738. static readonly BILLBOARDMODE_Y: number;
  23739. /** Billboard on Z axis */
  23740. static readonly BILLBOARDMODE_Z: number;
  23741. /** Billboard on all axes */
  23742. static readonly BILLBOARDMODE_ALL: number;
  23743. private _facetData;
  23744. /**
  23745. * The culling strategy to use to check whether the mesh must be rendered or not.
  23746. * This value can be changed at any time and will be used on the next render mesh selection.
  23747. * The possible values are :
  23748. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23749. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23750. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23751. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23752. * Please read each static variable documentation to get details about the culling process.
  23753. * */
  23754. cullingStrategy: number;
  23755. /**
  23756. * Gets the number of facets in the mesh
  23757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23758. */
  23759. readonly facetNb: number;
  23760. /**
  23761. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23763. */
  23764. partitioningSubdivisions: number;
  23765. /**
  23766. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23767. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23769. */
  23770. partitioningBBoxRatio: number;
  23771. /**
  23772. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23773. * Works only for updatable meshes.
  23774. * Doesn't work with multi-materials
  23775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23776. */
  23777. mustDepthSortFacets: boolean;
  23778. /**
  23779. * The location (Vector3) where the facet depth sort must be computed from.
  23780. * By default, the active camera position.
  23781. * Used only when facet depth sort is enabled
  23782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23783. */
  23784. facetDepthSortFrom: Vector3;
  23785. /**
  23786. * gets a boolean indicating if facetData is enabled
  23787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23788. */
  23789. readonly isFacetDataEnabled: boolean;
  23790. /** @hidden */
  23791. _updateNonUniformScalingState(value: boolean): boolean;
  23792. /**
  23793. * An event triggered when this mesh collides with another one
  23794. */
  23795. onCollideObservable: Observable<AbstractMesh>;
  23796. private _onCollideObserver;
  23797. /** Set a function to call when this mesh collides with another one */
  23798. onCollide: () => void;
  23799. /**
  23800. * An event triggered when the collision's position changes
  23801. */
  23802. onCollisionPositionChangeObservable: Observable<Vector3>;
  23803. private _onCollisionPositionChangeObserver;
  23804. /** Set a function to call when the collision's position changes */
  23805. onCollisionPositionChange: () => void;
  23806. /**
  23807. * An event triggered when material is changed
  23808. */
  23809. onMaterialChangedObservable: Observable<AbstractMesh>;
  23810. /**
  23811. * Gets or sets the orientation for POV movement & rotation
  23812. */
  23813. definedFacingForward: boolean;
  23814. /** @hidden */
  23815. _occlusionQuery: Nullable<WebGLQuery>;
  23816. private _visibility;
  23817. /**
  23818. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23819. */
  23820. /**
  23821. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23822. */
  23823. visibility: number;
  23824. /** Gets or sets the alpha index used to sort transparent meshes
  23825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23826. */
  23827. alphaIndex: number;
  23828. /**
  23829. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23830. */
  23831. isVisible: boolean;
  23832. /**
  23833. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23834. */
  23835. isPickable: boolean;
  23836. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23837. showSubMeshesBoundingBox: boolean;
  23838. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23840. */
  23841. isBlocker: boolean;
  23842. /**
  23843. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23844. */
  23845. enablePointerMoveEvents: boolean;
  23846. /**
  23847. * Specifies the rendering group id for this mesh (0 by default)
  23848. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23849. */
  23850. renderingGroupId: number;
  23851. private _material;
  23852. /** Gets or sets current material */
  23853. material: Nullable<Material>;
  23854. private _receiveShadows;
  23855. /**
  23856. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23857. * @see http://doc.babylonjs.com/babylon101/shadows
  23858. */
  23859. receiveShadows: boolean;
  23860. /** Defines color to use when rendering outline */
  23861. outlineColor: Color3;
  23862. /** Define width to use when rendering outline */
  23863. outlineWidth: number;
  23864. /** Defines color to use when rendering overlay */
  23865. overlayColor: Color3;
  23866. /** Defines alpha to use when rendering overlay */
  23867. overlayAlpha: number;
  23868. private _hasVertexAlpha;
  23869. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23870. hasVertexAlpha: boolean;
  23871. private _useVertexColors;
  23872. /** 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) */
  23873. useVertexColors: boolean;
  23874. private _computeBonesUsingShaders;
  23875. /**
  23876. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23877. */
  23878. computeBonesUsingShaders: boolean;
  23879. private _numBoneInfluencers;
  23880. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23881. numBoneInfluencers: number;
  23882. private _applyFog;
  23883. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23884. applyFog: boolean;
  23885. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23886. useOctreeForRenderingSelection: boolean;
  23887. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23888. useOctreeForPicking: boolean;
  23889. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23890. useOctreeForCollisions: boolean;
  23891. private _layerMask;
  23892. /**
  23893. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23894. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23895. */
  23896. layerMask: number;
  23897. /**
  23898. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23899. */
  23900. alwaysSelectAsActiveMesh: boolean;
  23901. /**
  23902. * Gets or sets the current action manager
  23903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23904. */
  23905. actionManager: Nullable<AbstractActionManager>;
  23906. private _checkCollisions;
  23907. private _collisionMask;
  23908. private _collisionGroup;
  23909. /**
  23910. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23911. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23912. */
  23913. ellipsoid: Vector3;
  23914. /**
  23915. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23916. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23917. */
  23918. ellipsoidOffset: Vector3;
  23919. private _collider;
  23920. private _oldPositionForCollisions;
  23921. private _diffPositionForCollisions;
  23922. /**
  23923. * Gets or sets a collision mask used to mask collisions (default is -1).
  23924. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23925. */
  23926. collisionMask: number;
  23927. /**
  23928. * Gets or sets the current collision group mask (-1 by default).
  23929. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23930. */
  23931. collisionGroup: number;
  23932. /**
  23933. * Defines edge width used when edgesRenderer is enabled
  23934. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23935. */
  23936. edgesWidth: number;
  23937. /**
  23938. * Defines edge color used when edgesRenderer is enabled
  23939. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23940. */
  23941. edgesColor: Color4;
  23942. /** @hidden */
  23943. _edgesRenderer: Nullable<IEdgesRenderer>;
  23944. /** @hidden */
  23945. _masterMesh: Nullable<AbstractMesh>;
  23946. /** @hidden */
  23947. _boundingInfo: Nullable<BoundingInfo>;
  23948. /** @hidden */
  23949. _renderId: number;
  23950. /**
  23951. * Gets or sets the list of subMeshes
  23952. * @see http://doc.babylonjs.com/how_to/multi_materials
  23953. */
  23954. subMeshes: SubMesh[];
  23955. /** @hidden */
  23956. _intersectionsInProgress: AbstractMesh[];
  23957. /** @hidden */
  23958. _unIndexed: boolean;
  23959. /** @hidden */
  23960. _lightSources: Light[];
  23961. /** @hidden */
  23962. readonly _positions: Nullable<Vector3[]>;
  23963. /** @hidden */
  23964. _waitingActions: any;
  23965. /** @hidden */
  23966. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23967. private _skeleton;
  23968. /** @hidden */
  23969. _bonesTransformMatrices: Nullable<Float32Array>;
  23970. /**
  23971. * Gets or sets a skeleton to apply skining transformations
  23972. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23973. */
  23974. skeleton: Nullable<Skeleton>;
  23975. /**
  23976. * An event triggered when the mesh is rebuilt.
  23977. */
  23978. onRebuildObservable: Observable<AbstractMesh>;
  23979. /**
  23980. * Creates a new AbstractMesh
  23981. * @param name defines the name of the mesh
  23982. * @param scene defines the hosting scene
  23983. */
  23984. constructor(name: string, scene?: Nullable<Scene>);
  23985. /**
  23986. * Returns the string "AbstractMesh"
  23987. * @returns "AbstractMesh"
  23988. */
  23989. getClassName(): string;
  23990. /**
  23991. * Gets a string representation of the current mesh
  23992. * @param fullDetails defines a boolean indicating if full details must be included
  23993. * @returns a string representation of the current mesh
  23994. */
  23995. toString(fullDetails?: boolean): string;
  23996. /** @hidden */
  23997. _rebuild(): void;
  23998. /** @hidden */
  23999. _resyncLightSources(): void;
  24000. /** @hidden */
  24001. _resyncLighSource(light: Light): void;
  24002. /** @hidden */
  24003. _unBindEffect(): void;
  24004. /** @hidden */
  24005. _removeLightSource(light: Light): void;
  24006. private _markSubMeshesAsDirty;
  24007. /** @hidden */
  24008. _markSubMeshesAsLightDirty(): void;
  24009. /** @hidden */
  24010. _markSubMeshesAsAttributesDirty(): void;
  24011. /** @hidden */
  24012. _markSubMeshesAsMiscDirty(): void;
  24013. /**
  24014. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24015. */
  24016. scaling: Vector3;
  24017. /**
  24018. * Returns true if the mesh is blocked. Implemented by child classes
  24019. */
  24020. readonly isBlocked: boolean;
  24021. /**
  24022. * Returns the mesh itself by default. Implemented by child classes
  24023. * @param camera defines the camera to use to pick the right LOD level
  24024. * @returns the currentAbstractMesh
  24025. */
  24026. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24027. /**
  24028. * Returns 0 by default. Implemented by child classes
  24029. * @returns an integer
  24030. */
  24031. getTotalVertices(): number;
  24032. /**
  24033. * Returns a positive integer : the total number of indices in this mesh geometry.
  24034. * @returns the numner of indices or zero if the mesh has no geometry.
  24035. */
  24036. getTotalIndices(): number;
  24037. /**
  24038. * Returns null by default. Implemented by child classes
  24039. * @returns null
  24040. */
  24041. getIndices(): Nullable<IndicesArray>;
  24042. /**
  24043. * Returns the array of the requested vertex data kind. Implemented by child classes
  24044. * @param kind defines the vertex data kind to use
  24045. * @returns null
  24046. */
  24047. getVerticesData(kind: string): Nullable<FloatArray>;
  24048. /**
  24049. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24050. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24051. * Note that a new underlying VertexBuffer object is created each call.
  24052. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24053. * @param kind defines vertex data kind:
  24054. * * VertexBuffer.PositionKind
  24055. * * VertexBuffer.UVKind
  24056. * * VertexBuffer.UV2Kind
  24057. * * VertexBuffer.UV3Kind
  24058. * * VertexBuffer.UV4Kind
  24059. * * VertexBuffer.UV5Kind
  24060. * * VertexBuffer.UV6Kind
  24061. * * VertexBuffer.ColorKind
  24062. * * VertexBuffer.MatricesIndicesKind
  24063. * * VertexBuffer.MatricesIndicesExtraKind
  24064. * * VertexBuffer.MatricesWeightsKind
  24065. * * VertexBuffer.MatricesWeightsExtraKind
  24066. * @param data defines the data source
  24067. * @param updatable defines if the data must be flagged as updatable (or static)
  24068. * @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
  24069. * @returns the current mesh
  24070. */
  24071. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24072. /**
  24073. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24074. * If the mesh has no geometry, it is simply returned as it is.
  24075. * @param kind defines vertex data kind:
  24076. * * VertexBuffer.PositionKind
  24077. * * VertexBuffer.UVKind
  24078. * * VertexBuffer.UV2Kind
  24079. * * VertexBuffer.UV3Kind
  24080. * * VertexBuffer.UV4Kind
  24081. * * VertexBuffer.UV5Kind
  24082. * * VertexBuffer.UV6Kind
  24083. * * VertexBuffer.ColorKind
  24084. * * VertexBuffer.MatricesIndicesKind
  24085. * * VertexBuffer.MatricesIndicesExtraKind
  24086. * * VertexBuffer.MatricesWeightsKind
  24087. * * VertexBuffer.MatricesWeightsExtraKind
  24088. * @param data defines the data source
  24089. * @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
  24090. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24091. * @returns the current mesh
  24092. */
  24093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24094. /**
  24095. * Sets the mesh indices,
  24096. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24097. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24098. * @param totalVertices Defines the total number of vertices
  24099. * @returns the current mesh
  24100. */
  24101. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24102. /**
  24103. * Gets a boolean indicating if specific vertex data is present
  24104. * @param kind defines the vertex data kind to use
  24105. * @returns true is data kind is present
  24106. */
  24107. isVerticesDataPresent(kind: string): boolean;
  24108. /**
  24109. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24110. * @returns a BoundingInfo
  24111. */
  24112. getBoundingInfo(): BoundingInfo;
  24113. /**
  24114. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24115. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24116. * @returns the current mesh
  24117. */
  24118. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24119. /**
  24120. * Overwrite the current bounding info
  24121. * @param boundingInfo defines the new bounding info
  24122. * @returns the current mesh
  24123. */
  24124. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24125. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24126. readonly useBones: boolean;
  24127. /** @hidden */
  24128. _preActivate(): void;
  24129. /** @hidden */
  24130. _preActivateForIntermediateRendering(renderId: number): void;
  24131. /** @hidden */
  24132. _activate(renderId: number): void;
  24133. /**
  24134. * Gets the current world matrix
  24135. * @returns a Matrix
  24136. */
  24137. getWorldMatrix(): Matrix;
  24138. /** @hidden */
  24139. _getWorldMatrixDeterminant(): number;
  24140. /**
  24141. * Perform relative position change from the point of view of behind the front of the mesh.
  24142. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24143. * Supports definition of mesh facing forward or backward
  24144. * @param amountRight defines the distance on the right axis
  24145. * @param amountUp defines the distance on the up axis
  24146. * @param amountForward defines the distance on the forward axis
  24147. * @returns the current mesh
  24148. */
  24149. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24150. /**
  24151. * Calculate relative position change from the point of view of behind the front of the mesh.
  24152. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24153. * Supports definition of mesh facing forward or backward
  24154. * @param amountRight defines the distance on the right axis
  24155. * @param amountUp defines the distance on the up axis
  24156. * @param amountForward defines the distance on the forward axis
  24157. * @returns the new displacement vector
  24158. */
  24159. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24160. /**
  24161. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24162. * Supports definition of mesh facing forward or backward
  24163. * @param flipBack defines the flip
  24164. * @param twirlClockwise defines the twirl
  24165. * @param tiltRight defines the tilt
  24166. * @returns the current mesh
  24167. */
  24168. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24169. /**
  24170. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24171. * Supports definition of mesh facing forward or backward.
  24172. * @param flipBack defines the flip
  24173. * @param twirlClockwise defines the twirl
  24174. * @param tiltRight defines the tilt
  24175. * @returns the new rotation vector
  24176. */
  24177. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24178. /**
  24179. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24180. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24181. * @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
  24182. * @returns the new bounding vectors
  24183. */
  24184. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24185. min: Vector3;
  24186. max: Vector3;
  24187. };
  24188. /**
  24189. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24190. * This means the mesh underlying bounding box and sphere are recomputed.
  24191. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24192. * @returns the current mesh
  24193. */
  24194. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24195. /** @hidden */
  24196. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24197. /** @hidden */
  24198. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24199. /** @hidden */
  24200. _updateBoundingInfo(): AbstractMesh;
  24201. /** @hidden */
  24202. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24203. /** @hidden */
  24204. protected _afterComputeWorldMatrix(): void;
  24205. /**
  24206. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24207. * A mesh is in the frustum if its bounding box intersects the frustum
  24208. * @param frustumPlanes defines the frustum to test
  24209. * @returns true if the mesh is in the frustum planes
  24210. */
  24211. isInFrustum(frustumPlanes: Plane[]): boolean;
  24212. /**
  24213. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24214. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24215. * @param frustumPlanes defines the frustum to test
  24216. * @returns true if the mesh is completely in the frustum planes
  24217. */
  24218. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24219. /**
  24220. * True if the mesh intersects another mesh or a SolidParticle object
  24221. * @param mesh defines a target mesh or SolidParticle to test
  24222. * @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)
  24223. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24224. * @returns true if there is an intersection
  24225. */
  24226. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24227. /**
  24228. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24229. * @param point defines the point to test
  24230. * @returns true if there is an intersection
  24231. */
  24232. intersectsPoint(point: Vector3): boolean;
  24233. /**
  24234. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24236. */
  24237. checkCollisions: boolean;
  24238. /**
  24239. * Gets Collider object used to compute collisions (not physics)
  24240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24241. */
  24242. readonly collider: Collider;
  24243. /**
  24244. * Move the mesh using collision engine
  24245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24246. * @param displacement defines the requested displacement vector
  24247. * @returns the current mesh
  24248. */
  24249. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24250. private _onCollisionPositionChange;
  24251. /** @hidden */
  24252. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24253. /** @hidden */
  24254. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24255. /** @hidden */
  24256. _checkCollision(collider: Collider): AbstractMesh;
  24257. /** @hidden */
  24258. _generatePointsArray(): boolean;
  24259. /**
  24260. * Checks if the passed Ray intersects with the mesh
  24261. * @param ray defines the ray to use
  24262. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24263. * @returns the picking info
  24264. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24265. */
  24266. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24267. /**
  24268. * Clones the current mesh
  24269. * @param name defines the mesh name
  24270. * @param newParent defines the new mesh parent
  24271. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24272. * @returns the new mesh
  24273. */
  24274. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24275. /**
  24276. * Disposes all the submeshes of the current meshnp
  24277. * @returns the current mesh
  24278. */
  24279. releaseSubMeshes(): AbstractMesh;
  24280. /**
  24281. * Releases resources associated with this abstract mesh.
  24282. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24283. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24284. */
  24285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24286. /**
  24287. * Adds the passed mesh as a child to the current mesh
  24288. * @param mesh defines the child mesh
  24289. * @returns the current mesh
  24290. */
  24291. addChild(mesh: AbstractMesh): AbstractMesh;
  24292. /**
  24293. * Removes the passed mesh from the current mesh children list
  24294. * @param mesh defines the child mesh
  24295. * @returns the current mesh
  24296. */
  24297. removeChild(mesh: AbstractMesh): AbstractMesh;
  24298. /** @hidden */
  24299. private _initFacetData;
  24300. /**
  24301. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24302. * This method can be called within the render loop.
  24303. * 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
  24304. * @returns the current mesh
  24305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24306. */
  24307. updateFacetData(): AbstractMesh;
  24308. /**
  24309. * Returns the facetLocalNormals array.
  24310. * The normals are expressed in the mesh local spac
  24311. * @returns an array of Vector3
  24312. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24313. */
  24314. getFacetLocalNormals(): Vector3[];
  24315. /**
  24316. * Returns the facetLocalPositions array.
  24317. * The facet positions are expressed in the mesh local space
  24318. * @returns an array of Vector3
  24319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24320. */
  24321. getFacetLocalPositions(): Vector3[];
  24322. /**
  24323. * Returns the facetLocalPartioning array
  24324. * @returns an array of array of numbers
  24325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24326. */
  24327. getFacetLocalPartitioning(): number[][];
  24328. /**
  24329. * Returns the i-th facet position in the world system.
  24330. * This method allocates a new Vector3 per call
  24331. * @param i defines the facet index
  24332. * @returns a new Vector3
  24333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24334. */
  24335. getFacetPosition(i: number): Vector3;
  24336. /**
  24337. * Sets the reference Vector3 with the i-th facet position in the world system
  24338. * @param i defines the facet index
  24339. * @param ref defines the target vector
  24340. * @returns the current mesh
  24341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24342. */
  24343. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24344. /**
  24345. * Returns the i-th facet normal in the world system.
  24346. * This method allocates a new Vector3 per call
  24347. * @param i defines the facet index
  24348. * @returns a new Vector3
  24349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24350. */
  24351. getFacetNormal(i: number): Vector3;
  24352. /**
  24353. * Sets the reference Vector3 with the i-th facet normal in the world system
  24354. * @param i defines the facet index
  24355. * @param ref defines the target vector
  24356. * @returns the current mesh
  24357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24358. */
  24359. getFacetNormalToRef(i: number, ref: Vector3): this;
  24360. /**
  24361. * 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)
  24362. * @param x defines x coordinate
  24363. * @param y defines y coordinate
  24364. * @param z defines z coordinate
  24365. * @returns the array of facet indexes
  24366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24367. */
  24368. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24369. /**
  24370. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24371. * @param projected sets as the (x,y,z) world projection on the facet
  24372. * @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
  24373. * @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
  24374. * @param x defines x coordinate
  24375. * @param y defines y coordinate
  24376. * @param z defines z coordinate
  24377. * @returns the face index if found (or null instead)
  24378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24379. */
  24380. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24381. /**
  24382. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24383. * @param projected sets as the (x,y,z) local projection on the facet
  24384. * @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
  24385. * @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
  24386. * @param x defines x coordinate
  24387. * @param y defines y coordinate
  24388. * @param z defines z coordinate
  24389. * @returns the face index if found (or null instead)
  24390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24391. */
  24392. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24393. /**
  24394. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24395. * @returns the parameters
  24396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24397. */
  24398. getFacetDataParameters(): any;
  24399. /**
  24400. * Disables the feature FacetData and frees the related memory
  24401. * @returns the current mesh
  24402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24403. */
  24404. disableFacetData(): AbstractMesh;
  24405. /**
  24406. * Updates the AbstractMesh indices array
  24407. * @param indices defines the data source
  24408. * @returns the current mesh
  24409. */
  24410. updateIndices(indices: IndicesArray): AbstractMesh;
  24411. /**
  24412. * Creates new normals data for the mesh
  24413. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24414. * @returns the current mesh
  24415. */
  24416. createNormals(updatable: boolean): AbstractMesh;
  24417. /**
  24418. * Align the mesh with a normal
  24419. * @param normal defines the normal to use
  24420. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24421. * @returns the current mesh
  24422. */
  24423. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24424. /** @hidden */
  24425. _checkOcclusionQuery(): boolean;
  24426. }
  24427. }
  24428. declare module "babylonjs/node" {
  24429. import { Scene } from "babylonjs/scene";
  24430. import { Nullable } from "babylonjs/types";
  24431. import { Matrix } from "babylonjs/Maths/math";
  24432. import { Engine } from "babylonjs/Engines/engine";
  24433. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24434. import { Observable } from "babylonjs/Misc/observable";
  24435. import { Animatable } from "babylonjs/Animations/animatable";
  24436. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24437. import { Animation } from "babylonjs/Animations/animation";
  24438. import { AnimationRange } from "babylonjs/Animations/animation";
  24439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24440. /**
  24441. * Defines how a node can be built from a string name.
  24442. */
  24443. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24444. /**
  24445. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24446. */
  24447. export class Node implements IBehaviorAware<Node> {
  24448. /** @hidden */
  24449. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animation").AnimationRange;
  24450. private static _NodeConstructors;
  24451. /**
  24452. * Add a new node constructor
  24453. * @param type defines the type name of the node to construct
  24454. * @param constructorFunc defines the constructor function
  24455. */
  24456. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24457. /**
  24458. * Returns a node constructor based on type name
  24459. * @param type defines the type name
  24460. * @param name defines the new node name
  24461. * @param scene defines the hosting scene
  24462. * @param options defines optional options to transmit to constructors
  24463. * @returns the new constructor or null
  24464. */
  24465. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24466. /**
  24467. * Gets or sets the name of the node
  24468. */
  24469. name: string;
  24470. /**
  24471. * Gets or sets the id of the node
  24472. */
  24473. id: string;
  24474. /**
  24475. * Gets or sets the unique id of the node
  24476. */
  24477. uniqueId: number;
  24478. /**
  24479. * Gets or sets a string used to store user defined state for the node
  24480. */
  24481. state: string;
  24482. /**
  24483. * Gets or sets an object used to store user defined information for the node
  24484. */
  24485. metadata: any;
  24486. /**
  24487. * For internal use only. Please do not use.
  24488. */
  24489. reservedDataStore: any;
  24490. /**
  24491. * Gets or sets a boolean used to define if the node must be serialized
  24492. */
  24493. doNotSerialize: boolean;
  24494. /** @hidden */
  24495. _isDisposed: boolean;
  24496. /**
  24497. * Gets a list of Animations associated with the node
  24498. */
  24499. animations: import("babylonjs/Animations/animation").Animation[];
  24500. protected _ranges: {
  24501. [name: string]: Nullable<AnimationRange>;
  24502. };
  24503. /**
  24504. * Callback raised when the node is ready to be used
  24505. */
  24506. onReady: (node: Node) => void;
  24507. private _isEnabled;
  24508. private _isParentEnabled;
  24509. private _isReady;
  24510. /** @hidden */
  24511. _currentRenderId: number;
  24512. private _parentRenderId;
  24513. protected _childRenderId: number;
  24514. /** @hidden */
  24515. _waitingParentId: Nullable<string>;
  24516. /** @hidden */
  24517. _scene: Scene;
  24518. /** @hidden */
  24519. _cache: any;
  24520. private _parentNode;
  24521. private _children;
  24522. /** @hidden */
  24523. _worldMatrix: Matrix;
  24524. /** @hidden */
  24525. _worldMatrixDeterminant: number;
  24526. /** @hidden */
  24527. private _sceneRootNodesIndex;
  24528. /**
  24529. * Gets a boolean indicating if the node has been disposed
  24530. * @returns true if the node was disposed
  24531. */
  24532. isDisposed(): boolean;
  24533. /**
  24534. * Gets or sets the parent of the node
  24535. */
  24536. parent: Nullable<Node>;
  24537. private addToSceneRootNodes;
  24538. private removeFromSceneRootNodes;
  24539. private _animationPropertiesOverride;
  24540. /**
  24541. * Gets or sets the animation properties override
  24542. */
  24543. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24544. /**
  24545. * Gets a string idenfifying the name of the class
  24546. * @returns "Node" string
  24547. */
  24548. getClassName(): string;
  24549. /** @hidden */
  24550. readonly _isNode: boolean;
  24551. /**
  24552. * An event triggered when the mesh is disposed
  24553. */
  24554. onDisposeObservable: Observable<Node>;
  24555. private _onDisposeObserver;
  24556. /**
  24557. * Sets a callback that will be raised when the node will be disposed
  24558. */
  24559. onDispose: () => void;
  24560. /**
  24561. * Creates a new Node
  24562. * @param name the name and id to be given to this node
  24563. * @param scene the scene this node will be added to
  24564. * @param addToRootNodes the node will be added to scene.rootNodes
  24565. */
  24566. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24567. /**
  24568. * Gets the scene of the node
  24569. * @returns a scene
  24570. */
  24571. getScene(): Scene;
  24572. /**
  24573. * Gets the engine of the node
  24574. * @returns a Engine
  24575. */
  24576. getEngine(): Engine;
  24577. private _behaviors;
  24578. /**
  24579. * Attach a behavior to the node
  24580. * @see http://doc.babylonjs.com/features/behaviour
  24581. * @param behavior defines the behavior to attach
  24582. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24583. * @returns the current Node
  24584. */
  24585. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24586. /**
  24587. * Remove an attached behavior
  24588. * @see http://doc.babylonjs.com/features/behaviour
  24589. * @param behavior defines the behavior to attach
  24590. * @returns the current Node
  24591. */
  24592. removeBehavior(behavior: Behavior<Node>): Node;
  24593. /**
  24594. * Gets the list of attached behaviors
  24595. * @see http://doc.babylonjs.com/features/behaviour
  24596. */
  24597. readonly behaviors: Behavior<Node>[];
  24598. /**
  24599. * Gets an attached behavior by name
  24600. * @param name defines the name of the behavior to look for
  24601. * @see http://doc.babylonjs.com/features/behaviour
  24602. * @returns null if behavior was not found else the requested behavior
  24603. */
  24604. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24605. /**
  24606. * Returns the latest update of the World matrix
  24607. * @returns a Matrix
  24608. */
  24609. getWorldMatrix(): Matrix;
  24610. /** @hidden */
  24611. _getWorldMatrixDeterminant(): number;
  24612. /**
  24613. * Returns directly the latest state of the mesh World matrix.
  24614. * A Matrix is returned.
  24615. */
  24616. readonly worldMatrixFromCache: Matrix;
  24617. /** @hidden */
  24618. _initCache(): void;
  24619. /** @hidden */
  24620. updateCache(force?: boolean): void;
  24621. /** @hidden */
  24622. _updateCache(ignoreParentClass?: boolean): void;
  24623. /** @hidden */
  24624. _isSynchronized(): boolean;
  24625. /** @hidden */
  24626. _markSyncedWithParent(): void;
  24627. /** @hidden */
  24628. isSynchronizedWithParent(): boolean;
  24629. /** @hidden */
  24630. isSynchronized(): boolean;
  24631. /**
  24632. * Is this node ready to be used/rendered
  24633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24634. * @return true if the node is ready
  24635. */
  24636. isReady(completeCheck?: boolean): boolean;
  24637. /**
  24638. * Is this node enabled?
  24639. * 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
  24640. * @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
  24641. * @return whether this node (and its parent) is enabled
  24642. */
  24643. isEnabled(checkAncestors?: boolean): boolean;
  24644. /** @hidden */
  24645. protected _syncParentEnabledState(): void;
  24646. /**
  24647. * Set the enabled state of this node
  24648. * @param value defines the new enabled state
  24649. */
  24650. setEnabled(value: boolean): void;
  24651. /**
  24652. * Is this node a descendant of the given node?
  24653. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24654. * @param ancestor defines the parent node to inspect
  24655. * @returns a boolean indicating if this node is a descendant of the given node
  24656. */
  24657. isDescendantOf(ancestor: Node): boolean;
  24658. /** @hidden */
  24659. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24660. /**
  24661. * Will return all nodes that have this node as ascendant
  24662. * @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
  24663. * @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
  24664. * @return all children nodes of all types
  24665. */
  24666. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24667. /**
  24668. * Get all child-meshes of this node
  24669. * @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
  24670. * @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
  24671. * @returns an array of AbstractMesh
  24672. */
  24673. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24674. /**
  24675. * Get all direct children of this node
  24676. * @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
  24677. * @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)
  24678. * @returns an array of Node
  24679. */
  24680. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24681. /** @hidden */
  24682. _setReady(state: boolean): void;
  24683. /**
  24684. * Get an animation by name
  24685. * @param name defines the name of the animation to look for
  24686. * @returns null if not found else the requested animation
  24687. */
  24688. getAnimationByName(name: string): Nullable<Animation>;
  24689. /**
  24690. * Creates an animation range for this node
  24691. * @param name defines the name of the range
  24692. * @param from defines the starting key
  24693. * @param to defines the end key
  24694. */
  24695. createAnimationRange(name: string, from: number, to: number): void;
  24696. /**
  24697. * Delete a specific animation range
  24698. * @param name defines the name of the range to delete
  24699. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24700. */
  24701. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24702. /**
  24703. * Get an animation range by name
  24704. * @param name defines the name of the animation range to look for
  24705. * @returns null if not found else the requested animation range
  24706. */
  24707. getAnimationRange(name: string): Nullable<AnimationRange>;
  24708. /**
  24709. * Will start the animation sequence
  24710. * @param name defines the range frames for animation sequence
  24711. * @param loop defines if the animation should loop (false by default)
  24712. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24713. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24714. * @returns the object created for this animation. If range does not exist, it will return null
  24715. */
  24716. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24717. /**
  24718. * Serialize animation ranges into a JSON compatible object
  24719. * @returns serialization object
  24720. */
  24721. serializeAnimationRanges(): any;
  24722. /**
  24723. * Computes the world matrix of the node
  24724. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24725. * @returns the world matrix
  24726. */
  24727. computeWorldMatrix(force?: boolean): Matrix;
  24728. /**
  24729. * Releases resources associated with this node.
  24730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24732. */
  24733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24734. /**
  24735. * Parse animation range data from a serialization object and store them into a given node
  24736. * @param node defines where to store the animation ranges
  24737. * @param parsedNode defines the serialization object to read data from
  24738. * @param scene defines the hosting scene
  24739. */
  24740. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24741. }
  24742. }
  24743. declare module "babylonjs/Animations/animation" {
  24744. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  24745. import { Path2, Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  24746. import { Nullable } from "babylonjs/types";
  24747. import { Scene } from "babylonjs/scene";
  24748. import { IAnimatable } from "babylonjs/Misc/tools";
  24749. import { Node } from "babylonjs/node";
  24750. import { Animatable } from "babylonjs/Animations/animatable";
  24751. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24752. /**
  24753. * Represents the range of an animation
  24754. */
  24755. export class AnimationRange {
  24756. /**The name of the animation range**/
  24757. name: string;
  24758. /**The starting frame of the animation */
  24759. from: number;
  24760. /**The ending frame of the animation*/
  24761. to: number;
  24762. /**
  24763. * Initializes the range of an animation
  24764. * @param name The name of the animation range
  24765. * @param from The starting frame of the animation
  24766. * @param to The ending frame of the animation
  24767. */
  24768. constructor(
  24769. /**The name of the animation range**/
  24770. name: string,
  24771. /**The starting frame of the animation */
  24772. from: number,
  24773. /**The ending frame of the animation*/
  24774. to: number);
  24775. /**
  24776. * Makes a copy of the animation range
  24777. * @returns A copy of the animation range
  24778. */
  24779. clone(): AnimationRange;
  24780. }
  24781. /**
  24782. * Composed of a frame, and an action function
  24783. */
  24784. export class AnimationEvent {
  24785. /** The frame for which the event is triggered **/
  24786. frame: number;
  24787. /** The event to perform when triggered **/
  24788. action: (currentFrame: number) => void;
  24789. /** Specifies if the event should be triggered only once**/
  24790. onlyOnce?: boolean | undefined;
  24791. /**
  24792. * Specifies if the animation event is done
  24793. */
  24794. isDone: boolean;
  24795. /**
  24796. * Initializes the animation event
  24797. * @param frame The frame for which the event is triggered
  24798. * @param action The event to perform when triggered
  24799. * @param onlyOnce Specifies if the event should be triggered only once
  24800. */
  24801. constructor(
  24802. /** The frame for which the event is triggered **/
  24803. frame: number,
  24804. /** The event to perform when triggered **/
  24805. action: (currentFrame: number) => void,
  24806. /** Specifies if the event should be triggered only once**/
  24807. onlyOnce?: boolean | undefined);
  24808. /** @hidden */
  24809. _clone(): AnimationEvent;
  24810. }
  24811. /**
  24812. * A cursor which tracks a point on a path
  24813. */
  24814. export class PathCursor {
  24815. private path;
  24816. /**
  24817. * Stores path cursor callbacks for when an onchange event is triggered
  24818. */
  24819. private _onchange;
  24820. /**
  24821. * The value of the path cursor
  24822. */
  24823. value: number;
  24824. /**
  24825. * The animation array of the path cursor
  24826. */
  24827. animations: Animation[];
  24828. /**
  24829. * Initializes the path cursor
  24830. * @param path The path to track
  24831. */
  24832. constructor(path: Path2);
  24833. /**
  24834. * Gets the cursor point on the path
  24835. * @returns A point on the path cursor at the cursor location
  24836. */
  24837. getPoint(): Vector3;
  24838. /**
  24839. * Moves the cursor ahead by the step amount
  24840. * @param step The amount to move the cursor forward
  24841. * @returns This path cursor
  24842. */
  24843. moveAhead(step?: number): PathCursor;
  24844. /**
  24845. * Moves the cursor behind by the step amount
  24846. * @param step The amount to move the cursor back
  24847. * @returns This path cursor
  24848. */
  24849. moveBack(step?: number): PathCursor;
  24850. /**
  24851. * Moves the cursor by the step amount
  24852. * If the step amount is greater than one, an exception is thrown
  24853. * @param step The amount to move the cursor
  24854. * @returns This path cursor
  24855. */
  24856. move(step: number): PathCursor;
  24857. /**
  24858. * Ensures that the value is limited between zero and one
  24859. * @returns This path cursor
  24860. */
  24861. private ensureLimits;
  24862. /**
  24863. * Runs onchange callbacks on change (used by the animation engine)
  24864. * @returns This path cursor
  24865. */
  24866. private raiseOnChange;
  24867. /**
  24868. * Executes a function on change
  24869. * @param f A path cursor onchange callback
  24870. * @returns This path cursor
  24871. */
  24872. onchange(f: (cursor: PathCursor) => void): PathCursor;
  24873. }
  24874. /**
  24875. * Defines an interface which represents an animation key frame
  24876. */
  24877. export interface IAnimationKey {
  24878. /**
  24879. * Frame of the key frame
  24880. */
  24881. frame: number;
  24882. /**
  24883. * Value at the specifies key frame
  24884. */
  24885. value: any;
  24886. /**
  24887. * The input tangent for the cubic hermite spline
  24888. */
  24889. inTangent?: any;
  24890. /**
  24891. * The output tangent for the cubic hermite spline
  24892. */
  24893. outTangent?: any;
  24894. /**
  24895. * The animation interpolation type
  24896. */
  24897. interpolation?: AnimationKeyInterpolation;
  24898. }
  24899. /**
  24900. * Enum for the animation key frame interpolation type
  24901. */
  24902. export enum AnimationKeyInterpolation {
  24903. /**
  24904. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  24905. */
  24906. STEP = 1
  24907. }
  24908. /**
  24909. * Class used to store any kind of animation
  24910. */
  24911. export class Animation {
  24912. /**Name of the animation */
  24913. name: string;
  24914. /**Property to animate */
  24915. targetProperty: string;
  24916. /**The frames per second of the animation */
  24917. framePerSecond: number;
  24918. /**The data type of the animation */
  24919. dataType: number;
  24920. /**The loop mode of the animation */
  24921. loopMode?: number | undefined;
  24922. /**Specifies if blending should be enabled */
  24923. enableBlending?: boolean | undefined;
  24924. /**
  24925. * Use matrix interpolation instead of using direct key value when animating matrices
  24926. */
  24927. static AllowMatricesInterpolation: boolean;
  24928. /**
  24929. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24930. */
  24931. static AllowMatrixDecomposeForInterpolation: boolean;
  24932. /**
  24933. * Stores the key frames of the animation
  24934. */
  24935. private _keys;
  24936. /**
  24937. * Stores the easing function of the animation
  24938. */
  24939. private _easingFunction;
  24940. /**
  24941. * @hidden Internal use only
  24942. */
  24943. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  24944. /**
  24945. * The set of event that will be linked to this animation
  24946. */
  24947. private _events;
  24948. /**
  24949. * Stores an array of target property paths
  24950. */
  24951. targetPropertyPath: string[];
  24952. /**
  24953. * Stores the blending speed of the animation
  24954. */
  24955. blendingSpeed: number;
  24956. /**
  24957. * Stores the animation ranges for the animation
  24958. */
  24959. private _ranges;
  24960. /**
  24961. * @hidden Internal use
  24962. */
  24963. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24964. /**
  24965. * Sets up an animation
  24966. * @param property The property to animate
  24967. * @param animationType The animation type to apply
  24968. * @param framePerSecond The frames per second of the animation
  24969. * @param easingFunction The easing function used in the animation
  24970. * @returns The created animation
  24971. */
  24972. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24973. /**
  24974. * Create and start an animation on a node
  24975. * @param name defines the name of the global animation that will be run on all nodes
  24976. * @param node defines the root node where the animation will take place
  24977. * @param targetProperty defines property to animate
  24978. * @param framePerSecond defines the number of frame per second yo use
  24979. * @param totalFrame defines the number of frames in total
  24980. * @param from defines the initial value
  24981. * @param to defines the final value
  24982. * @param loopMode defines which loop mode you want to use (off by default)
  24983. * @param easingFunction defines the easing function to use (linear by default)
  24984. * @param onAnimationEnd defines the callback to call when animation end
  24985. * @returns the animatable created for this animation
  24986. */
  24987. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24988. /**
  24989. * Create and start an animation on a node and its descendants
  24990. * @param name defines the name of the global animation that will be run on all nodes
  24991. * @param node defines the root node where the animation will take place
  24992. * @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
  24993. * @param targetProperty defines property to animate
  24994. * @param framePerSecond defines the number of frame per second to use
  24995. * @param totalFrame defines the number of frames in total
  24996. * @param from defines the initial value
  24997. * @param to defines the final value
  24998. * @param loopMode defines which loop mode you want to use (off by default)
  24999. * @param easingFunction defines the easing function to use (linear by default)
  25000. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25001. * @returns the list of animatables created for all nodes
  25002. * @example https://www.babylonjs-playground.com/#MH0VLI
  25003. */
  25004. 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[]>;
  25005. /**
  25006. * Creates a new animation, merges it with the existing animations and starts it
  25007. * @param name Name of the animation
  25008. * @param node Node which contains the scene that begins the animations
  25009. * @param targetProperty Specifies which property to animate
  25010. * @param framePerSecond The frames per second of the animation
  25011. * @param totalFrame The total number of frames
  25012. * @param from The frame at the beginning of the animation
  25013. * @param to The frame at the end of the animation
  25014. * @param loopMode Specifies the loop mode of the animation
  25015. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25016. * @param onAnimationEnd Callback to run once the animation is complete
  25017. * @returns Nullable animation
  25018. */
  25019. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25020. /**
  25021. * Transition property of an host to the target Value
  25022. * @param property The property to transition
  25023. * @param targetValue The target Value of the property
  25024. * @param host The object where the property to animate belongs
  25025. * @param scene Scene used to run the animation
  25026. * @param frameRate Framerate (in frame/s) to use
  25027. * @param transition The transition type we want to use
  25028. * @param duration The duration of the animation, in milliseconds
  25029. * @param onAnimationEnd Callback trigger at the end of the animation
  25030. * @returns Nullable animation
  25031. */
  25032. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25033. /**
  25034. * Return the array of runtime animations currently using this animation
  25035. */
  25036. readonly runtimeAnimations: RuntimeAnimation[];
  25037. /**
  25038. * Specifies if any of the runtime animations are currently running
  25039. */
  25040. readonly hasRunningRuntimeAnimations: boolean;
  25041. /**
  25042. * Initializes the animation
  25043. * @param name Name of the animation
  25044. * @param targetProperty Property to animate
  25045. * @param framePerSecond The frames per second of the animation
  25046. * @param dataType The data type of the animation
  25047. * @param loopMode The loop mode of the animation
  25048. * @param enableBlending Specifies if blending should be enabled
  25049. */
  25050. constructor(
  25051. /**Name of the animation */
  25052. name: string,
  25053. /**Property to animate */
  25054. targetProperty: string,
  25055. /**The frames per second of the animation */
  25056. framePerSecond: number,
  25057. /**The data type of the animation */
  25058. dataType: number,
  25059. /**The loop mode of the animation */
  25060. loopMode?: number | undefined,
  25061. /**Specifies if blending should be enabled */
  25062. enableBlending?: boolean | undefined);
  25063. /**
  25064. * Converts the animation to a string
  25065. * @param fullDetails support for multiple levels of logging within scene loading
  25066. * @returns String form of the animation
  25067. */
  25068. toString(fullDetails?: boolean): string;
  25069. /**
  25070. * Add an event to this animation
  25071. * @param event Event to add
  25072. */
  25073. addEvent(event: AnimationEvent): void;
  25074. /**
  25075. * Remove all events found at the given frame
  25076. * @param frame The frame to remove events from
  25077. */
  25078. removeEvents(frame: number): void;
  25079. /**
  25080. * Retrieves all the events from the animation
  25081. * @returns Events from the animation
  25082. */
  25083. getEvents(): AnimationEvent[];
  25084. /**
  25085. * Creates an animation range
  25086. * @param name Name of the animation range
  25087. * @param from Starting frame of the animation range
  25088. * @param to Ending frame of the animation
  25089. */
  25090. createRange(name: string, from: number, to: number): void;
  25091. /**
  25092. * Deletes an animation range by name
  25093. * @param name Name of the animation range to delete
  25094. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25095. */
  25096. deleteRange(name: string, deleteFrames?: boolean): void;
  25097. /**
  25098. * Gets the animation range by name, or null if not defined
  25099. * @param name Name of the animation range
  25100. * @returns Nullable animation range
  25101. */
  25102. getRange(name: string): Nullable<AnimationRange>;
  25103. /**
  25104. * Gets the key frames from the animation
  25105. * @returns The key frames of the animation
  25106. */
  25107. getKeys(): Array<IAnimationKey>;
  25108. /**
  25109. * Gets the highest frame rate of the animation
  25110. * @returns Highest frame rate of the animation
  25111. */
  25112. getHighestFrame(): number;
  25113. /**
  25114. * Gets the easing function of the animation
  25115. * @returns Easing function of the animation
  25116. */
  25117. getEasingFunction(): IEasingFunction;
  25118. /**
  25119. * Sets the easing function of the animation
  25120. * @param easingFunction A custom mathematical formula for animation
  25121. */
  25122. setEasingFunction(easingFunction: EasingFunction): void;
  25123. /**
  25124. * Interpolates a scalar linearly
  25125. * @param startValue Start value of the animation curve
  25126. * @param endValue End value of the animation curve
  25127. * @param gradient Scalar amount to interpolate
  25128. * @returns Interpolated scalar value
  25129. */
  25130. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25131. /**
  25132. * Interpolates a scalar cubically
  25133. * @param startValue Start value of the animation curve
  25134. * @param outTangent End tangent of the animation
  25135. * @param endValue End value of the animation curve
  25136. * @param inTangent Start tangent of the animation curve
  25137. * @param gradient Scalar amount to interpolate
  25138. * @returns Interpolated scalar value
  25139. */
  25140. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25141. /**
  25142. * Interpolates a quaternion using a spherical linear interpolation
  25143. * @param startValue Start value of the animation curve
  25144. * @param endValue End value of the animation curve
  25145. * @param gradient Scalar amount to interpolate
  25146. * @returns Interpolated quaternion value
  25147. */
  25148. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25149. /**
  25150. * Interpolates a quaternion cubically
  25151. * @param startValue Start value of the animation curve
  25152. * @param outTangent End tangent of the animation curve
  25153. * @param endValue End value of the animation curve
  25154. * @param inTangent Start tangent of the animation curve
  25155. * @param gradient Scalar amount to interpolate
  25156. * @returns Interpolated quaternion value
  25157. */
  25158. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25159. /**
  25160. * Interpolates a Vector3 linearl
  25161. * @param startValue Start value of the animation curve
  25162. * @param endValue End value of the animation curve
  25163. * @param gradient Scalar amount to interpolate
  25164. * @returns Interpolated scalar value
  25165. */
  25166. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25167. /**
  25168. * Interpolates a Vector3 cubically
  25169. * @param startValue Start value of the animation curve
  25170. * @param outTangent End tangent of the animation
  25171. * @param endValue End value of the animation curve
  25172. * @param inTangent Start tangent of the animation curve
  25173. * @param gradient Scalar amount to interpolate
  25174. * @returns InterpolatedVector3 value
  25175. */
  25176. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25177. /**
  25178. * Interpolates a Vector2 linearly
  25179. * @param startValue Start value of the animation curve
  25180. * @param endValue End value of the animation curve
  25181. * @param gradient Scalar amount to interpolate
  25182. * @returns Interpolated Vector2 value
  25183. */
  25184. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25185. /**
  25186. * Interpolates a Vector2 cubically
  25187. * @param startValue Start value of the animation curve
  25188. * @param outTangent End tangent of the animation
  25189. * @param endValue End value of the animation curve
  25190. * @param inTangent Start tangent of the animation curve
  25191. * @param gradient Scalar amount to interpolate
  25192. * @returns Interpolated Vector2 value
  25193. */
  25194. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25195. /**
  25196. * Interpolates a size linearly
  25197. * @param startValue Start value of the animation curve
  25198. * @param endValue End value of the animation curve
  25199. * @param gradient Scalar amount to interpolate
  25200. * @returns Interpolated Size value
  25201. */
  25202. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25203. /**
  25204. * Interpolates a Color3 linearly
  25205. * @param startValue Start value of the animation curve
  25206. * @param endValue End value of the animation curve
  25207. * @param gradient Scalar amount to interpolate
  25208. * @returns Interpolated Color3 value
  25209. */
  25210. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25211. /**
  25212. * @hidden Internal use only
  25213. */
  25214. _getKeyValue(value: any): any;
  25215. /**
  25216. * @hidden Internal use only
  25217. */
  25218. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25219. /**
  25220. * Defines the function to use to interpolate matrices
  25221. * @param startValue defines the start matrix
  25222. * @param endValue defines the end matrix
  25223. * @param gradient defines the gradient between both matrices
  25224. * @param result defines an optional target matrix where to store the interpolation
  25225. * @returns the interpolated matrix
  25226. */
  25227. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25228. /**
  25229. * Makes a copy of the animation
  25230. * @returns Cloned animation
  25231. */
  25232. clone(): Animation;
  25233. /**
  25234. * Sets the key frames of the animation
  25235. * @param values The animation key frames to set
  25236. */
  25237. setKeys(values: Array<IAnimationKey>): void;
  25238. /**
  25239. * Serializes the animation to an object
  25240. * @returns Serialized object
  25241. */
  25242. serialize(): any;
  25243. /**
  25244. * Float animation type
  25245. */
  25246. private static _ANIMATIONTYPE_FLOAT;
  25247. /**
  25248. * Vector3 animation type
  25249. */
  25250. private static _ANIMATIONTYPE_VECTOR3;
  25251. /**
  25252. * Quaternion animation type
  25253. */
  25254. private static _ANIMATIONTYPE_QUATERNION;
  25255. /**
  25256. * Matrix animation type
  25257. */
  25258. private static _ANIMATIONTYPE_MATRIX;
  25259. /**
  25260. * Color3 animation type
  25261. */
  25262. private static _ANIMATIONTYPE_COLOR3;
  25263. /**
  25264. * Vector2 animation type
  25265. */
  25266. private static _ANIMATIONTYPE_VECTOR2;
  25267. /**
  25268. * Size animation type
  25269. */
  25270. private static _ANIMATIONTYPE_SIZE;
  25271. /**
  25272. * Relative Loop Mode
  25273. */
  25274. private static _ANIMATIONLOOPMODE_RELATIVE;
  25275. /**
  25276. * Cycle Loop Mode
  25277. */
  25278. private static _ANIMATIONLOOPMODE_CYCLE;
  25279. /**
  25280. * Constant Loop Mode
  25281. */
  25282. private static _ANIMATIONLOOPMODE_CONSTANT;
  25283. /**
  25284. * Get the float animation type
  25285. */
  25286. static readonly ANIMATIONTYPE_FLOAT: number;
  25287. /**
  25288. * Get the Vector3 animation type
  25289. */
  25290. static readonly ANIMATIONTYPE_VECTOR3: number;
  25291. /**
  25292. * Get the Vector2 animation type
  25293. */
  25294. static readonly ANIMATIONTYPE_VECTOR2: number;
  25295. /**
  25296. * Get the Size animation type
  25297. */
  25298. static readonly ANIMATIONTYPE_SIZE: number;
  25299. /**
  25300. * Get the Quaternion animation type
  25301. */
  25302. static readonly ANIMATIONTYPE_QUATERNION: number;
  25303. /**
  25304. * Get the Matrix animation type
  25305. */
  25306. static readonly ANIMATIONTYPE_MATRIX: number;
  25307. /**
  25308. * Get the Color3 animation type
  25309. */
  25310. static readonly ANIMATIONTYPE_COLOR3: number;
  25311. /**
  25312. * Get the Relative Loop Mode
  25313. */
  25314. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25315. /**
  25316. * Get the Cycle Loop Mode
  25317. */
  25318. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25319. /**
  25320. * Get the Constant Loop Mode
  25321. */
  25322. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25323. /** @hidden */
  25324. static _UniversalLerp(left: any, right: any, amount: number): any;
  25325. /**
  25326. * Parses an animation object and creates an animation
  25327. * @param parsedAnimation Parsed animation object
  25328. * @returns Animation object
  25329. */
  25330. static Parse(parsedAnimation: any): Animation;
  25331. /**
  25332. * Appends the serialized animations from the source animations
  25333. * @param source Source containing the animations
  25334. * @param destination Target to store the animations
  25335. */
  25336. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25337. }
  25338. }
  25339. declare module "babylonjs/Materials/Textures/baseTexture" {
  25340. import { Observable } from "babylonjs/Misc/observable";
  25341. import { IAnimatable } from "babylonjs/Misc/tools";
  25342. import { Nullable } from "babylonjs/types";
  25343. import { Scene } from "babylonjs/scene";
  25344. import { Matrix, ISize } from "babylonjs/Maths/math";
  25345. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25347. /**
  25348. * Base class of all the textures in babylon.
  25349. * It groups all the common properties the materials, post process, lights... might need
  25350. * in order to make a correct use of the texture.
  25351. */
  25352. export class BaseTexture implements IAnimatable {
  25353. /**
  25354. * Default anisotropic filtering level for the application.
  25355. * It is set to 4 as a good tradeoff between perf and quality.
  25356. */
  25357. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25358. /**
  25359. * Gets or sets the unique id of the texture
  25360. */
  25361. uniqueId: number;
  25362. /**
  25363. * Define the name of the texture.
  25364. */
  25365. name: string;
  25366. /**
  25367. * Gets or sets an object used to store user defined information.
  25368. */
  25369. metadata: any;
  25370. /**
  25371. * For internal use only. Please do not use.
  25372. */
  25373. reservedDataStore: any;
  25374. private _hasAlpha;
  25375. /**
  25376. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25377. */
  25378. hasAlpha: boolean;
  25379. /**
  25380. * Defines if the alpha value should be determined via the rgb values.
  25381. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25382. */
  25383. getAlphaFromRGB: boolean;
  25384. /**
  25385. * Intensity or strength of the texture.
  25386. * It is commonly used by materials to fine tune the intensity of the texture
  25387. */
  25388. level: number;
  25389. /**
  25390. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25391. * This is part of the texture as textures usually maps to one uv set.
  25392. */
  25393. coordinatesIndex: number;
  25394. private _coordinatesMode;
  25395. /**
  25396. * How a texture is mapped.
  25397. *
  25398. * | Value | Type | Description |
  25399. * | ----- | ----------------------------------- | ----------- |
  25400. * | 0 | EXPLICIT_MODE | |
  25401. * | 1 | SPHERICAL_MODE | |
  25402. * | 2 | PLANAR_MODE | |
  25403. * | 3 | CUBIC_MODE | |
  25404. * | 4 | PROJECTION_MODE | |
  25405. * | 5 | SKYBOX_MODE | |
  25406. * | 6 | INVCUBIC_MODE | |
  25407. * | 7 | EQUIRECTANGULAR_MODE | |
  25408. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25409. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25410. */
  25411. coordinatesMode: number;
  25412. /**
  25413. * | Value | Type | Description |
  25414. * | ----- | ------------------ | ----------- |
  25415. * | 0 | CLAMP_ADDRESSMODE | |
  25416. * | 1 | WRAP_ADDRESSMODE | |
  25417. * | 2 | MIRROR_ADDRESSMODE | |
  25418. */
  25419. wrapU: number;
  25420. /**
  25421. * | Value | Type | Description |
  25422. * | ----- | ------------------ | ----------- |
  25423. * | 0 | CLAMP_ADDRESSMODE | |
  25424. * | 1 | WRAP_ADDRESSMODE | |
  25425. * | 2 | MIRROR_ADDRESSMODE | |
  25426. */
  25427. wrapV: number;
  25428. /**
  25429. * | Value | Type | Description |
  25430. * | ----- | ------------------ | ----------- |
  25431. * | 0 | CLAMP_ADDRESSMODE | |
  25432. * | 1 | WRAP_ADDRESSMODE | |
  25433. * | 2 | MIRROR_ADDRESSMODE | |
  25434. */
  25435. wrapR: number;
  25436. /**
  25437. * With compliant hardware and browser (supporting anisotropic filtering)
  25438. * this defines the level of anisotropic filtering in the texture.
  25439. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25440. */
  25441. anisotropicFilteringLevel: number;
  25442. /**
  25443. * Define if the texture is a cube texture or if false a 2d texture.
  25444. */
  25445. isCube: boolean;
  25446. /**
  25447. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25448. */
  25449. is3D: boolean;
  25450. /**
  25451. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25452. * HDR texture are usually stored in linear space.
  25453. * This only impacts the PBR and Background materials
  25454. */
  25455. gammaSpace: boolean;
  25456. /**
  25457. * Gets whether or not the texture contains RGBD data.
  25458. */
  25459. readonly isRGBD: boolean;
  25460. /**
  25461. * Is Z inverted in the texture (useful in a cube texture).
  25462. */
  25463. invertZ: boolean;
  25464. /**
  25465. * Are mip maps generated for this texture or not.
  25466. */
  25467. readonly noMipmap: boolean;
  25468. /**
  25469. * @hidden
  25470. */
  25471. lodLevelInAlpha: boolean;
  25472. /**
  25473. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25474. */
  25475. lodGenerationOffset: number;
  25476. /**
  25477. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25478. */
  25479. lodGenerationScale: number;
  25480. /**
  25481. * Define if the texture is a render target.
  25482. */
  25483. isRenderTarget: boolean;
  25484. /**
  25485. * Define the unique id of the texture in the scene.
  25486. */
  25487. readonly uid: string;
  25488. /**
  25489. * Return a string representation of the texture.
  25490. * @returns the texture as a string
  25491. */
  25492. toString(): string;
  25493. /**
  25494. * Get the class name of the texture.
  25495. * @returns "BaseTexture"
  25496. */
  25497. getClassName(): string;
  25498. /**
  25499. * Define the list of animation attached to the texture.
  25500. */
  25501. animations: import("babylonjs/Animations/animation").Animation[];
  25502. /**
  25503. * An event triggered when the texture is disposed.
  25504. */
  25505. onDisposeObservable: Observable<BaseTexture>;
  25506. private _onDisposeObserver;
  25507. /**
  25508. * Callback triggered when the texture has been disposed.
  25509. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25510. */
  25511. onDispose: () => void;
  25512. /**
  25513. * Define the current state of the loading sequence when in delayed load mode.
  25514. */
  25515. delayLoadState: number;
  25516. private _scene;
  25517. /** @hidden */
  25518. _texture: Nullable<InternalTexture>;
  25519. private _uid;
  25520. /**
  25521. * Define if the texture is preventinga material to render or not.
  25522. * If not and the texture is not ready, the engine will use a default black texture instead.
  25523. */
  25524. readonly isBlocking: boolean;
  25525. /**
  25526. * Instantiates a new BaseTexture.
  25527. * Base class of all the textures in babylon.
  25528. * It groups all the common properties the materials, post process, lights... might need
  25529. * in order to make a correct use of the texture.
  25530. * @param scene Define the scene the texture blongs to
  25531. */
  25532. constructor(scene: Nullable<Scene>);
  25533. /**
  25534. * Get the scene the texture belongs to.
  25535. * @returns the scene or null if undefined
  25536. */
  25537. getScene(): Nullable<Scene>;
  25538. /**
  25539. * Get the texture transform matrix used to offset tile the texture for istance.
  25540. * @returns the transformation matrix
  25541. */
  25542. getTextureMatrix(): Matrix;
  25543. /**
  25544. * Get the texture reflection matrix used to rotate/transform the reflection.
  25545. * @returns the reflection matrix
  25546. */
  25547. getReflectionTextureMatrix(): Matrix;
  25548. /**
  25549. * Get the underlying lower level texture from Babylon.
  25550. * @returns the insternal texture
  25551. */
  25552. getInternalTexture(): Nullable<InternalTexture>;
  25553. /**
  25554. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25555. * @returns true if ready or not blocking
  25556. */
  25557. isReadyOrNotBlocking(): boolean;
  25558. /**
  25559. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25560. * @returns true if fully ready
  25561. */
  25562. isReady(): boolean;
  25563. private _cachedSize;
  25564. /**
  25565. * Get the size of the texture.
  25566. * @returns the texture size.
  25567. */
  25568. getSize(): ISize;
  25569. /**
  25570. * Get the base size of the texture.
  25571. * It can be different from the size if the texture has been resized for POT for instance
  25572. * @returns the base size
  25573. */
  25574. getBaseSize(): ISize;
  25575. /**
  25576. * Update the sampling mode of the texture.
  25577. * Default is Trilinear mode.
  25578. *
  25579. * | Value | Type | Description |
  25580. * | ----- | ------------------ | ----------- |
  25581. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25582. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25583. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25584. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25585. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25586. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25587. * | 7 | NEAREST_LINEAR | |
  25588. * | 8 | NEAREST_NEAREST | |
  25589. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25590. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25591. * | 11 | LINEAR_LINEAR | |
  25592. * | 12 | LINEAR_NEAREST | |
  25593. *
  25594. * > _mag_: magnification filter (close to the viewer)
  25595. * > _min_: minification filter (far from the viewer)
  25596. * > _mip_: filter used between mip map levels
  25597. *@param samplingMode Define the new sampling mode of the texture
  25598. */
  25599. updateSamplingMode(samplingMode: number): void;
  25600. /**
  25601. * Scales the texture if is `canRescale()`
  25602. * @param ratio the resize factor we want to use to rescale
  25603. */
  25604. scale(ratio: number): void;
  25605. /**
  25606. * Get if the texture can rescale.
  25607. */
  25608. readonly canRescale: boolean;
  25609. /** @hidden */
  25610. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25611. /** @hidden */
  25612. _rebuild(): void;
  25613. /**
  25614. * Triggers the load sequence in delayed load mode.
  25615. */
  25616. delayLoad(): void;
  25617. /**
  25618. * Clones the texture.
  25619. * @returns the cloned texture
  25620. */
  25621. clone(): Nullable<BaseTexture>;
  25622. /**
  25623. * Get the texture underlying type (INT, FLOAT...)
  25624. */
  25625. readonly textureType: number;
  25626. /**
  25627. * Get the texture underlying format (RGB, RGBA...)
  25628. */
  25629. readonly textureFormat: number;
  25630. /**
  25631. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25632. * This will returns an RGBA array buffer containing either in values (0-255) or
  25633. * float values (0-1) depending of the underlying buffer type.
  25634. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25635. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25636. * @param buffer defines a user defined buffer to fill with data (can be null)
  25637. * @returns The Array buffer containing the pixels data.
  25638. */
  25639. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25640. /**
  25641. * Release and destroy the underlying lower level texture aka internalTexture.
  25642. */
  25643. releaseInternalTexture(): void;
  25644. /**
  25645. * Get the polynomial representation of the texture data.
  25646. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25647. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25648. */
  25649. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25650. /** @hidden */
  25651. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25652. /** @hidden */
  25653. readonly _lodTextureMid: Nullable<BaseTexture>;
  25654. /** @hidden */
  25655. readonly _lodTextureLow: Nullable<BaseTexture>;
  25656. /**
  25657. * Dispose the texture and release its associated resources.
  25658. */
  25659. dispose(): void;
  25660. /**
  25661. * Serialize the texture into a JSON representation that can be parsed later on.
  25662. * @returns the JSON representation of the texture
  25663. */
  25664. serialize(): any;
  25665. /**
  25666. * Helper function to be called back once a list of texture contains only ready textures.
  25667. * @param textures Define the list of textures to wait for
  25668. * @param callback Define the callback triggered once the entire list will be ready
  25669. */
  25670. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25671. }
  25672. }
  25673. declare module "babylonjs/Materials/uniformBuffer" {
  25674. import { Nullable, FloatArray } from "babylonjs/types";
  25675. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25676. import { Engine } from "babylonjs/Engines/engine";
  25677. import { Effect } from "babylonjs/Materials/effect";
  25678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25679. /**
  25680. * Uniform buffer objects.
  25681. *
  25682. * Handles blocks of uniform on the GPU.
  25683. *
  25684. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25685. *
  25686. * For more information, please refer to :
  25687. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25688. */
  25689. export class UniformBuffer {
  25690. private _engine;
  25691. private _buffer;
  25692. private _data;
  25693. private _bufferData;
  25694. private _dynamic?;
  25695. private _uniformLocations;
  25696. private _uniformSizes;
  25697. private _uniformLocationPointer;
  25698. private _needSync;
  25699. private _noUBO;
  25700. private _currentEffect;
  25701. private static _MAX_UNIFORM_SIZE;
  25702. private static _tempBuffer;
  25703. /**
  25704. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25705. * This is dynamic to allow compat with webgl 1 and 2.
  25706. * You will need to pass the name of the uniform as well as the value.
  25707. */
  25708. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25709. /**
  25710. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25711. * This is dynamic to allow compat with webgl 1 and 2.
  25712. * You will need to pass the name of the uniform as well as the value.
  25713. */
  25714. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25715. /**
  25716. * Lambda to Update a single float in a uniform buffer.
  25717. * This is dynamic to allow compat with webgl 1 and 2.
  25718. * You will need to pass the name of the uniform as well as the value.
  25719. */
  25720. updateFloat: (name: string, x: number) => void;
  25721. /**
  25722. * Lambda to Update a vec2 of float in a uniform buffer.
  25723. * This is dynamic to allow compat with webgl 1 and 2.
  25724. * You will need to pass the name of the uniform as well as the value.
  25725. */
  25726. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25727. /**
  25728. * Lambda to Update a vec3 of float in a uniform buffer.
  25729. * This is dynamic to allow compat with webgl 1 and 2.
  25730. * You will need to pass the name of the uniform as well as the value.
  25731. */
  25732. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25733. /**
  25734. * Lambda to Update a vec4 of float in a uniform buffer.
  25735. * This is dynamic to allow compat with webgl 1 and 2.
  25736. * You will need to pass the name of the uniform as well as the value.
  25737. */
  25738. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25739. /**
  25740. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25741. * This is dynamic to allow compat with webgl 1 and 2.
  25742. * You will need to pass the name of the uniform as well as the value.
  25743. */
  25744. updateMatrix: (name: string, mat: Matrix) => void;
  25745. /**
  25746. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25747. * This is dynamic to allow compat with webgl 1 and 2.
  25748. * You will need to pass the name of the uniform as well as the value.
  25749. */
  25750. updateVector3: (name: string, vector: Vector3) => void;
  25751. /**
  25752. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25753. * This is dynamic to allow compat with webgl 1 and 2.
  25754. * You will need to pass the name of the uniform as well as the value.
  25755. */
  25756. updateVector4: (name: string, vector: Vector4) => void;
  25757. /**
  25758. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25759. * This is dynamic to allow compat with webgl 1 and 2.
  25760. * You will need to pass the name of the uniform as well as the value.
  25761. */
  25762. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25763. /**
  25764. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25765. * This is dynamic to allow compat with webgl 1 and 2.
  25766. * You will need to pass the name of the uniform as well as the value.
  25767. */
  25768. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25769. /**
  25770. * Instantiates a new Uniform buffer objects.
  25771. *
  25772. * Handles blocks of uniform on the GPU.
  25773. *
  25774. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25775. *
  25776. * For more information, please refer to :
  25777. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25778. * @param engine Define the engine the buffer is associated with
  25779. * @param data Define the data contained in the buffer
  25780. * @param dynamic Define if the buffer is updatable
  25781. */
  25782. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25783. /**
  25784. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25785. * or just falling back on setUniformXXX calls.
  25786. */
  25787. readonly useUbo: boolean;
  25788. /**
  25789. * Indicates if the WebGL underlying uniform buffer is in sync
  25790. * with the javascript cache data.
  25791. */
  25792. readonly isSync: boolean;
  25793. /**
  25794. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25795. * Also, a dynamic UniformBuffer will disable cache verification and always
  25796. * update the underlying WebGL uniform buffer to the GPU.
  25797. * @returns if Dynamic, otherwise false
  25798. */
  25799. isDynamic(): boolean;
  25800. /**
  25801. * The data cache on JS side.
  25802. * @returns the underlying data as a float array
  25803. */
  25804. getData(): Float32Array;
  25805. /**
  25806. * The underlying WebGL Uniform buffer.
  25807. * @returns the webgl buffer
  25808. */
  25809. getBuffer(): Nullable<WebGLBuffer>;
  25810. /**
  25811. * std140 layout specifies how to align data within an UBO structure.
  25812. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25813. * for specs.
  25814. */
  25815. private _fillAlignment;
  25816. /**
  25817. * Adds an uniform in the buffer.
  25818. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25819. * for the layout to be correct !
  25820. * @param name Name of the uniform, as used in the uniform block in the shader.
  25821. * @param size Data size, or data directly.
  25822. */
  25823. addUniform(name: string, size: number | number[]): void;
  25824. /**
  25825. * Adds a Matrix 4x4 to the uniform buffer.
  25826. * @param name Name of the uniform, as used in the uniform block in the shader.
  25827. * @param mat A 4x4 matrix.
  25828. */
  25829. addMatrix(name: string, mat: Matrix): void;
  25830. /**
  25831. * Adds a vec2 to the uniform buffer.
  25832. * @param name Name of the uniform, as used in the uniform block in the shader.
  25833. * @param x Define the x component value of the vec2
  25834. * @param y Define the y component value of the vec2
  25835. */
  25836. addFloat2(name: string, x: number, y: number): void;
  25837. /**
  25838. * Adds a vec3 to the uniform buffer.
  25839. * @param name Name of the uniform, as used in the uniform block in the shader.
  25840. * @param x Define the x component value of the vec3
  25841. * @param y Define the y component value of the vec3
  25842. * @param z Define the z component value of the vec3
  25843. */
  25844. addFloat3(name: string, x: number, y: number, z: number): void;
  25845. /**
  25846. * Adds a vec3 to the uniform buffer.
  25847. * @param name Name of the uniform, as used in the uniform block in the shader.
  25848. * @param color Define the vec3 from a Color
  25849. */
  25850. addColor3(name: string, color: Color3): void;
  25851. /**
  25852. * Adds a vec4 to the uniform buffer.
  25853. * @param name Name of the uniform, as used in the uniform block in the shader.
  25854. * @param color Define the rgb components from a Color
  25855. * @param alpha Define the a component of the vec4
  25856. */
  25857. addColor4(name: string, color: Color3, alpha: number): void;
  25858. /**
  25859. * Adds a vec3 to the uniform buffer.
  25860. * @param name Name of the uniform, as used in the uniform block in the shader.
  25861. * @param vector Define the vec3 components from a Vector
  25862. */
  25863. addVector3(name: string, vector: Vector3): void;
  25864. /**
  25865. * Adds a Matrix 3x3 to the uniform buffer.
  25866. * @param name Name of the uniform, as used in the uniform block in the shader.
  25867. */
  25868. addMatrix3x3(name: string): void;
  25869. /**
  25870. * Adds a Matrix 2x2 to the uniform buffer.
  25871. * @param name Name of the uniform, as used in the uniform block in the shader.
  25872. */
  25873. addMatrix2x2(name: string): void;
  25874. /**
  25875. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25876. */
  25877. create(): void;
  25878. /** @hidden */
  25879. _rebuild(): void;
  25880. /**
  25881. * Updates the WebGL Uniform Buffer on the GPU.
  25882. * If the `dynamic` flag is set to true, no cache comparison is done.
  25883. * Otherwise, the buffer will be updated only if the cache differs.
  25884. */
  25885. update(): void;
  25886. /**
  25887. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25888. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25889. * @param data Define the flattened data
  25890. * @param size Define the size of the data.
  25891. */
  25892. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25893. private _updateMatrix3x3ForUniform;
  25894. private _updateMatrix3x3ForEffect;
  25895. private _updateMatrix2x2ForEffect;
  25896. private _updateMatrix2x2ForUniform;
  25897. private _updateFloatForEffect;
  25898. private _updateFloatForUniform;
  25899. private _updateFloat2ForEffect;
  25900. private _updateFloat2ForUniform;
  25901. private _updateFloat3ForEffect;
  25902. private _updateFloat3ForUniform;
  25903. private _updateFloat4ForEffect;
  25904. private _updateFloat4ForUniform;
  25905. private _updateMatrixForEffect;
  25906. private _updateMatrixForUniform;
  25907. private _updateVector3ForEffect;
  25908. private _updateVector3ForUniform;
  25909. private _updateVector4ForEffect;
  25910. private _updateVector4ForUniform;
  25911. private _updateColor3ForEffect;
  25912. private _updateColor3ForUniform;
  25913. private _updateColor4ForEffect;
  25914. private _updateColor4ForUniform;
  25915. /**
  25916. * Sets a sampler uniform on the effect.
  25917. * @param name Define the name of the sampler.
  25918. * @param texture Define the texture to set in the sampler
  25919. */
  25920. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25921. /**
  25922. * Directly updates the value of the uniform in the cache AND on the GPU.
  25923. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25924. * @param data Define the flattened data
  25925. */
  25926. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25927. /**
  25928. * Binds this uniform buffer to an effect.
  25929. * @param effect Define the effect to bind the buffer to
  25930. * @param name Name of the uniform block in the shader.
  25931. */
  25932. bindToEffect(effect: Effect, name: string): void;
  25933. /**
  25934. * Disposes the uniform buffer.
  25935. */
  25936. dispose(): void;
  25937. }
  25938. }
  25939. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  25940. import { Nullable } from "babylonjs/types";
  25941. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25942. /**
  25943. * This represents the required contract to create a new type of texture loader.
  25944. */
  25945. export interface IInternalTextureLoader {
  25946. /**
  25947. * Defines wether the loader supports cascade loading the different faces.
  25948. */
  25949. supportCascades: boolean;
  25950. /**
  25951. * This returns if the loader support the current file information.
  25952. * @param extension defines the file extension of the file being loaded
  25953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25954. * @param fallback defines the fallback internal texture if any
  25955. * @param isBase64 defines whether the texture is encoded as a base64
  25956. * @param isBuffer defines whether the texture data are stored as a buffer
  25957. * @returns true if the loader can load the specified file
  25958. */
  25959. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25960. /**
  25961. * Transform the url before loading if required.
  25962. * @param rootUrl the url of the texture
  25963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25964. * @returns the transformed texture
  25965. */
  25966. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25967. /**
  25968. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25969. * @param rootUrl the url of the texture
  25970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25971. * @returns the fallback texture
  25972. */
  25973. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25974. /**
  25975. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25976. * @param data contains the texture data
  25977. * @param texture defines the BabylonJS internal texture
  25978. * @param createPolynomials will be true if polynomials have been requested
  25979. * @param onLoad defines the callback to trigger once the texture is ready
  25980. * @param onError defines the callback to trigger in case of error
  25981. */
  25982. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25983. /**
  25984. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25985. * @param data contains the texture data
  25986. * @param texture defines the BabylonJS internal texture
  25987. * @param callback defines the method to call once ready to upload
  25988. */
  25989. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25990. }
  25991. }
  25992. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  25993. import { Scene } from "babylonjs/scene";
  25994. import { Engine } from "babylonjs/Engines/engine";
  25995. import { Texture } from "babylonjs/Materials/Textures/texture";
  25996. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25997. /**
  25998. * Creation options of the multi render target texture.
  25999. */
  26000. export interface IMultiRenderTargetOptions {
  26001. /**
  26002. * Define if the texture needs to create mip maps after render.
  26003. */
  26004. generateMipMaps?: boolean;
  26005. /**
  26006. * Define the types of all the draw buffers we want to create
  26007. */
  26008. types?: number[];
  26009. /**
  26010. * Define the sampling modes of all the draw buffers we want to create
  26011. */
  26012. samplingModes?: number[];
  26013. /**
  26014. * Define if a depth buffer is required
  26015. */
  26016. generateDepthBuffer?: boolean;
  26017. /**
  26018. * Define if a stencil buffer is required
  26019. */
  26020. generateStencilBuffer?: boolean;
  26021. /**
  26022. * Define if a depth texture is required instead of a depth buffer
  26023. */
  26024. generateDepthTexture?: boolean;
  26025. /**
  26026. * Define the number of desired draw buffers
  26027. */
  26028. textureCount?: number;
  26029. /**
  26030. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26031. */
  26032. doNotChangeAspectRatio?: boolean;
  26033. /**
  26034. * Define the default type of the buffers we are creating
  26035. */
  26036. defaultType?: number;
  26037. }
  26038. /**
  26039. * A multi render target, like a render target provides the ability to render to a texture.
  26040. * Unlike the render target, it can render to several draw buffers in one draw.
  26041. * This is specially interesting in deferred rendering or for any effects requiring more than
  26042. * just one color from a single pass.
  26043. */
  26044. export class MultiRenderTarget extends RenderTargetTexture {
  26045. private _internalTextures;
  26046. private _textures;
  26047. private _multiRenderTargetOptions;
  26048. /**
  26049. * Get if draw buffers are currently supported by the used hardware and browser.
  26050. */
  26051. readonly isSupported: boolean;
  26052. /**
  26053. * Get the list of textures generated by the multi render target.
  26054. */
  26055. readonly textures: Texture[];
  26056. /**
  26057. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26058. */
  26059. readonly depthTexture: Texture;
  26060. /**
  26061. * Set the wrapping mode on U of all the textures we are rendering to.
  26062. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26063. */
  26064. wrapU: number;
  26065. /**
  26066. * Set the wrapping mode on V of all the textures we are rendering to.
  26067. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26068. */
  26069. wrapV: number;
  26070. /**
  26071. * Instantiate a new multi render target texture.
  26072. * A multi render target, like a render target provides the ability to render to a texture.
  26073. * Unlike the render target, it can render to several draw buffers in one draw.
  26074. * This is specially interesting in deferred rendering or for any effects requiring more than
  26075. * just one color from a single pass.
  26076. * @param name Define the name of the texture
  26077. * @param size Define the size of the buffers to render to
  26078. * @param count Define the number of target we are rendering into
  26079. * @param scene Define the scene the texture belongs to
  26080. * @param options Define the options used to create the multi render target
  26081. */
  26082. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26083. /** @hidden */
  26084. _rebuild(): void;
  26085. private _createInternalTextures;
  26086. private _createTextures;
  26087. /**
  26088. * Define the number of samples used if MSAA is enabled.
  26089. */
  26090. samples: number;
  26091. /**
  26092. * Resize all the textures in the multi render target.
  26093. * Be carrefull as it will recreate all the data in the new texture.
  26094. * @param size Define the new size
  26095. */
  26096. resize(size: any): void;
  26097. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26098. /**
  26099. * Dispose the render targets and their associated resources
  26100. */
  26101. dispose(): void;
  26102. /**
  26103. * Release all the underlying texture used as draw buffers.
  26104. */
  26105. releaseInternalTextures(): void;
  26106. }
  26107. }
  26108. declare module "babylonjs/Audio/analyser" {
  26109. import { Scene } from "babylonjs/scene";
  26110. /**
  26111. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26113. */
  26114. export class Analyser {
  26115. /**
  26116. * Gets or sets the smoothing
  26117. * @ignorenaming
  26118. */
  26119. SMOOTHING: number;
  26120. /**
  26121. * Gets or sets the FFT table size
  26122. * @ignorenaming
  26123. */
  26124. FFT_SIZE: number;
  26125. /**
  26126. * Gets or sets the bar graph amplitude
  26127. * @ignorenaming
  26128. */
  26129. BARGRAPHAMPLITUDE: number;
  26130. /**
  26131. * Gets or sets the position of the debug canvas
  26132. * @ignorenaming
  26133. */
  26134. DEBUGCANVASPOS: {
  26135. x: number;
  26136. y: number;
  26137. };
  26138. /**
  26139. * Gets or sets the debug canvas size
  26140. * @ignorenaming
  26141. */
  26142. DEBUGCANVASSIZE: {
  26143. width: number;
  26144. height: number;
  26145. };
  26146. private _byteFreqs;
  26147. private _byteTime;
  26148. private _floatFreqs;
  26149. private _webAudioAnalyser;
  26150. private _debugCanvas;
  26151. private _debugCanvasContext;
  26152. private _scene;
  26153. private _registerFunc;
  26154. private _audioEngine;
  26155. /**
  26156. * Creates a new analyser
  26157. * @param scene defines hosting scene
  26158. */
  26159. constructor(scene: Scene);
  26160. /**
  26161. * Get the number of data values you will have to play with for the visualization
  26162. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26163. * @returns a number
  26164. */
  26165. getFrequencyBinCount(): number;
  26166. /**
  26167. * Gets the current frequency data as a byte array
  26168. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26169. * @returns a Uint8Array
  26170. */
  26171. getByteFrequencyData(): Uint8Array;
  26172. /**
  26173. * Gets the current waveform as a byte array
  26174. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26175. * @returns a Uint8Array
  26176. */
  26177. getByteTimeDomainData(): Uint8Array;
  26178. /**
  26179. * Gets the current frequency data as a float array
  26180. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26181. * @returns a Float32Array
  26182. */
  26183. getFloatFrequencyData(): Float32Array;
  26184. /**
  26185. * Renders the debug canvas
  26186. */
  26187. drawDebugCanvas(): void;
  26188. /**
  26189. * Stops rendering the debug canvas and removes it
  26190. */
  26191. stopDebugCanvas(): void;
  26192. /**
  26193. * Connects two audio nodes
  26194. * @param inputAudioNode defines first node to connect
  26195. * @param outputAudioNode defines second node to connect
  26196. */
  26197. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26198. /**
  26199. * Releases all associated resources
  26200. */
  26201. dispose(): void;
  26202. }
  26203. }
  26204. declare module "babylonjs/Audio/audioEngine" {
  26205. import { IDisposable } from "babylonjs/scene";
  26206. import { Analyser } from "babylonjs/Audio/analyser";
  26207. import { Nullable } from "babylonjs/types";
  26208. import { Observable } from "babylonjs/Misc/observable";
  26209. /**
  26210. * This represents an audio engine and it is responsible
  26211. * to play, synchronize and analyse sounds throughout the application.
  26212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26213. */
  26214. export interface IAudioEngine extends IDisposable {
  26215. /**
  26216. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26217. */
  26218. readonly canUseWebAudio: boolean;
  26219. /**
  26220. * Gets the current AudioContext if available.
  26221. */
  26222. readonly audioContext: Nullable<AudioContext>;
  26223. /**
  26224. * The master gain node defines the global audio volume of your audio engine.
  26225. */
  26226. readonly masterGain: GainNode;
  26227. /**
  26228. * Gets whether or not mp3 are supported by your browser.
  26229. */
  26230. readonly isMP3supported: boolean;
  26231. /**
  26232. * Gets whether or not ogg are supported by your browser.
  26233. */
  26234. readonly isOGGsupported: boolean;
  26235. /**
  26236. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26237. * @ignoreNaming
  26238. */
  26239. WarnedWebAudioUnsupported: boolean;
  26240. /**
  26241. * Defines if the audio engine relies on a custom unlocked button.
  26242. * In this case, the embedded button will not be displayed.
  26243. */
  26244. useCustomUnlockedButton: boolean;
  26245. /**
  26246. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26247. */
  26248. readonly unlocked: boolean;
  26249. /**
  26250. * Event raised when audio has been unlocked on the browser.
  26251. */
  26252. onAudioUnlockedObservable: Observable<AudioEngine>;
  26253. /**
  26254. * Event raised when audio has been locked on the browser.
  26255. */
  26256. onAudioLockedObservable: Observable<AudioEngine>;
  26257. /**
  26258. * Flags the audio engine in Locked state.
  26259. * This happens due to new browser policies preventing audio to autoplay.
  26260. */
  26261. lock(): void;
  26262. /**
  26263. * Unlocks the audio engine once a user action has been done on the dom.
  26264. * This is helpful to resume play once browser policies have been satisfied.
  26265. */
  26266. unlock(): void;
  26267. }
  26268. /**
  26269. * This represents the default audio engine used in babylon.
  26270. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26272. */
  26273. export class AudioEngine implements IAudioEngine {
  26274. private _audioContext;
  26275. private _audioContextInitialized;
  26276. private _muteButton;
  26277. private _hostElement;
  26278. /**
  26279. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26280. */
  26281. canUseWebAudio: boolean;
  26282. /**
  26283. * The master gain node defines the global audio volume of your audio engine.
  26284. */
  26285. masterGain: GainNode;
  26286. /**
  26287. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26288. * @ignoreNaming
  26289. */
  26290. WarnedWebAudioUnsupported: boolean;
  26291. /**
  26292. * Gets whether or not mp3 are supported by your browser.
  26293. */
  26294. isMP3supported: boolean;
  26295. /**
  26296. * Gets whether or not ogg are supported by your browser.
  26297. */
  26298. isOGGsupported: boolean;
  26299. /**
  26300. * Gets whether audio has been unlocked on the device.
  26301. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26302. * a user interaction has happened.
  26303. */
  26304. unlocked: boolean;
  26305. /**
  26306. * Defines if the audio engine relies on a custom unlocked button.
  26307. * In this case, the embedded button will not be displayed.
  26308. */
  26309. useCustomUnlockedButton: boolean;
  26310. /**
  26311. * Event raised when audio has been unlocked on the browser.
  26312. */
  26313. onAudioUnlockedObservable: Observable<AudioEngine>;
  26314. /**
  26315. * Event raised when audio has been locked on the browser.
  26316. */
  26317. onAudioLockedObservable: Observable<AudioEngine>;
  26318. /**
  26319. * Gets the current AudioContext if available.
  26320. */
  26321. readonly audioContext: Nullable<AudioContext>;
  26322. private _connectedAnalyser;
  26323. /**
  26324. * Instantiates a new audio engine.
  26325. *
  26326. * There should be only one per page as some browsers restrict the number
  26327. * of audio contexts you can create.
  26328. * @param hostElement defines the host element where to display the mute icon if necessary
  26329. */
  26330. constructor(hostElement?: Nullable<HTMLElement>);
  26331. /**
  26332. * Flags the audio engine in Locked state.
  26333. * This happens due to new browser policies preventing audio to autoplay.
  26334. */
  26335. lock(): void;
  26336. /**
  26337. * Unlocks the audio engine once a user action has been done on the dom.
  26338. * This is helpful to resume play once browser policies have been satisfied.
  26339. */
  26340. unlock(): void;
  26341. private _resumeAudioContext;
  26342. private _initializeAudioContext;
  26343. private _tryToRun;
  26344. private _triggerRunningState;
  26345. private _triggerSuspendedState;
  26346. private _displayMuteButton;
  26347. private _moveButtonToTopLeft;
  26348. private _onResize;
  26349. private _hideMuteButton;
  26350. /**
  26351. * Destroy and release the resources associated with the audio ccontext.
  26352. */
  26353. dispose(): void;
  26354. /**
  26355. * Gets the global volume sets on the master gain.
  26356. * @returns the global volume if set or -1 otherwise
  26357. */
  26358. getGlobalVolume(): number;
  26359. /**
  26360. * Sets the global volume of your experience (sets on the master gain).
  26361. * @param newVolume Defines the new global volume of the application
  26362. */
  26363. setGlobalVolume(newVolume: number): void;
  26364. /**
  26365. * Connect the audio engine to an audio analyser allowing some amazing
  26366. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26368. * @param analyser The analyser to connect to the engine
  26369. */
  26370. connectToAnalyser(analyser: Analyser): void;
  26371. }
  26372. }
  26373. declare module "babylonjs/Loading/loadingScreen" {
  26374. /**
  26375. * Interface used to present a loading screen while loading a scene
  26376. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26377. */
  26378. export interface ILoadingScreen {
  26379. /**
  26380. * Function called to display the loading screen
  26381. */
  26382. displayLoadingUI: () => void;
  26383. /**
  26384. * Function called to hide the loading screen
  26385. */
  26386. hideLoadingUI: () => void;
  26387. /**
  26388. * Gets or sets the color to use for the background
  26389. */
  26390. loadingUIBackgroundColor: string;
  26391. /**
  26392. * Gets or sets the text to display while loading
  26393. */
  26394. loadingUIText: string;
  26395. }
  26396. /**
  26397. * Class used for the default loading screen
  26398. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26399. */
  26400. export class DefaultLoadingScreen implements ILoadingScreen {
  26401. private _renderingCanvas;
  26402. private _loadingText;
  26403. private _loadingDivBackgroundColor;
  26404. private _loadingDiv;
  26405. private _loadingTextDiv;
  26406. /**
  26407. * Creates a new default loading screen
  26408. * @param _renderingCanvas defines the canvas used to render the scene
  26409. * @param _loadingText defines the default text to display
  26410. * @param _loadingDivBackgroundColor defines the default background color
  26411. */
  26412. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26413. /**
  26414. * Function called to display the loading screen
  26415. */
  26416. displayLoadingUI(): void;
  26417. /**
  26418. * Function called to hide the loading screen
  26419. */
  26420. hideLoadingUI(): void;
  26421. /**
  26422. * Gets or sets the text to display while loading
  26423. */
  26424. loadingUIText: string;
  26425. /**
  26426. * Gets or sets the color to use for the background
  26427. */
  26428. loadingUIBackgroundColor: string;
  26429. private _resizeLoadingUI;
  26430. }
  26431. }
  26432. declare module "babylonjs/Materials/Textures/videoTexture" {
  26433. import { Observable } from "babylonjs/Misc/observable";
  26434. import { Nullable } from "babylonjs/types";
  26435. import { Scene } from "babylonjs/scene";
  26436. import { Texture } from "babylonjs/Materials/Textures/texture";
  26437. /**
  26438. * Settings for finer control over video usage
  26439. */
  26440. export interface VideoTextureSettings {
  26441. /**
  26442. * Applies `autoplay` to video, if specified
  26443. */
  26444. autoPlay?: boolean;
  26445. /**
  26446. * Applies `loop` to video, if specified
  26447. */
  26448. loop?: boolean;
  26449. /**
  26450. * Automatically updates internal texture from video at every frame in the render loop
  26451. */
  26452. autoUpdateTexture: boolean;
  26453. /**
  26454. * Image src displayed during the video loading or until the user interacts with the video.
  26455. */
  26456. poster?: string;
  26457. }
  26458. /**
  26459. * If you want to display a video in your scene, this is the special texture for that.
  26460. * This special texture works similar to other textures, with the exception of a few parameters.
  26461. * @see https://doc.babylonjs.com/how_to/video_texture
  26462. */
  26463. export class VideoTexture extends Texture {
  26464. /**
  26465. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26466. */
  26467. readonly autoUpdateTexture: boolean;
  26468. /**
  26469. * The video instance used by the texture internally
  26470. */
  26471. readonly video: HTMLVideoElement;
  26472. private _onUserActionRequestedObservable;
  26473. /**
  26474. * Event triggerd when a dom action is required by the user to play the video.
  26475. * This happens due to recent changes in browser policies preventing video to auto start.
  26476. */
  26477. readonly onUserActionRequestedObservable: Observable<Texture>;
  26478. private _generateMipMaps;
  26479. private _engine;
  26480. private _stillImageCaptured;
  26481. private _displayingPosterTexture;
  26482. private _settings;
  26483. private _createInternalTextureOnEvent;
  26484. /**
  26485. * Creates a video texture.
  26486. * If you want to display a video in your scene, this is the special texture for that.
  26487. * This special texture works similar to other textures, with the exception of a few parameters.
  26488. * @see https://doc.babylonjs.com/how_to/video_texture
  26489. * @param name optional name, will detect from video source, if not defined
  26490. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26491. * @param scene is obviously the current scene.
  26492. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26493. * @param invertY is false by default but can be used to invert video on Y axis
  26494. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26495. * @param settings allows finer control over video usage
  26496. */
  26497. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26498. private _getName;
  26499. private _getVideo;
  26500. private _createInternalTexture;
  26501. private reset;
  26502. /**
  26503. * @hidden Internal method to initiate `update`.
  26504. */
  26505. _rebuild(): void;
  26506. /**
  26507. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26508. */
  26509. update(): void;
  26510. /**
  26511. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26512. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26513. */
  26514. updateTexture(isVisible: boolean): void;
  26515. protected _updateInternalTexture: () => void;
  26516. /**
  26517. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26518. * @param url New url.
  26519. */
  26520. updateURL(url: string): void;
  26521. /**
  26522. * Dispose the texture and release its associated resources.
  26523. */
  26524. dispose(): void;
  26525. /**
  26526. * Creates a video texture straight from your WebCam video feed.
  26527. * @param scene Define the scene the texture should be created in
  26528. * @param onReady Define a callback to triggered once the texture will be ready
  26529. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26530. */
  26531. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26532. minWidth: number;
  26533. maxWidth: number;
  26534. minHeight: number;
  26535. maxHeight: number;
  26536. deviceId: string;
  26537. }): void;
  26538. }
  26539. }
  26540. declare module "babylonjs/Engines/engine" {
  26541. import { Observable } from "babylonjs/Misc/observable";
  26542. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26543. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26544. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26545. import { Camera } from "babylonjs/Cameras/camera";
  26546. import { Scene } from "babylonjs/scene";
  26547. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26548. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26549. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26550. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26551. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26552. import { Material } from "babylonjs/Materials/material";
  26553. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26554. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26556. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26557. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26558. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26559. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26560. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26561. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26564. /**
  26565. * Interface for attribute information associated with buffer instanciation
  26566. */
  26567. export class InstancingAttributeInfo {
  26568. /**
  26569. * Index/offset of the attribute in the vertex shader
  26570. */
  26571. index: number;
  26572. /**
  26573. * size of the attribute, 1, 2, 3 or 4
  26574. */
  26575. attributeSize: number;
  26576. /**
  26577. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26578. * default is FLOAT
  26579. */
  26580. attribyteType: number;
  26581. /**
  26582. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26583. */
  26584. normalized: boolean;
  26585. /**
  26586. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26587. */
  26588. offset: number;
  26589. /**
  26590. * Name of the GLSL attribute, for debugging purpose only
  26591. */
  26592. attributeName: string;
  26593. }
  26594. /**
  26595. * Define options used to create a depth texture
  26596. */
  26597. export class DepthTextureCreationOptions {
  26598. /** Specifies whether or not a stencil should be allocated in the texture */
  26599. generateStencil?: boolean;
  26600. /** Specifies whether or not bilinear filtering is enable on the texture */
  26601. bilinearFiltering?: boolean;
  26602. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26603. comparisonFunction?: number;
  26604. /** Specifies if the created texture is a cube texture */
  26605. isCube?: boolean;
  26606. }
  26607. /**
  26608. * Class used to describe the capabilities of the engine relatively to the current browser
  26609. */
  26610. export class EngineCapabilities {
  26611. /** Maximum textures units per fragment shader */
  26612. maxTexturesImageUnits: number;
  26613. /** Maximum texture units per vertex shader */
  26614. maxVertexTextureImageUnits: number;
  26615. /** Maximum textures units in the entire pipeline */
  26616. maxCombinedTexturesImageUnits: number;
  26617. /** Maximum texture size */
  26618. maxTextureSize: number;
  26619. /** Maximum cube texture size */
  26620. maxCubemapTextureSize: number;
  26621. /** Maximum render texture size */
  26622. maxRenderTextureSize: number;
  26623. /** Maximum number of vertex attributes */
  26624. maxVertexAttribs: number;
  26625. /** Maximum number of varyings */
  26626. maxVaryingVectors: number;
  26627. /** Maximum number of uniforms per vertex shader */
  26628. maxVertexUniformVectors: number;
  26629. /** Maximum number of uniforms per fragment shader */
  26630. maxFragmentUniformVectors: number;
  26631. /** Defines if standard derivates (dx/dy) are supported */
  26632. standardDerivatives: boolean;
  26633. /** Defines if s3tc texture compression is supported */
  26634. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26635. /** Defines if pvrtc texture compression is supported */
  26636. pvrtc: any;
  26637. /** Defines if etc1 texture compression is supported */
  26638. etc1: any;
  26639. /** Defines if etc2 texture compression is supported */
  26640. etc2: any;
  26641. /** Defines if astc texture compression is supported */
  26642. astc: any;
  26643. /** Defines if float textures are supported */
  26644. textureFloat: boolean;
  26645. /** Defines if vertex array objects are supported */
  26646. vertexArrayObject: boolean;
  26647. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26648. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26649. /** Gets the maximum level of anisotropy supported */
  26650. maxAnisotropy: number;
  26651. /** Defines if instancing is supported */
  26652. instancedArrays: boolean;
  26653. /** Defines if 32 bits indices are supported */
  26654. uintIndices: boolean;
  26655. /** Defines if high precision shaders are supported */
  26656. highPrecisionShaderSupported: boolean;
  26657. /** Defines if depth reading in the fragment shader is supported */
  26658. fragmentDepthSupported: boolean;
  26659. /** Defines if float texture linear filtering is supported*/
  26660. textureFloatLinearFiltering: boolean;
  26661. /** Defines if rendering to float textures is supported */
  26662. textureFloatRender: boolean;
  26663. /** Defines if half float textures are supported*/
  26664. textureHalfFloat: boolean;
  26665. /** Defines if half float texture linear filtering is supported*/
  26666. textureHalfFloatLinearFiltering: boolean;
  26667. /** Defines if rendering to half float textures is supported */
  26668. textureHalfFloatRender: boolean;
  26669. /** Defines if textureLOD shader command is supported */
  26670. textureLOD: boolean;
  26671. /** Defines if draw buffers extension is supported */
  26672. drawBuffersExtension: boolean;
  26673. /** Defines if depth textures are supported */
  26674. depthTextureExtension: boolean;
  26675. /** Defines if float color buffer are supported */
  26676. colorBufferFloat: boolean;
  26677. /** Gets disjoint timer query extension (null if not supported) */
  26678. timerQuery: EXT_disjoint_timer_query;
  26679. /** Defines if timestamp can be used with timer query */
  26680. canUseTimestampForTimerQuery: boolean;
  26681. /** Function used to let the system compiles shaders in background */
  26682. parallelShaderCompile: {
  26683. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26684. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26685. COMPLETION_STATUS_KHR: number;
  26686. };
  26687. }
  26688. /** Interface defining initialization parameters for Engine class */
  26689. export interface EngineOptions extends WebGLContextAttributes {
  26690. /**
  26691. * Defines if the engine should no exceed a specified device ratio
  26692. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26693. */
  26694. limitDeviceRatio?: number;
  26695. /**
  26696. * Defines if webvr should be enabled automatically
  26697. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26698. */
  26699. autoEnableWebVR?: boolean;
  26700. /**
  26701. * Defines if webgl2 should be turned off even if supported
  26702. * @see http://doc.babylonjs.com/features/webgl2
  26703. */
  26704. disableWebGL2Support?: boolean;
  26705. /**
  26706. * Defines if webaudio should be initialized as well
  26707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26708. */
  26709. audioEngine?: boolean;
  26710. /**
  26711. * Defines if animations should run using a deterministic lock step
  26712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26713. */
  26714. deterministicLockstep?: boolean;
  26715. /** Defines the maximum steps to use with deterministic lock step mode */
  26716. lockstepMaxSteps?: number;
  26717. /**
  26718. * Defines that engine should ignore context lost events
  26719. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26720. */
  26721. doNotHandleContextLost?: boolean;
  26722. /**
  26723. * Defines that engine should ignore modifying touch action attribute and style
  26724. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26725. */
  26726. doNotHandleTouchAction?: boolean;
  26727. }
  26728. /**
  26729. * Defines the interface used by display changed events
  26730. */
  26731. export interface IDisplayChangedEventArgs {
  26732. /** Gets the vrDisplay object (if any) */
  26733. vrDisplay: Nullable<any>;
  26734. /** Gets a boolean indicating if webVR is supported */
  26735. vrSupported: boolean;
  26736. }
  26737. /**
  26738. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26739. */
  26740. export class Engine {
  26741. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26742. static ExceptionList: ({
  26743. key: string;
  26744. capture: string;
  26745. captureConstraint: number;
  26746. targets: string[];
  26747. } | {
  26748. key: string;
  26749. capture: null;
  26750. captureConstraint: null;
  26751. targets: string[];
  26752. })[];
  26753. /** Gets the list of created engines */
  26754. static readonly Instances: Engine[];
  26755. /**
  26756. * Gets the latest created engine
  26757. */
  26758. static readonly LastCreatedEngine: Nullable<Engine>;
  26759. /**
  26760. * Gets the latest created scene
  26761. */
  26762. static readonly LastCreatedScene: Nullable<Scene>;
  26763. /**
  26764. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26765. * @param flag defines which part of the materials must be marked as dirty
  26766. * @param predicate defines a predicate used to filter which materials should be affected
  26767. */
  26768. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26769. /**
  26770. * Hidden
  26771. */
  26772. static _TextureLoaders: IInternalTextureLoader[];
  26773. /** Defines that alpha blending is disabled */
  26774. static readonly ALPHA_DISABLE: number;
  26775. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26776. static readonly ALPHA_ADD: number;
  26777. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26778. static readonly ALPHA_COMBINE: number;
  26779. /** Defines that alpha blending to DEST - SRC * DEST */
  26780. static readonly ALPHA_SUBTRACT: number;
  26781. /** Defines that alpha blending to SRC * DEST */
  26782. static readonly ALPHA_MULTIPLY: number;
  26783. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26784. static readonly ALPHA_MAXIMIZED: number;
  26785. /** Defines that alpha blending to SRC + DEST */
  26786. static readonly ALPHA_ONEONE: number;
  26787. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26788. static readonly ALPHA_PREMULTIPLIED: number;
  26789. /**
  26790. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26791. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26792. */
  26793. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26794. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26795. static readonly ALPHA_INTERPOLATE: number;
  26796. /**
  26797. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26798. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26799. */
  26800. static readonly ALPHA_SCREENMODE: number;
  26801. /** Defines that the ressource is not delayed*/
  26802. static readonly DELAYLOADSTATE_NONE: number;
  26803. /** Defines that the ressource was successfully delay loaded */
  26804. static readonly DELAYLOADSTATE_LOADED: number;
  26805. /** Defines that the ressource is currently delay loading */
  26806. static readonly DELAYLOADSTATE_LOADING: number;
  26807. /** Defines that the ressource is delayed and has not started loading */
  26808. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26809. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26810. static readonly NEVER: number;
  26811. /** 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 */
  26812. static readonly ALWAYS: number;
  26813. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26814. static readonly LESS: number;
  26815. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26816. static readonly EQUAL: number;
  26817. /** 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 */
  26818. static readonly LEQUAL: number;
  26819. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26820. static readonly GREATER: number;
  26821. /** 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 */
  26822. static readonly GEQUAL: number;
  26823. /** 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 */
  26824. static readonly NOTEQUAL: number;
  26825. /** Passed to stencilOperation to specify that stencil value must be kept */
  26826. static readonly KEEP: number;
  26827. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26828. static readonly REPLACE: number;
  26829. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26830. static readonly INCR: number;
  26831. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26832. static readonly DECR: number;
  26833. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26834. static readonly INVERT: number;
  26835. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26836. static readonly INCR_WRAP: number;
  26837. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26838. static readonly DECR_WRAP: number;
  26839. /** Texture is not repeating outside of 0..1 UVs */
  26840. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26841. /** Texture is repeating outside of 0..1 UVs */
  26842. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26843. /** Texture is repeating and mirrored */
  26844. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26845. /** ALPHA */
  26846. static readonly TEXTUREFORMAT_ALPHA: number;
  26847. /** LUMINANCE */
  26848. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26849. /** LUMINANCE_ALPHA */
  26850. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26851. /** RGB */
  26852. static readonly TEXTUREFORMAT_RGB: number;
  26853. /** RGBA */
  26854. static readonly TEXTUREFORMAT_RGBA: number;
  26855. /** RED */
  26856. static readonly TEXTUREFORMAT_RED: number;
  26857. /** RED (2nd reference) */
  26858. static readonly TEXTUREFORMAT_R: number;
  26859. /** RG */
  26860. static readonly TEXTUREFORMAT_RG: number;
  26861. /** RED_INTEGER */
  26862. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26863. /** RED_INTEGER (2nd reference) */
  26864. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26865. /** RG_INTEGER */
  26866. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26867. /** RGB_INTEGER */
  26868. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26869. /** RGBA_INTEGER */
  26870. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26871. /** UNSIGNED_BYTE */
  26872. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26873. /** UNSIGNED_BYTE (2nd reference) */
  26874. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26875. /** FLOAT */
  26876. static readonly TEXTURETYPE_FLOAT: number;
  26877. /** HALF_FLOAT */
  26878. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26879. /** BYTE */
  26880. static readonly TEXTURETYPE_BYTE: number;
  26881. /** SHORT */
  26882. static readonly TEXTURETYPE_SHORT: number;
  26883. /** UNSIGNED_SHORT */
  26884. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26885. /** INT */
  26886. static readonly TEXTURETYPE_INT: number;
  26887. /** UNSIGNED_INT */
  26888. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26889. /** UNSIGNED_SHORT_4_4_4_4 */
  26890. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26891. /** UNSIGNED_SHORT_5_5_5_1 */
  26892. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26893. /** UNSIGNED_SHORT_5_6_5 */
  26894. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26895. /** UNSIGNED_INT_2_10_10_10_REV */
  26896. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26897. /** UNSIGNED_INT_24_8 */
  26898. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26899. /** UNSIGNED_INT_10F_11F_11F_REV */
  26900. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26901. /** UNSIGNED_INT_5_9_9_9_REV */
  26902. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26903. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26904. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26905. /** nearest is mag = nearest and min = nearest and mip = linear */
  26906. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26907. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26908. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26909. /** Trilinear is mag = linear and min = linear and mip = linear */
  26910. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26911. /** nearest is mag = nearest and min = nearest and mip = linear */
  26912. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26914. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26915. /** Trilinear is mag = linear and min = linear and mip = linear */
  26916. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26917. /** mag = nearest and min = nearest and mip = nearest */
  26918. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26919. /** mag = nearest and min = linear and mip = nearest */
  26920. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26921. /** mag = nearest and min = linear and mip = linear */
  26922. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26923. /** mag = nearest and min = linear and mip = none */
  26924. static readonly TEXTURE_NEAREST_LINEAR: number;
  26925. /** mag = nearest and min = nearest and mip = none */
  26926. static readonly TEXTURE_NEAREST_NEAREST: number;
  26927. /** mag = linear and min = nearest and mip = nearest */
  26928. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26929. /** mag = linear and min = nearest and mip = linear */
  26930. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26931. /** mag = linear and min = linear and mip = none */
  26932. static readonly TEXTURE_LINEAR_LINEAR: number;
  26933. /** mag = linear and min = nearest and mip = none */
  26934. static readonly TEXTURE_LINEAR_NEAREST: number;
  26935. /** Explicit coordinates mode */
  26936. static readonly TEXTURE_EXPLICIT_MODE: number;
  26937. /** Spherical coordinates mode */
  26938. static readonly TEXTURE_SPHERICAL_MODE: number;
  26939. /** Planar coordinates mode */
  26940. static readonly TEXTURE_PLANAR_MODE: number;
  26941. /** Cubic coordinates mode */
  26942. static readonly TEXTURE_CUBIC_MODE: number;
  26943. /** Projection coordinates mode */
  26944. static readonly TEXTURE_PROJECTION_MODE: number;
  26945. /** Skybox coordinates mode */
  26946. static readonly TEXTURE_SKYBOX_MODE: number;
  26947. /** Inverse Cubic coordinates mode */
  26948. static readonly TEXTURE_INVCUBIC_MODE: number;
  26949. /** Equirectangular coordinates mode */
  26950. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26951. /** Equirectangular Fixed coordinates mode */
  26952. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26953. /** Equirectangular Fixed Mirrored coordinates mode */
  26954. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26955. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26956. static readonly SCALEMODE_FLOOR: number;
  26957. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26958. static readonly SCALEMODE_NEAREST: number;
  26959. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26960. static readonly SCALEMODE_CEILING: number;
  26961. /**
  26962. * Returns the current version of the framework
  26963. */
  26964. static readonly Version: string;
  26965. /**
  26966. * Returns a string describing the current engine
  26967. */
  26968. readonly description: string;
  26969. /**
  26970. * Gets or sets the epsilon value used by collision engine
  26971. */
  26972. static CollisionsEpsilon: number;
  26973. /**
  26974. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26975. */
  26976. static ShadersRepository: string;
  26977. /**
  26978. * Method called to create the default loading screen.
  26979. * This can be overriden in your own app.
  26980. * @param canvas The rendering canvas element
  26981. * @returns The loading screen
  26982. */
  26983. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26984. /**
  26985. * Method called to create the default rescale post process on each engine.
  26986. */
  26987. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26988. /**
  26989. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26990. */
  26991. forcePOTTextures: boolean;
  26992. /**
  26993. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26994. */
  26995. isFullscreen: boolean;
  26996. /**
  26997. * Gets a boolean indicating if the pointer is currently locked
  26998. */
  26999. isPointerLock: boolean;
  27000. /**
  27001. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27002. */
  27003. cullBackFaces: boolean;
  27004. /**
  27005. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27006. */
  27007. renderEvenInBackground: boolean;
  27008. /**
  27009. * Gets or sets a boolean indicating that cache can be kept between frames
  27010. */
  27011. preventCacheWipeBetweenFrames: boolean;
  27012. /**
  27013. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27014. **/
  27015. enableOfflineSupport: boolean;
  27016. /**
  27017. * 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)
  27018. **/
  27019. disableManifestCheck: boolean;
  27020. /**
  27021. * Gets the list of created scenes
  27022. */
  27023. scenes: Scene[];
  27024. /**
  27025. * Event raised when a new scene is created
  27026. */
  27027. onNewSceneAddedObservable: Observable<Scene>;
  27028. /**
  27029. * Gets the list of created postprocesses
  27030. */
  27031. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27032. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27033. validateShaderPrograms: boolean;
  27034. /**
  27035. * Observable event triggered each time the rendering canvas is resized
  27036. */
  27037. onResizeObservable: Observable<Engine>;
  27038. /**
  27039. * Observable event triggered each time the canvas loses focus
  27040. */
  27041. onCanvasBlurObservable: Observable<Engine>;
  27042. /**
  27043. * Observable event triggered each time the canvas gains focus
  27044. */
  27045. onCanvasFocusObservable: Observable<Engine>;
  27046. /**
  27047. * Observable event triggered each time the canvas receives pointerout event
  27048. */
  27049. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27050. /**
  27051. * Observable event triggered before each texture is initialized
  27052. */
  27053. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27054. private _vrDisplay;
  27055. private _vrSupported;
  27056. private _oldSize;
  27057. private _oldHardwareScaleFactor;
  27058. private _vrExclusivePointerMode;
  27059. private _webVRInitPromise;
  27060. /**
  27061. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27062. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27063. */
  27064. readonly isInVRExclusivePointerMode: boolean;
  27065. /**
  27066. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27067. */
  27068. disableUniformBuffers: boolean;
  27069. /** @hidden */
  27070. _uniformBuffers: UniformBuffer[];
  27071. /**
  27072. * Gets a boolean indicating that the engine supports uniform buffers
  27073. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27074. */
  27075. readonly supportsUniformBuffers: boolean;
  27076. /**
  27077. * Observable raised when the engine begins a new frame
  27078. */
  27079. onBeginFrameObservable: Observable<Engine>;
  27080. /**
  27081. * If set, will be used to request the next animation frame for the render loop
  27082. */
  27083. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27084. /**
  27085. * Observable raised when the engine ends the current frame
  27086. */
  27087. onEndFrameObservable: Observable<Engine>;
  27088. /**
  27089. * Observable raised when the engine is about to compile a shader
  27090. */
  27091. onBeforeShaderCompilationObservable: Observable<Engine>;
  27092. /**
  27093. * Observable raised when the engine has jsut compiled a shader
  27094. */
  27095. onAfterShaderCompilationObservable: Observable<Engine>;
  27096. /** @hidden */
  27097. _gl: WebGLRenderingContext;
  27098. private _renderingCanvas;
  27099. private _windowIsBackground;
  27100. private _webGLVersion;
  27101. /**
  27102. * Gets a boolean indicating that only power of 2 textures are supported
  27103. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27104. */
  27105. readonly needPOTTextures: boolean;
  27106. /** @hidden */
  27107. _badOS: boolean;
  27108. /** @hidden */
  27109. _badDesktopOS: boolean;
  27110. /**
  27111. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27112. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27113. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27114. */
  27115. disableTextureBindingOptimization: boolean;
  27116. /**
  27117. * Gets the audio engine
  27118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27119. * @ignorenaming
  27120. */
  27121. static audioEngine: IAudioEngine;
  27122. /**
  27123. * Default AudioEngine factory responsible of creating the Audio Engine.
  27124. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27125. */
  27126. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27127. /**
  27128. * Default offline support factory responsible of creating a tool used to store data locally.
  27129. * By default, this will create a Database object if the workload has been embedded.
  27130. */
  27131. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27132. private _onFocus;
  27133. private _onBlur;
  27134. private _onCanvasPointerOut;
  27135. private _onCanvasBlur;
  27136. private _onCanvasFocus;
  27137. private _onFullscreenChange;
  27138. private _onPointerLockChange;
  27139. private _onVRDisplayPointerRestricted;
  27140. private _onVRDisplayPointerUnrestricted;
  27141. private _onVrDisplayConnect;
  27142. private _onVrDisplayDisconnect;
  27143. private _onVrDisplayPresentChange;
  27144. /**
  27145. * Observable signaled when VR display mode changes
  27146. */
  27147. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27148. /**
  27149. * Observable signaled when VR request present is complete
  27150. */
  27151. onVRRequestPresentComplete: Observable<boolean>;
  27152. /**
  27153. * Observable signaled when VR request present starts
  27154. */
  27155. onVRRequestPresentStart: Observable<Engine>;
  27156. private _hardwareScalingLevel;
  27157. /** @hidden */
  27158. protected _caps: EngineCapabilities;
  27159. private _pointerLockRequested;
  27160. private _isStencilEnable;
  27161. private _colorWrite;
  27162. private _loadingScreen;
  27163. /** @hidden */
  27164. _drawCalls: PerfCounter;
  27165. /** @hidden */
  27166. _textureCollisions: PerfCounter;
  27167. private _glVersion;
  27168. private _glRenderer;
  27169. private _glVendor;
  27170. private _videoTextureSupported;
  27171. private _renderingQueueLaunched;
  27172. private _activeRenderLoops;
  27173. private _deterministicLockstep;
  27174. private _lockstepMaxSteps;
  27175. /**
  27176. * Observable signaled when a context lost event is raised
  27177. */
  27178. onContextLostObservable: Observable<Engine>;
  27179. /**
  27180. * Observable signaled when a context restored event is raised
  27181. */
  27182. onContextRestoredObservable: Observable<Engine>;
  27183. private _onContextLost;
  27184. private _onContextRestored;
  27185. private _contextWasLost;
  27186. private _doNotHandleContextLost;
  27187. /**
  27188. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27190. */
  27191. doNotHandleContextLost: boolean;
  27192. private _performanceMonitor;
  27193. private _fps;
  27194. private _deltaTime;
  27195. /**
  27196. * Turn this value on if you want to pause FPS computation when in background
  27197. */
  27198. disablePerformanceMonitorInBackground: boolean;
  27199. /**
  27200. * Gets the performance monitor attached to this engine
  27201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27202. */
  27203. readonly performanceMonitor: PerformanceMonitor;
  27204. /** @hidden */
  27205. protected _depthCullingState: _DepthCullingState;
  27206. /** @hidden */
  27207. protected _stencilState: _StencilState;
  27208. /** @hidden */
  27209. protected _alphaState: _AlphaState;
  27210. /** @hidden */
  27211. protected _alphaMode: number;
  27212. protected _internalTexturesCache: InternalTexture[];
  27213. /** @hidden */
  27214. protected _activeChannel: number;
  27215. private _currentTextureChannel;
  27216. /** @hidden */
  27217. protected _boundTexturesCache: {
  27218. [key: string]: Nullable<InternalTexture>;
  27219. };
  27220. /** @hidden */
  27221. protected _currentEffect: Nullable<Effect>;
  27222. /** @hidden */
  27223. protected _currentProgram: Nullable<WebGLProgram>;
  27224. private _compiledEffects;
  27225. private _vertexAttribArraysEnabled;
  27226. /** @hidden */
  27227. protected _cachedViewport: Nullable<Viewport>;
  27228. private _cachedVertexArrayObject;
  27229. /** @hidden */
  27230. protected _cachedVertexBuffers: any;
  27231. /** @hidden */
  27232. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27233. /** @hidden */
  27234. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27235. /** @hidden */
  27236. protected _currentRenderTarget: Nullable<InternalTexture>;
  27237. private _uintIndicesCurrentlySet;
  27238. private _currentBoundBuffer;
  27239. /** @hidden */
  27240. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27241. private _currentBufferPointers;
  27242. private _currentInstanceLocations;
  27243. private _currentInstanceBuffers;
  27244. private _textureUnits;
  27245. private _firstBoundInternalTextureTracker;
  27246. private _lastBoundInternalTextureTracker;
  27247. private _workingCanvas;
  27248. private _workingContext;
  27249. private _rescalePostProcess;
  27250. private _dummyFramebuffer;
  27251. private _externalData;
  27252. private _bindedRenderFunction;
  27253. private _vaoRecordInProgress;
  27254. private _mustWipeVertexAttributes;
  27255. private _emptyTexture;
  27256. private _emptyCubeTexture;
  27257. private _emptyTexture3D;
  27258. /** @hidden */
  27259. _frameHandler: number;
  27260. private _nextFreeTextureSlots;
  27261. private _maxSimultaneousTextures;
  27262. private _activeRequests;
  27263. private _texturesSupported;
  27264. private _textureFormatInUse;
  27265. /**
  27266. * Gets the list of texture formats supported
  27267. */
  27268. readonly texturesSupported: Array<string>;
  27269. /**
  27270. * Gets the list of texture formats in use
  27271. */
  27272. readonly textureFormatInUse: Nullable<string>;
  27273. /**
  27274. * Gets the current viewport
  27275. */
  27276. readonly currentViewport: Nullable<Viewport>;
  27277. /**
  27278. * Gets the default empty texture
  27279. */
  27280. readonly emptyTexture: InternalTexture;
  27281. /**
  27282. * Gets the default empty 3D texture
  27283. */
  27284. readonly emptyTexture3D: InternalTexture;
  27285. /**
  27286. * Gets the default empty cube texture
  27287. */
  27288. readonly emptyCubeTexture: InternalTexture;
  27289. /**
  27290. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27291. */
  27292. readonly premultipliedAlpha: boolean;
  27293. /**
  27294. * Creates a new engine
  27295. * @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
  27296. * @param antialias defines enable antialiasing (default: false)
  27297. * @param options defines further options to be sent to the getContext() function
  27298. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27299. */
  27300. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27301. private _disableTouchAction;
  27302. private _rebuildInternalTextures;
  27303. private _rebuildEffects;
  27304. /**
  27305. * Gets a boolean indicating if all created effects are ready
  27306. * @returns true if all effects are ready
  27307. */
  27308. areAllEffectsReady(): boolean;
  27309. private _rebuildBuffers;
  27310. private _initGLContext;
  27311. /**
  27312. * Gets version of the current webGL context
  27313. */
  27314. readonly webGLVersion: number;
  27315. /**
  27316. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27317. */
  27318. readonly isStencilEnable: boolean;
  27319. private _prepareWorkingCanvas;
  27320. /**
  27321. * Reset the texture cache to empty state
  27322. */
  27323. resetTextureCache(): void;
  27324. /**
  27325. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27327. * @returns true if engine is in deterministic lock step mode
  27328. */
  27329. isDeterministicLockStep(): boolean;
  27330. /**
  27331. * Gets the max steps when engine is running in deterministic lock step
  27332. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27333. * @returns the max steps
  27334. */
  27335. getLockstepMaxSteps(): number;
  27336. /**
  27337. * Gets an object containing information about the current webGL context
  27338. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27339. */
  27340. getGlInfo(): {
  27341. vendor: string;
  27342. renderer: string;
  27343. version: string;
  27344. };
  27345. /**
  27346. * Gets current aspect ratio
  27347. * @param camera defines the camera to use to get the aspect ratio
  27348. * @param useScreen defines if screen size must be used (or the current render target if any)
  27349. * @returns a number defining the aspect ratio
  27350. */
  27351. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27352. /**
  27353. * Gets current screen aspect ratio
  27354. * @returns a number defining the aspect ratio
  27355. */
  27356. getScreenAspectRatio(): number;
  27357. /**
  27358. * Gets the current render width
  27359. * @param useScreen defines if screen size must be used (or the current render target if any)
  27360. * @returns a number defining the current render width
  27361. */
  27362. getRenderWidth(useScreen?: boolean): number;
  27363. /**
  27364. * Gets the current render height
  27365. * @param useScreen defines if screen size must be used (or the current render target if any)
  27366. * @returns a number defining the current render height
  27367. */
  27368. getRenderHeight(useScreen?: boolean): number;
  27369. /**
  27370. * Gets the HTML canvas attached with the current webGL context
  27371. * @returns a HTML canvas
  27372. */
  27373. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27374. /**
  27375. * Gets the client rect of the HTML canvas attached with the current webGL context
  27376. * @returns a client rectanglee
  27377. */
  27378. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27379. /**
  27380. * Defines the hardware scaling level.
  27381. * By default the hardware scaling level is computed from the window device ratio.
  27382. * 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.
  27383. * @param level defines the level to use
  27384. */
  27385. setHardwareScalingLevel(level: number): void;
  27386. /**
  27387. * Gets the current hardware scaling level.
  27388. * By default the hardware scaling level is computed from the window device ratio.
  27389. * 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.
  27390. * @returns a number indicating the current hardware scaling level
  27391. */
  27392. getHardwareScalingLevel(): number;
  27393. /**
  27394. * Gets the list of loaded textures
  27395. * @returns an array containing all loaded textures
  27396. */
  27397. getLoadedTexturesCache(): InternalTexture[];
  27398. /**
  27399. * Gets the object containing all engine capabilities
  27400. * @returns the EngineCapabilities object
  27401. */
  27402. getCaps(): EngineCapabilities;
  27403. /**
  27404. * Gets the current depth function
  27405. * @returns a number defining the depth function
  27406. */
  27407. getDepthFunction(): Nullable<number>;
  27408. /**
  27409. * Sets the current depth function
  27410. * @param depthFunc defines the function to use
  27411. */
  27412. setDepthFunction(depthFunc: number): void;
  27413. /**
  27414. * Sets the current depth function to GREATER
  27415. */
  27416. setDepthFunctionToGreater(): void;
  27417. /**
  27418. * Sets the current depth function to GEQUAL
  27419. */
  27420. setDepthFunctionToGreaterOrEqual(): void;
  27421. /**
  27422. * Sets the current depth function to LESS
  27423. */
  27424. setDepthFunctionToLess(): void;
  27425. /**
  27426. * Sets the current depth function to LEQUAL
  27427. */
  27428. setDepthFunctionToLessOrEqual(): void;
  27429. /**
  27430. * Gets a boolean indicating if stencil buffer is enabled
  27431. * @returns the current stencil buffer state
  27432. */
  27433. getStencilBuffer(): boolean;
  27434. /**
  27435. * Enable or disable the stencil buffer
  27436. * @param enable defines if the stencil buffer must be enabled or disabled
  27437. */
  27438. setStencilBuffer(enable: boolean): void;
  27439. /**
  27440. * Gets the current stencil mask
  27441. * @returns a number defining the new stencil mask to use
  27442. */
  27443. getStencilMask(): number;
  27444. /**
  27445. * Sets the current stencil mask
  27446. * @param mask defines the new stencil mask to use
  27447. */
  27448. setStencilMask(mask: number): void;
  27449. /**
  27450. * Gets the current stencil function
  27451. * @returns a number defining the stencil function to use
  27452. */
  27453. getStencilFunction(): number;
  27454. /**
  27455. * Gets the current stencil reference value
  27456. * @returns a number defining the stencil reference value to use
  27457. */
  27458. getStencilFunctionReference(): number;
  27459. /**
  27460. * Gets the current stencil mask
  27461. * @returns a number defining the stencil mask to use
  27462. */
  27463. getStencilFunctionMask(): number;
  27464. /**
  27465. * Sets the current stencil function
  27466. * @param stencilFunc defines the new stencil function to use
  27467. */
  27468. setStencilFunction(stencilFunc: number): void;
  27469. /**
  27470. * Sets the current stencil reference
  27471. * @param reference defines the new stencil reference to use
  27472. */
  27473. setStencilFunctionReference(reference: number): void;
  27474. /**
  27475. * Sets the current stencil mask
  27476. * @param mask defines the new stencil mask to use
  27477. */
  27478. setStencilFunctionMask(mask: number): void;
  27479. /**
  27480. * Gets the current stencil operation when stencil fails
  27481. * @returns a number defining stencil operation to use when stencil fails
  27482. */
  27483. getStencilOperationFail(): number;
  27484. /**
  27485. * Gets the current stencil operation when depth fails
  27486. * @returns a number defining stencil operation to use when depth fails
  27487. */
  27488. getStencilOperationDepthFail(): number;
  27489. /**
  27490. * Gets the current stencil operation when stencil passes
  27491. * @returns a number defining stencil operation to use when stencil passes
  27492. */
  27493. getStencilOperationPass(): number;
  27494. /**
  27495. * Sets the stencil operation to use when stencil fails
  27496. * @param operation defines the stencil operation to use when stencil fails
  27497. */
  27498. setStencilOperationFail(operation: number): void;
  27499. /**
  27500. * Sets the stencil operation to use when depth fails
  27501. * @param operation defines the stencil operation to use when depth fails
  27502. */
  27503. setStencilOperationDepthFail(operation: number): void;
  27504. /**
  27505. * Sets the stencil operation to use when stencil passes
  27506. * @param operation defines the stencil operation to use when stencil passes
  27507. */
  27508. setStencilOperationPass(operation: number): void;
  27509. /**
  27510. * Sets a boolean indicating if the dithering state is enabled or disabled
  27511. * @param value defines the dithering state
  27512. */
  27513. setDitheringState(value: boolean): void;
  27514. /**
  27515. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27516. * @param value defines the rasterizer state
  27517. */
  27518. setRasterizerState(value: boolean): void;
  27519. /**
  27520. * stop executing a render loop function and remove it from the execution array
  27521. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27522. */
  27523. stopRenderLoop(renderFunction?: () => void): void;
  27524. /** @hidden */
  27525. _renderLoop(): void;
  27526. /**
  27527. * Register and execute a render loop. The engine can have more than one render function
  27528. * @param renderFunction defines the function to continuously execute
  27529. */
  27530. runRenderLoop(renderFunction: () => void): void;
  27531. /**
  27532. * Toggle full screen mode
  27533. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27534. */
  27535. switchFullscreen(requestPointerLock: boolean): void;
  27536. /**
  27537. * Clear the current render buffer or the current render target (if any is set up)
  27538. * @param color defines the color to use
  27539. * @param backBuffer defines if the back buffer must be cleared
  27540. * @param depth defines if the depth buffer must be cleared
  27541. * @param stencil defines if the stencil buffer must be cleared
  27542. */
  27543. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27544. /**
  27545. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27546. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27547. * @param y defines the y-coordinate of the corner of the clear rectangle
  27548. * @param width defines the width of the clear rectangle
  27549. * @param height defines the height of the clear rectangle
  27550. * @param clearColor defines the clear color
  27551. */
  27552. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27553. /**
  27554. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27555. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27556. * @param y defines the y-coordinate of the corner of the clear rectangle
  27557. * @param width defines the width of the clear rectangle
  27558. * @param height defines the height of the clear rectangle
  27559. */
  27560. enableScissor(x: number, y: number, width: number, height: number): void;
  27561. /**
  27562. * Disable previously set scissor test rectangle
  27563. */
  27564. disableScissor(): void;
  27565. private _viewportCached;
  27566. /** @hidden */
  27567. _viewport(x: number, y: number, width: number, height: number): void;
  27568. /**
  27569. * Set the WebGL's viewport
  27570. * @param viewport defines the viewport element to be used
  27571. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27572. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27573. */
  27574. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27575. /**
  27576. * Directly set the WebGL Viewport
  27577. * @param x defines the x coordinate of the viewport (in screen space)
  27578. * @param y defines the y coordinate of the viewport (in screen space)
  27579. * @param width defines the width of the viewport (in screen space)
  27580. * @param height defines the height of the viewport (in screen space)
  27581. * @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
  27582. */
  27583. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27584. /**
  27585. * Begin a new frame
  27586. */
  27587. beginFrame(): void;
  27588. /**
  27589. * Enf the current frame
  27590. */
  27591. endFrame(): void;
  27592. /**
  27593. * Resize the view according to the canvas' size
  27594. */
  27595. resize(): void;
  27596. /**
  27597. * Force a specific size of the canvas
  27598. * @param width defines the new canvas' width
  27599. * @param height defines the new canvas' height
  27600. */
  27601. setSize(width: number, height: number): void;
  27602. /**
  27603. * Gets a boolean indicating if a webVR device was detected
  27604. * @returns true if a webVR device was detected
  27605. */
  27606. isVRDevicePresent(): boolean;
  27607. /**
  27608. * Gets the current webVR device
  27609. * @returns the current webVR device (or null)
  27610. */
  27611. getVRDevice(): any;
  27612. /**
  27613. * Initializes a webVR display and starts listening to display change events
  27614. * The onVRDisplayChangedObservable will be notified upon these changes
  27615. * @returns The onVRDisplayChangedObservable
  27616. */
  27617. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27618. /**
  27619. * Initializes a webVR display and starts listening to display change events
  27620. * The onVRDisplayChangedObservable will be notified upon these changes
  27621. * @returns A promise containing a VRDisplay and if vr is supported
  27622. */
  27623. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27624. /**
  27625. * Call this function to switch to webVR mode
  27626. * Will do nothing if webVR is not supported or if there is no webVR device
  27627. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27628. */
  27629. enableVR(): void;
  27630. /**
  27631. * Call this function to leave webVR mode
  27632. * Will do nothing if webVR is not supported or if there is no webVR device
  27633. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27634. */
  27635. disableVR(): void;
  27636. private _onVRFullScreenTriggered;
  27637. private _getVRDisplaysAsync;
  27638. /**
  27639. * Binds the frame buffer to the specified texture.
  27640. * @param texture The texture to render to or null for the default canvas
  27641. * @param faceIndex The face of the texture to render to in case of cube texture
  27642. * @param requiredWidth The width of the target to render to
  27643. * @param requiredHeight The height of the target to render to
  27644. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27645. * @param depthStencilTexture The depth stencil texture to use to render
  27646. * @param lodLevel defines le lod level to bind to the frame buffer
  27647. */
  27648. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27649. private bindUnboundFramebuffer;
  27650. /**
  27651. * Unbind the current render target texture from the webGL context
  27652. * @param texture defines the render target texture to unbind
  27653. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27654. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27655. */
  27656. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27657. /**
  27658. * Unbind a list of render target textures from the webGL context
  27659. * This is used only when drawBuffer extension or webGL2 are active
  27660. * @param textures defines the render target textures to unbind
  27661. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27662. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27663. */
  27664. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27665. /**
  27666. * Force the mipmap generation for the given render target texture
  27667. * @param texture defines the render target texture to use
  27668. */
  27669. generateMipMapsForCubemap(texture: InternalTexture): void;
  27670. /**
  27671. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27672. */
  27673. flushFramebuffer(): void;
  27674. /**
  27675. * Unbind the current render target and bind the default framebuffer
  27676. */
  27677. restoreDefaultFramebuffer(): void;
  27678. /**
  27679. * Create an uniform buffer
  27680. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27681. * @param elements defines the content of the uniform buffer
  27682. * @returns the webGL uniform buffer
  27683. */
  27684. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27685. /**
  27686. * Create a dynamic uniform buffer
  27687. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27688. * @param elements defines the content of the uniform buffer
  27689. * @returns the webGL uniform buffer
  27690. */
  27691. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27692. /**
  27693. * Update an existing uniform buffer
  27694. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27695. * @param uniformBuffer defines the target uniform buffer
  27696. * @param elements defines the content to update
  27697. * @param offset defines the offset in the uniform buffer where update should start
  27698. * @param count defines the size of the data to update
  27699. */
  27700. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27701. private _resetVertexBufferBinding;
  27702. /**
  27703. * Creates a vertex buffer
  27704. * @param data the data for the vertex buffer
  27705. * @returns the new WebGL static buffer
  27706. */
  27707. createVertexBuffer(data: DataArray): WebGLBuffer;
  27708. /**
  27709. * Creates a dynamic vertex buffer
  27710. * @param data the data for the dynamic vertex buffer
  27711. * @returns the new WebGL dynamic buffer
  27712. */
  27713. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27714. /**
  27715. * Update a dynamic index buffer
  27716. * @param indexBuffer defines the target index buffer
  27717. * @param indices defines the data to update
  27718. * @param offset defines the offset in the target index buffer where update should start
  27719. */
  27720. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27721. /**
  27722. * Updates a dynamic vertex buffer.
  27723. * @param vertexBuffer the vertex buffer to update
  27724. * @param data the data used to update the vertex buffer
  27725. * @param byteOffset the byte offset of the data
  27726. * @param byteLength the byte length of the data
  27727. */
  27728. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27729. private _resetIndexBufferBinding;
  27730. /**
  27731. * Creates a new index buffer
  27732. * @param indices defines the content of the index buffer
  27733. * @param updatable defines if the index buffer must be updatable
  27734. * @returns a new webGL buffer
  27735. */
  27736. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27737. /**
  27738. * Bind a webGL buffer to the webGL context
  27739. * @param buffer defines the buffer to bind
  27740. */
  27741. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27742. /**
  27743. * Bind an uniform buffer to the current webGL context
  27744. * @param buffer defines the buffer to bind
  27745. */
  27746. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27747. /**
  27748. * Bind a buffer to the current webGL context at a given location
  27749. * @param buffer defines the buffer to bind
  27750. * @param location defines the index where to bind the buffer
  27751. */
  27752. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27753. /**
  27754. * Bind a specific block at a given index in a specific shader program
  27755. * @param shaderProgram defines the shader program
  27756. * @param blockName defines the block name
  27757. * @param index defines the index where to bind the block
  27758. */
  27759. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27760. private bindIndexBuffer;
  27761. private bindBuffer;
  27762. /**
  27763. * update the bound buffer with the given data
  27764. * @param data defines the data to update
  27765. */
  27766. updateArrayBuffer(data: Float32Array): void;
  27767. private _vertexAttribPointer;
  27768. private _bindIndexBufferWithCache;
  27769. private _bindVertexBuffersAttributes;
  27770. /**
  27771. * Records a vertex array object
  27772. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27773. * @param vertexBuffers defines the list of vertex buffers to store
  27774. * @param indexBuffer defines the index buffer to store
  27775. * @param effect defines the effect to store
  27776. * @returns the new vertex array object
  27777. */
  27778. recordVertexArrayObject(vertexBuffers: {
  27779. [key: string]: VertexBuffer;
  27780. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27781. /**
  27782. * Bind a specific vertex array object
  27783. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27784. * @param vertexArrayObject defines the vertex array object to bind
  27785. * @param indexBuffer defines the index buffer to bind
  27786. */
  27787. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27788. /**
  27789. * Bind webGl buffers directly to the webGL context
  27790. * @param vertexBuffer defines the vertex buffer to bind
  27791. * @param indexBuffer defines the index buffer to bind
  27792. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27793. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27794. * @param effect defines the effect associated with the vertex buffer
  27795. */
  27796. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27797. private _unbindVertexArrayObject;
  27798. /**
  27799. * Bind a list of vertex buffers to the webGL context
  27800. * @param vertexBuffers defines the list of vertex buffers to bind
  27801. * @param indexBuffer defines the index buffer to bind
  27802. * @param effect defines the effect associated with the vertex buffers
  27803. */
  27804. bindBuffers(vertexBuffers: {
  27805. [key: string]: Nullable<VertexBuffer>;
  27806. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27807. /**
  27808. * Unbind all instance attributes
  27809. */
  27810. unbindInstanceAttributes(): void;
  27811. /**
  27812. * Release and free the memory of a vertex array object
  27813. * @param vao defines the vertex array object to delete
  27814. */
  27815. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27816. /** @hidden */
  27817. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27818. /**
  27819. * Creates a webGL buffer to use with instanciation
  27820. * @param capacity defines the size of the buffer
  27821. * @returns the webGL buffer
  27822. */
  27823. createInstancesBuffer(capacity: number): WebGLBuffer;
  27824. /**
  27825. * Delete a webGL buffer used with instanciation
  27826. * @param buffer defines the webGL buffer to delete
  27827. */
  27828. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27829. /**
  27830. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27831. * @param instancesBuffer defines the webGL buffer to update and bind
  27832. * @param data defines the data to store in the buffer
  27833. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27834. */
  27835. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27836. /**
  27837. * Apply all cached states (depth, culling, stencil and alpha)
  27838. */
  27839. applyStates(): void;
  27840. /**
  27841. * Send a draw order
  27842. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27843. * @param indexStart defines the starting index
  27844. * @param indexCount defines the number of index to draw
  27845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27846. */
  27847. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27848. /**
  27849. * Draw a list of points
  27850. * @param verticesStart defines the index of first vertex to draw
  27851. * @param verticesCount defines the count of vertices to draw
  27852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27853. */
  27854. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27855. /**
  27856. * Draw a list of unindexed primitives
  27857. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27858. * @param verticesStart defines the index of first vertex to draw
  27859. * @param verticesCount defines the count of vertices to draw
  27860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27861. */
  27862. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27863. /**
  27864. * Draw a list of indexed primitives
  27865. * @param fillMode defines the primitive to use
  27866. * @param indexStart defines the starting index
  27867. * @param indexCount defines the number of index to draw
  27868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27869. */
  27870. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27871. /**
  27872. * Draw a list of unindexed primitives
  27873. * @param fillMode defines the primitive to use
  27874. * @param verticesStart defines the index of first vertex to draw
  27875. * @param verticesCount defines the count of vertices to draw
  27876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27877. */
  27878. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27879. private _drawMode;
  27880. /** @hidden */
  27881. _releaseEffect(effect: Effect): void;
  27882. /** @hidden */
  27883. _deleteProgram(program: WebGLProgram): void;
  27884. /**
  27885. * Create a new effect (used to store vertex/fragment shaders)
  27886. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27887. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27888. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27889. * @param samplers defines an array of string used to represent textures
  27890. * @param defines defines the string containing the defines to use to compile the shaders
  27891. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27892. * @param onCompiled defines a function to call when the effect creation is successful
  27893. * @param onError defines a function to call when the effect creation has failed
  27894. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27895. * @returns the new Effect
  27896. */
  27897. 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;
  27898. private _compileShader;
  27899. private _compileRawShader;
  27900. /**
  27901. * Directly creates a webGL program
  27902. * @param vertexCode defines the vertex shader code to use
  27903. * @param fragmentCode defines the fragment shader code to use
  27904. * @param context defines the webGL context to use (if not set, the current one will be used)
  27905. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27906. * @returns the new webGL program
  27907. */
  27908. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27909. /**
  27910. * Creates a webGL program
  27911. * @param vertexCode defines the vertex shader code to use
  27912. * @param fragmentCode defines the fragment shader code to use
  27913. * @param defines defines the string containing the defines to use to compile the shaders
  27914. * @param context defines the webGL context to use (if not set, the current one will be used)
  27915. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27916. * @returns the new webGL program
  27917. */
  27918. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27919. private _createShaderProgram;
  27920. private _finalizeProgram;
  27921. /** @hidden */
  27922. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27923. /** @hidden */
  27924. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27925. /**
  27926. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27927. * @param shaderProgram defines the webGL program to use
  27928. * @param uniformsNames defines the list of uniform names
  27929. * @returns an array of webGL uniform locations
  27930. */
  27931. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27932. /**
  27933. * Gets the lsit of active attributes for a given webGL program
  27934. * @param shaderProgram defines the webGL program to use
  27935. * @param attributesNames defines the list of attribute names to get
  27936. * @returns an array of indices indicating the offset of each attribute
  27937. */
  27938. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27939. /**
  27940. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27941. * @param effect defines the effect to activate
  27942. */
  27943. enableEffect(effect: Nullable<Effect>): void;
  27944. /**
  27945. * Set the value of an uniform to an array of int32
  27946. * @param uniform defines the webGL uniform location where to store the value
  27947. * @param array defines the array of int32 to store
  27948. */
  27949. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27950. /**
  27951. * Set the value of an uniform to an array of int32 (stored as vec2)
  27952. * @param uniform defines the webGL uniform location where to store the value
  27953. * @param array defines the array of int32 to store
  27954. */
  27955. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27956. /**
  27957. * Set the value of an uniform to an array of int32 (stored as vec3)
  27958. * @param uniform defines the webGL uniform location where to store the value
  27959. * @param array defines the array of int32 to store
  27960. */
  27961. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27962. /**
  27963. * Set the value of an uniform to an array of int32 (stored as vec4)
  27964. * @param uniform defines the webGL uniform location where to store the value
  27965. * @param array defines the array of int32 to store
  27966. */
  27967. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27968. /**
  27969. * Set the value of an uniform to an array of float32
  27970. * @param uniform defines the webGL uniform location where to store the value
  27971. * @param array defines the array of float32 to store
  27972. */
  27973. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27974. /**
  27975. * Set the value of an uniform to an array of float32 (stored as vec2)
  27976. * @param uniform defines the webGL uniform location where to store the value
  27977. * @param array defines the array of float32 to store
  27978. */
  27979. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27980. /**
  27981. * Set the value of an uniform to an array of float32 (stored as vec3)
  27982. * @param uniform defines the webGL uniform location where to store the value
  27983. * @param array defines the array of float32 to store
  27984. */
  27985. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27986. /**
  27987. * Set the value of an uniform to an array of float32 (stored as vec4)
  27988. * @param uniform defines the webGL uniform location where to store the value
  27989. * @param array defines the array of float32 to store
  27990. */
  27991. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27992. /**
  27993. * Set the value of an uniform to an array of number
  27994. * @param uniform defines the webGL uniform location where to store the value
  27995. * @param array defines the array of number to store
  27996. */
  27997. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27998. /**
  27999. * Set the value of an uniform to an array of number (stored as vec2)
  28000. * @param uniform defines the webGL uniform location where to store the value
  28001. * @param array defines the array of number to store
  28002. */
  28003. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28004. /**
  28005. * Set the value of an uniform to an array of number (stored as vec3)
  28006. * @param uniform defines the webGL uniform location where to store the value
  28007. * @param array defines the array of number to store
  28008. */
  28009. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28010. /**
  28011. * Set the value of an uniform to an array of number (stored as vec4)
  28012. * @param uniform defines the webGL uniform location where to store the value
  28013. * @param array defines the array of number to store
  28014. */
  28015. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28016. /**
  28017. * Set the value of an uniform to an array of float32 (stored as matrices)
  28018. * @param uniform defines the webGL uniform location where to store the value
  28019. * @param matrices defines the array of float32 to store
  28020. */
  28021. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28022. /**
  28023. * Set the value of an uniform to a matrix
  28024. * @param uniform defines the webGL uniform location where to store the value
  28025. * @param matrix defines the matrix to store
  28026. */
  28027. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28028. /**
  28029. * Set the value of an uniform to a matrix (3x3)
  28030. * @param uniform defines the webGL uniform location where to store the value
  28031. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28032. */
  28033. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28034. /**
  28035. * Set the value of an uniform to a matrix (2x2)
  28036. * @param uniform defines the webGL uniform location where to store the value
  28037. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28038. */
  28039. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28040. /**
  28041. * Set the value of an uniform to a number (int)
  28042. * @param uniform defines the webGL uniform location where to store the value
  28043. * @param value defines the int number to store
  28044. */
  28045. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28046. /**
  28047. * Set the value of an uniform to a number (float)
  28048. * @param uniform defines the webGL uniform location where to store the value
  28049. * @param value defines the float number to store
  28050. */
  28051. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28052. /**
  28053. * Set the value of an uniform to a vec2
  28054. * @param uniform defines the webGL uniform location where to store the value
  28055. * @param x defines the 1st component of the value
  28056. * @param y defines the 2nd component of the value
  28057. */
  28058. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28059. /**
  28060. * Set the value of an uniform to a vec3
  28061. * @param uniform defines the webGL uniform location where to store the value
  28062. * @param x defines the 1st component of the value
  28063. * @param y defines the 2nd component of the value
  28064. * @param z defines the 3rd component of the value
  28065. */
  28066. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28067. /**
  28068. * Set the value of an uniform to a boolean
  28069. * @param uniform defines the webGL uniform location where to store the value
  28070. * @param bool defines the boolean to store
  28071. */
  28072. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28073. /**
  28074. * Set the value of an uniform to a vec4
  28075. * @param uniform defines the webGL uniform location where to store the value
  28076. * @param x defines the 1st component of the value
  28077. * @param y defines the 2nd component of the value
  28078. * @param z defines the 3rd component of the value
  28079. * @param w defines the 4th component of the value
  28080. */
  28081. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28082. /**
  28083. * Set the value of an uniform to a Color3
  28084. * @param uniform defines the webGL uniform location where to store the value
  28085. * @param color3 defines the color to store
  28086. */
  28087. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28088. /**
  28089. * Set the value of an uniform to a Color3 and an alpha value
  28090. * @param uniform defines the webGL uniform location where to store the value
  28091. * @param color3 defines the color to store
  28092. * @param alpha defines the alpha component to store
  28093. */
  28094. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28095. /**
  28096. * Sets a Color4 on a uniform variable
  28097. * @param uniform defines the uniform location
  28098. * @param color4 defines the value to be set
  28099. */
  28100. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28101. /**
  28102. * Set various states to the webGL context
  28103. * @param culling defines backface culling state
  28104. * @param zOffset defines the value to apply to zOffset (0 by default)
  28105. * @param force defines if states must be applied even if cache is up to date
  28106. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28107. */
  28108. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28109. /**
  28110. * Set the z offset to apply to current rendering
  28111. * @param value defines the offset to apply
  28112. */
  28113. setZOffset(value: number): void;
  28114. /**
  28115. * Gets the current value of the zOffset
  28116. * @returns the current zOffset state
  28117. */
  28118. getZOffset(): number;
  28119. /**
  28120. * Enable or disable depth buffering
  28121. * @param enable defines the state to set
  28122. */
  28123. setDepthBuffer(enable: boolean): void;
  28124. /**
  28125. * Gets a boolean indicating if depth writing is enabled
  28126. * @returns the current depth writing state
  28127. */
  28128. getDepthWrite(): boolean;
  28129. /**
  28130. * Enable or disable depth writing
  28131. * @param enable defines the state to set
  28132. */
  28133. setDepthWrite(enable: boolean): void;
  28134. /**
  28135. * Enable or disable color writing
  28136. * @param enable defines the state to set
  28137. */
  28138. setColorWrite(enable: boolean): void;
  28139. /**
  28140. * Gets a boolean indicating if color writing is enabled
  28141. * @returns the current color writing state
  28142. */
  28143. getColorWrite(): boolean;
  28144. /**
  28145. * Sets alpha constants used by some alpha blending modes
  28146. * @param r defines the red component
  28147. * @param g defines the green component
  28148. * @param b defines the blue component
  28149. * @param a defines the alpha component
  28150. */
  28151. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28152. /**
  28153. * Sets the current alpha mode
  28154. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28155. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28156. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28157. */
  28158. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28159. /**
  28160. * Gets the current alpha mode
  28161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28162. * @returns the current alpha mode
  28163. */
  28164. getAlphaMode(): number;
  28165. /**
  28166. * Clears the list of texture accessible through engine.
  28167. * This can help preventing texture load conflict due to name collision.
  28168. */
  28169. clearInternalTexturesCache(): void;
  28170. /**
  28171. * Force the entire cache to be cleared
  28172. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28173. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28174. */
  28175. wipeCaches(bruteForce?: boolean): void;
  28176. /**
  28177. * Set the compressed texture format to use, based on the formats you have, and the formats
  28178. * supported by the hardware / browser.
  28179. *
  28180. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28181. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28182. * to API arguments needed to compressed textures. This puts the burden on the container
  28183. * generator to house the arcane code for determining these for current & future formats.
  28184. *
  28185. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28186. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28187. *
  28188. * Note: The result of this call is not taken into account when a texture is base64.
  28189. *
  28190. * @param formatsAvailable defines the list of those format families you have created
  28191. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28192. *
  28193. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28194. * @returns The extension selected.
  28195. */
  28196. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28197. private _getSamplingParameters;
  28198. private _partialLoadImg;
  28199. private _cascadeLoadImgs;
  28200. /** @hidden */
  28201. _createTexture(): WebGLTexture;
  28202. /**
  28203. * Usually called from Texture.ts.
  28204. * Passed information to create a WebGLTexture
  28205. * @param urlArg defines a value which contains one of the following:
  28206. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28207. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28208. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28209. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28210. * @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)
  28211. * @param scene needed for loading to the correct scene
  28212. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28213. * @param onLoad optional callback to be called upon successful completion
  28214. * @param onError optional callback to be called upon failure
  28215. * @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
  28216. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28217. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28218. * @param forcedExtension defines the extension to use to pick the right loader
  28219. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28220. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28221. */
  28222. 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;
  28223. private _rescaleTexture;
  28224. /**
  28225. * Update a raw texture
  28226. * @param texture defines the texture to update
  28227. * @param data defines the data to store in the texture
  28228. * @param format defines the format of the data
  28229. * @param invertY defines if data must be stored with Y axis inverted
  28230. * @param compression defines the compression used (null by default)
  28231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28232. */
  28233. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28234. /**
  28235. * Creates a raw texture
  28236. * @param data defines the data to store in the texture
  28237. * @param width defines the width of the texture
  28238. * @param height defines the height of the texture
  28239. * @param format defines the format of the data
  28240. * @param generateMipMaps defines if the engine should generate the mip levels
  28241. * @param invertY defines if data must be stored with Y axis inverted
  28242. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28243. * @param compression defines the compression used (null by default)
  28244. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28245. * @returns the raw texture inside an InternalTexture
  28246. */
  28247. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28248. private _unpackFlipYCached;
  28249. /**
  28250. * In case you are sharing the context with other applications, it might
  28251. * be interested to not cache the unpack flip y state to ensure a consistent
  28252. * value would be set.
  28253. */
  28254. enableUnpackFlipYCached: boolean;
  28255. /** @hidden */
  28256. _unpackFlipY(value: boolean): void;
  28257. /** @hidden */
  28258. _getUnpackAlignement(): number;
  28259. /**
  28260. * Creates a dynamic texture
  28261. * @param width defines the width of the texture
  28262. * @param height defines the height of the texture
  28263. * @param generateMipMaps defines if the engine should generate the mip levels
  28264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28265. * @returns the dynamic texture inside an InternalTexture
  28266. */
  28267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28268. /**
  28269. * Update the sampling mode of a given texture
  28270. * @param samplingMode defines the required sampling mode
  28271. * @param texture defines the texture to update
  28272. */
  28273. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28274. /**
  28275. * Update the content of a dynamic texture
  28276. * @param texture defines the texture to update
  28277. * @param canvas defines the canvas containing the source
  28278. * @param invertY defines if data must be stored with Y axis inverted
  28279. * @param premulAlpha defines if alpha is stored as premultiplied
  28280. * @param format defines the format of the data
  28281. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28282. */
  28283. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28284. /**
  28285. * Update a video texture
  28286. * @param texture defines the texture to update
  28287. * @param video defines the video element to use
  28288. * @param invertY defines if data must be stored with Y axis inverted
  28289. */
  28290. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28291. /**
  28292. * Updates a depth texture Comparison Mode and Function.
  28293. * If the comparison Function is equal to 0, the mode will be set to none.
  28294. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28295. * @param texture The texture to set the comparison function for
  28296. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28297. */
  28298. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28299. private _setupDepthStencilTexture;
  28300. /**
  28301. * Creates a depth stencil texture.
  28302. * This is only available in WebGL 2 or with the depth texture extension available.
  28303. * @param size The size of face edge in the texture.
  28304. * @param options The options defining the texture.
  28305. * @returns The texture
  28306. */
  28307. createDepthStencilTexture(size: number | {
  28308. width: number;
  28309. height: number;
  28310. }, options: DepthTextureCreationOptions): InternalTexture;
  28311. /**
  28312. * Creates a depth stencil texture.
  28313. * This is only available in WebGL 2 or with the depth texture extension available.
  28314. * @param size The size of face edge in the texture.
  28315. * @param options The options defining the texture.
  28316. * @returns The texture
  28317. */
  28318. private _createDepthStencilTexture;
  28319. /**
  28320. * Creates a depth stencil cube texture.
  28321. * This is only available in WebGL 2.
  28322. * @param size The size of face edge in the cube texture.
  28323. * @param options The options defining the cube texture.
  28324. * @returns The cube texture
  28325. */
  28326. private _createDepthStencilCubeTexture;
  28327. /**
  28328. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28329. * @param renderTarget The render target to set the frame buffer for
  28330. */
  28331. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28332. /**
  28333. * Creates a new render target texture
  28334. * @param size defines the size of the texture
  28335. * @param options defines the options used to create the texture
  28336. * @returns a new render target texture stored in an InternalTexture
  28337. */
  28338. createRenderTargetTexture(size: number | {
  28339. width: number;
  28340. height: number;
  28341. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28342. /**
  28343. * Create a multi render target texture
  28344. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28345. * @param size defines the size of the texture
  28346. * @param options defines the creation options
  28347. * @returns the cube texture as an InternalTexture
  28348. */
  28349. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28350. private _setupFramebufferDepthAttachments;
  28351. /**
  28352. * Updates the sample count of a render target texture
  28353. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28354. * @param texture defines the texture to update
  28355. * @param samples defines the sample count to set
  28356. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28357. */
  28358. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28359. /**
  28360. * Update the sample count for a given multiple render target texture
  28361. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28362. * @param textures defines the textures to update
  28363. * @param samples defines the sample count to set
  28364. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28365. */
  28366. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28367. /** @hidden */
  28368. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28369. /** @hidden */
  28370. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28371. /** @hidden */
  28372. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28373. /** @hidden */
  28374. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28375. /**
  28376. * Creates a new render target cube texture
  28377. * @param size defines the size of the texture
  28378. * @param options defines the options used to create the texture
  28379. * @returns a new render target cube texture stored in an InternalTexture
  28380. */
  28381. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28382. /**
  28383. * Creates a cube texture
  28384. * @param rootUrl defines the url where the files to load is located
  28385. * @param scene defines the current scene
  28386. * @param files defines the list of files to load (1 per face)
  28387. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28388. * @param onLoad defines an optional callback raised when the texture is loaded
  28389. * @param onError defines an optional callback raised if there is an issue to load the texture
  28390. * @param format defines the format of the data
  28391. * @param forcedExtension defines the extension to use to pick the right loader
  28392. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28393. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28394. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28395. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28396. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28397. * @returns the cube texture as an InternalTexture
  28398. */
  28399. 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;
  28400. /**
  28401. * @hidden
  28402. */
  28403. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28404. /**
  28405. * Update a raw cube texture
  28406. * @param texture defines the texture to udpdate
  28407. * @param data defines the data to store
  28408. * @param format defines the data format
  28409. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28410. * @param invertY defines if data must be stored with Y axis inverted
  28411. * @param compression defines the compression used (null by default)
  28412. * @param level defines which level of the texture to update
  28413. */
  28414. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28415. /**
  28416. * Creates a new raw cube texture
  28417. * @param data defines the array of data to use to create each face
  28418. * @param size defines the size of the textures
  28419. * @param format defines the format of the data
  28420. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28421. * @param generateMipMaps defines if the engine should generate the mip levels
  28422. * @param invertY defines if data must be stored with Y axis inverted
  28423. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28424. * @param compression defines the compression used (null by default)
  28425. * @returns the cube texture as an InternalTexture
  28426. */
  28427. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28428. /**
  28429. * Creates a new raw cube texture from a specified url
  28430. * @param url defines the url where the data is located
  28431. * @param scene defines the current scene
  28432. * @param size defines the size of the textures
  28433. * @param format defines the format of the data
  28434. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28435. * @param noMipmap defines if the engine should avoid generating the mip levels
  28436. * @param callback defines a callback used to extract texture data from loaded data
  28437. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28438. * @param onLoad defines a callback called when texture is loaded
  28439. * @param onError defines a callback called if there is an error
  28440. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28441. * @param invertY defines if data must be stored with Y axis inverted
  28442. * @returns the cube texture as an InternalTexture
  28443. */
  28444. 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;
  28445. /**
  28446. * Update a raw 3D texture
  28447. * @param texture defines the texture to update
  28448. * @param data defines the data to store
  28449. * @param format defines the data format
  28450. * @param invertY defines if data must be stored with Y axis inverted
  28451. * @param compression defines the used compression (can be null)
  28452. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28453. */
  28454. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28455. /**
  28456. * Creates a new raw 3D texture
  28457. * @param data defines the data used to create the texture
  28458. * @param width defines the width of the texture
  28459. * @param height defines the height of the texture
  28460. * @param depth defines the depth of the texture
  28461. * @param format defines the format of the texture
  28462. * @param generateMipMaps defines if the engine must generate mip levels
  28463. * @param invertY defines if data must be stored with Y axis inverted
  28464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28465. * @param compression defines the compressed used (can be null)
  28466. * @param textureType defines the compressed used (can be null)
  28467. * @returns a new raw 3D texture (stored in an InternalTexture)
  28468. */
  28469. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28470. private _prepareWebGLTextureContinuation;
  28471. private _prepareWebGLTexture;
  28472. private _convertRGBtoRGBATextureData;
  28473. /** @hidden */
  28474. _releaseFramebufferObjects(texture: InternalTexture): void;
  28475. /** @hidden */
  28476. _releaseTexture(texture: InternalTexture): void;
  28477. private setProgram;
  28478. private _boundUniforms;
  28479. /**
  28480. * Binds an effect to the webGL context
  28481. * @param effect defines the effect to bind
  28482. */
  28483. bindSamplers(effect: Effect): void;
  28484. private _moveBoundTextureOnTop;
  28485. private _getCorrectTextureChannel;
  28486. private _linkTrackers;
  28487. private _removeDesignatedSlot;
  28488. private _activateCurrentTexture;
  28489. /** @hidden */
  28490. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28491. /** @hidden */
  28492. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28493. /**
  28494. * Sets a texture to the webGL context from a postprocess
  28495. * @param channel defines the channel to use
  28496. * @param postProcess defines the source postprocess
  28497. */
  28498. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28499. /**
  28500. * Binds the output of the passed in post process to the texture channel specified
  28501. * @param channel The channel the texture should be bound to
  28502. * @param postProcess The post process which's output should be bound
  28503. */
  28504. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28505. /**
  28506. * Unbind all textures from the webGL context
  28507. */
  28508. unbindAllTextures(): void;
  28509. /**
  28510. * Sets a texture to the according uniform.
  28511. * @param channel The texture channel
  28512. * @param uniform The uniform to set
  28513. * @param texture The texture to apply
  28514. */
  28515. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28516. /**
  28517. * Sets a depth stencil texture from a render target to the according uniform.
  28518. * @param channel The texture channel
  28519. * @param uniform The uniform to set
  28520. * @param texture The render target texture containing the depth stencil texture to apply
  28521. */
  28522. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28523. private _bindSamplerUniformToChannel;
  28524. private _getTextureWrapMode;
  28525. private _setTexture;
  28526. /**
  28527. * Sets an array of texture to the webGL context
  28528. * @param channel defines the channel where the texture array must be set
  28529. * @param uniform defines the associated uniform location
  28530. * @param textures defines the array of textures to bind
  28531. */
  28532. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28533. /** @hidden */
  28534. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28535. private _setTextureParameterFloat;
  28536. private _setTextureParameterInteger;
  28537. /**
  28538. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28539. * @param x defines the x coordinate of the rectangle where pixels must be read
  28540. * @param y defines the y coordinate of the rectangle where pixels must be read
  28541. * @param width defines the width of the rectangle where pixels must be read
  28542. * @param height defines the height of the rectangle where pixels must be read
  28543. * @returns a Uint8Array containing RGBA colors
  28544. */
  28545. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28546. /**
  28547. * Add an externaly attached data from its key.
  28548. * This method call will fail and return false, if such key already exists.
  28549. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28550. * @param key the unique key that identifies the data
  28551. * @param data the data object to associate to the key for this Engine instance
  28552. * @return true if no such key were already present and the data was added successfully, false otherwise
  28553. */
  28554. addExternalData<T>(key: string, data: T): boolean;
  28555. /**
  28556. * Get an externaly attached data from its key
  28557. * @param key the unique key that identifies the data
  28558. * @return the associated data, if present (can be null), or undefined if not present
  28559. */
  28560. getExternalData<T>(key: string): T;
  28561. /**
  28562. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28563. * @param key the unique key that identifies the data
  28564. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28565. * @return the associated data, can be null if the factory returned null.
  28566. */
  28567. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28568. /**
  28569. * Remove an externaly attached data from the Engine instance
  28570. * @param key the unique key that identifies the data
  28571. * @return true if the data was successfully removed, false if it doesn't exist
  28572. */
  28573. removeExternalData(key: string): boolean;
  28574. /**
  28575. * Unbind all vertex attributes from the webGL context
  28576. */
  28577. unbindAllAttributes(): void;
  28578. /**
  28579. * 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
  28580. */
  28581. releaseEffects(): void;
  28582. /**
  28583. * Dispose and release all associated resources
  28584. */
  28585. dispose(): void;
  28586. /**
  28587. * Display the loading screen
  28588. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28589. */
  28590. displayLoadingUI(): void;
  28591. /**
  28592. * Hide the loading screen
  28593. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28594. */
  28595. hideLoadingUI(): void;
  28596. /**
  28597. * Gets the current loading screen object
  28598. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28599. */
  28600. /**
  28601. * Sets the current loading screen object
  28602. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28603. */
  28604. loadingScreen: ILoadingScreen;
  28605. /**
  28606. * Sets the current loading screen text
  28607. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28608. */
  28609. loadingUIText: string;
  28610. /**
  28611. * Sets the current loading screen background color
  28612. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28613. */
  28614. loadingUIBackgroundColor: string;
  28615. /**
  28616. * Attach a new callback raised when context lost event is fired
  28617. * @param callback defines the callback to call
  28618. */
  28619. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28620. /**
  28621. * Attach a new callback raised when context restored event is fired
  28622. * @param callback defines the callback to call
  28623. */
  28624. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28625. /**
  28626. * Gets the source code of the vertex shader associated with a specific webGL program
  28627. * @param program defines the program to use
  28628. * @returns a string containing the source code of the vertex shader associated with the program
  28629. */
  28630. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28631. /**
  28632. * Gets the source code of the fragment shader associated with a specific webGL program
  28633. * @param program defines the program to use
  28634. * @returns a string containing the source code of the fragment shader associated with the program
  28635. */
  28636. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28637. /**
  28638. * Get the current error code of the webGL context
  28639. * @returns the error code
  28640. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28641. */
  28642. getError(): number;
  28643. /**
  28644. * Gets the current framerate
  28645. * @returns a number representing the framerate
  28646. */
  28647. getFps(): number;
  28648. /**
  28649. * Gets the time spent between current and previous frame
  28650. * @returns a number representing the delta time in ms
  28651. */
  28652. getDeltaTime(): number;
  28653. private _measureFps;
  28654. /** @hidden */
  28655. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28656. private _canRenderToFloatFramebuffer;
  28657. private _canRenderToHalfFloatFramebuffer;
  28658. private _canRenderToFramebuffer;
  28659. /** @hidden */
  28660. _getWebGLTextureType(type: number): number;
  28661. private _getInternalFormat;
  28662. /** @hidden */
  28663. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28664. /** @hidden */
  28665. _getRGBAMultiSampleBufferFormat(type: number): number;
  28666. /** @hidden */
  28667. _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;
  28668. /** @hidden */
  28669. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28670. private _partialLoadFile;
  28671. private _cascadeLoadFiles;
  28672. /**
  28673. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28674. * @returns true if the engine can be created
  28675. * @ignorenaming
  28676. */
  28677. static isSupported(): boolean;
  28678. }
  28679. }
  28680. declare module "babylonjs/Materials/effect" {
  28681. import { Observable } from "babylonjs/Misc/observable";
  28682. import { Nullable } from "babylonjs/types";
  28683. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28684. import { Engine } from "babylonjs/Engines/engine";
  28685. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28688. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28690. /**
  28691. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28692. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28693. */
  28694. export class EffectFallbacks {
  28695. private _defines;
  28696. private _currentRank;
  28697. private _maxRank;
  28698. private _mesh;
  28699. /**
  28700. * Removes the fallback from the bound mesh.
  28701. */
  28702. unBindMesh(): void;
  28703. /**
  28704. * Adds a fallback on the specified property.
  28705. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28706. * @param define The name of the define in the shader
  28707. */
  28708. addFallback(rank: number, define: string): void;
  28709. /**
  28710. * Sets the mesh to use CPU skinning when needing to fallback.
  28711. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28712. * @param mesh The mesh to use the fallbacks.
  28713. */
  28714. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28715. /**
  28716. * Checks to see if more fallbacks are still availible.
  28717. */
  28718. readonly isMoreFallbacks: boolean;
  28719. /**
  28720. * Removes the defines that shoould be removed when falling back.
  28721. * @param currentDefines defines the current define statements for the shader.
  28722. * @param effect defines the current effect we try to compile
  28723. * @returns The resulting defines with defines of the current rank removed.
  28724. */
  28725. reduce(currentDefines: string, effect: Effect): string;
  28726. }
  28727. /**
  28728. * Options to be used when creating an effect.
  28729. */
  28730. export class EffectCreationOptions {
  28731. /**
  28732. * Atrributes that will be used in the shader.
  28733. */
  28734. attributes: string[];
  28735. /**
  28736. * Uniform varible names that will be set in the shader.
  28737. */
  28738. uniformsNames: string[];
  28739. /**
  28740. * Uniform buffer varible names that will be set in the shader.
  28741. */
  28742. uniformBuffersNames: string[];
  28743. /**
  28744. * Sampler texture variable names that will be set in the shader.
  28745. */
  28746. samplers: string[];
  28747. /**
  28748. * Define statements that will be set in the shader.
  28749. */
  28750. defines: any;
  28751. /**
  28752. * Possible fallbacks for this effect to improve performance when needed.
  28753. */
  28754. fallbacks: Nullable<EffectFallbacks>;
  28755. /**
  28756. * Callback that will be called when the shader is compiled.
  28757. */
  28758. onCompiled: Nullable<(effect: Effect) => void>;
  28759. /**
  28760. * Callback that will be called if an error occurs during shader compilation.
  28761. */
  28762. onError: Nullable<(effect: Effect, errors: string) => void>;
  28763. /**
  28764. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28765. */
  28766. indexParameters: any;
  28767. /**
  28768. * Max number of lights that can be used in the shader.
  28769. */
  28770. maxSimultaneousLights: number;
  28771. /**
  28772. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28773. */
  28774. transformFeedbackVaryings: Nullable<string[]>;
  28775. }
  28776. /**
  28777. * Effect containing vertex and fragment shader that can be executed on an object.
  28778. */
  28779. export class Effect {
  28780. /**
  28781. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28782. */
  28783. static ShadersRepository: string;
  28784. /**
  28785. * Name of the effect.
  28786. */
  28787. name: any;
  28788. /**
  28789. * String container all the define statements that should be set on the shader.
  28790. */
  28791. defines: string;
  28792. /**
  28793. * Callback that will be called when the shader is compiled.
  28794. */
  28795. onCompiled: Nullable<(effect: Effect) => void>;
  28796. /**
  28797. * Callback that will be called if an error occurs during shader compilation.
  28798. */
  28799. onError: Nullable<(effect: Effect, errors: string) => void>;
  28800. /**
  28801. * Callback that will be called when effect is bound.
  28802. */
  28803. onBind: Nullable<(effect: Effect) => void>;
  28804. /**
  28805. * Unique ID of the effect.
  28806. */
  28807. uniqueId: number;
  28808. /**
  28809. * Observable that will be called when the shader is compiled.
  28810. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28811. */
  28812. onCompileObservable: Observable<Effect>;
  28813. /**
  28814. * Observable that will be called if an error occurs during shader compilation.
  28815. */
  28816. onErrorObservable: Observable<Effect>;
  28817. /** @hidden */
  28818. _onBindObservable: Nullable<Observable<Effect>>;
  28819. /**
  28820. * Observable that will be called when effect is bound.
  28821. */
  28822. readonly onBindObservable: Observable<Effect>;
  28823. /** @hidden */
  28824. _bonesComputationForcedToCPU: boolean;
  28825. private static _uniqueIdSeed;
  28826. private _engine;
  28827. private _uniformBuffersNames;
  28828. private _uniformsNames;
  28829. private _samplers;
  28830. private _isReady;
  28831. private _compilationError;
  28832. private _attributesNames;
  28833. private _attributes;
  28834. private _uniforms;
  28835. /**
  28836. * Key for the effect.
  28837. * @hidden
  28838. */
  28839. _key: string;
  28840. private _indexParameters;
  28841. private _fallbacks;
  28842. private _vertexSourceCode;
  28843. private _fragmentSourceCode;
  28844. private _vertexSourceCodeOverride;
  28845. private _fragmentSourceCodeOverride;
  28846. private _transformFeedbackVaryings;
  28847. /**
  28848. * Compiled shader to webGL program.
  28849. * @hidden
  28850. */
  28851. _program: WebGLProgram;
  28852. private _valueCache;
  28853. private static _baseCache;
  28854. /**
  28855. * Instantiates an effect.
  28856. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28857. * @param baseName Name of the effect.
  28858. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28859. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28860. * @param samplers List of sampler variables that will be passed to the shader.
  28861. * @param engine Engine to be used to render the effect
  28862. * @param defines Define statements to be added to the shader.
  28863. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28864. * @param onCompiled Callback that will be called when the shader is compiled.
  28865. * @param onError Callback that will be called if an error occurs during shader compilation.
  28866. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28867. */
  28868. 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);
  28869. /**
  28870. * Unique key for this effect
  28871. */
  28872. readonly key: string;
  28873. /**
  28874. * If the effect has been compiled and prepared.
  28875. * @returns if the effect is compiled and prepared.
  28876. */
  28877. isReady(): boolean;
  28878. /**
  28879. * The engine the effect was initialized with.
  28880. * @returns the engine.
  28881. */
  28882. getEngine(): Engine;
  28883. /**
  28884. * The compiled webGL program for the effect
  28885. * @returns the webGL program.
  28886. */
  28887. getProgram(): WebGLProgram;
  28888. /**
  28889. * The set of names of attribute variables for the shader.
  28890. * @returns An array of attribute names.
  28891. */
  28892. getAttributesNames(): string[];
  28893. /**
  28894. * Returns the attribute at the given index.
  28895. * @param index The index of the attribute.
  28896. * @returns The location of the attribute.
  28897. */
  28898. getAttributeLocation(index: number): number;
  28899. /**
  28900. * Returns the attribute based on the name of the variable.
  28901. * @param name of the attribute to look up.
  28902. * @returns the attribute location.
  28903. */
  28904. getAttributeLocationByName(name: string): number;
  28905. /**
  28906. * The number of attributes.
  28907. * @returns the numnber of attributes.
  28908. */
  28909. getAttributesCount(): number;
  28910. /**
  28911. * Gets the index of a uniform variable.
  28912. * @param uniformName of the uniform to look up.
  28913. * @returns the index.
  28914. */
  28915. getUniformIndex(uniformName: string): number;
  28916. /**
  28917. * Returns the attribute based on the name of the variable.
  28918. * @param uniformName of the uniform to look up.
  28919. * @returns the location of the uniform.
  28920. */
  28921. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28922. /**
  28923. * Returns an array of sampler variable names
  28924. * @returns The array of sampler variable neames.
  28925. */
  28926. getSamplers(): string[];
  28927. /**
  28928. * The error from the last compilation.
  28929. * @returns the error string.
  28930. */
  28931. getCompilationError(): string;
  28932. /**
  28933. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28934. * @param func The callback to be used.
  28935. */
  28936. executeWhenCompiled(func: (effect: Effect) => void): void;
  28937. private _checkIsReady;
  28938. /** @hidden */
  28939. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28940. /** @hidden */
  28941. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28942. /** @hidden */
  28943. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28944. private _processShaderConversion;
  28945. private _processIncludes;
  28946. private _processPrecision;
  28947. /**
  28948. * Recompiles the webGL program
  28949. * @param vertexSourceCode The source code for the vertex shader.
  28950. * @param fragmentSourceCode The source code for the fragment shader.
  28951. * @param onCompiled Callback called when completed.
  28952. * @param onError Callback called on error.
  28953. * @hidden
  28954. */
  28955. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28956. /**
  28957. * Gets the uniform locations of the the specified variable names
  28958. * @param names THe names of the variables to lookup.
  28959. * @returns Array of locations in the same order as variable names.
  28960. */
  28961. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28962. /**
  28963. * Prepares the effect
  28964. * @hidden
  28965. */
  28966. _prepareEffect(): void;
  28967. /**
  28968. * Checks if the effect is supported. (Must be called after compilation)
  28969. */
  28970. readonly isSupported: boolean;
  28971. /**
  28972. * Binds a texture to the engine to be used as output of the shader.
  28973. * @param channel Name of the output variable.
  28974. * @param texture Texture to bind.
  28975. * @hidden
  28976. */
  28977. _bindTexture(channel: string, texture: InternalTexture): void;
  28978. /**
  28979. * Sets a texture on the engine to be used in the shader.
  28980. * @param channel Name of the sampler variable.
  28981. * @param texture Texture to set.
  28982. */
  28983. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28984. /**
  28985. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28986. * @param channel Name of the sampler variable.
  28987. * @param texture Texture to set.
  28988. */
  28989. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28990. /**
  28991. * Sets an array of textures on the engine to be used in the shader.
  28992. * @param channel Name of the variable.
  28993. * @param textures Textures to set.
  28994. */
  28995. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28996. /**
  28997. * 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)
  28998. * @param channel Name of the sampler variable.
  28999. * @param postProcess Post process to get the input texture from.
  29000. */
  29001. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29002. /**
  29003. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29004. * 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)
  29005. * @param channel Name of the sampler variable.
  29006. * @param postProcess Post process to get the output texture from.
  29007. */
  29008. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29009. /** @hidden */
  29010. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29011. /** @hidden */
  29012. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29013. /** @hidden */
  29014. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29015. /** @hidden */
  29016. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29017. /**
  29018. * Binds a buffer to a uniform.
  29019. * @param buffer Buffer to bind.
  29020. * @param name Name of the uniform variable to bind to.
  29021. */
  29022. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29023. /**
  29024. * Binds block to a uniform.
  29025. * @param blockName Name of the block to bind.
  29026. * @param index Index to bind.
  29027. */
  29028. bindUniformBlock(blockName: string, index: number): void;
  29029. /**
  29030. * Sets an interger value on a uniform variable.
  29031. * @param uniformName Name of the variable.
  29032. * @param value Value to be set.
  29033. * @returns this effect.
  29034. */
  29035. setInt(uniformName: string, value: number): Effect;
  29036. /**
  29037. * Sets an int array on a uniform variable.
  29038. * @param uniformName Name of the variable.
  29039. * @param array array to be set.
  29040. * @returns this effect.
  29041. */
  29042. setIntArray(uniformName: string, array: Int32Array): Effect;
  29043. /**
  29044. * 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)
  29045. * @param uniformName Name of the variable.
  29046. * @param array array to be set.
  29047. * @returns this effect.
  29048. */
  29049. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29050. /**
  29051. * 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)
  29052. * @param uniformName Name of the variable.
  29053. * @param array array to be set.
  29054. * @returns this effect.
  29055. */
  29056. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29057. /**
  29058. * 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)
  29059. * @param uniformName Name of the variable.
  29060. * @param array array to be set.
  29061. * @returns this effect.
  29062. */
  29063. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29064. /**
  29065. * Sets an float array on a uniform variable.
  29066. * @param uniformName Name of the variable.
  29067. * @param array array to be set.
  29068. * @returns this effect.
  29069. */
  29070. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29071. /**
  29072. * 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)
  29073. * @param uniformName Name of the variable.
  29074. * @param array array to be set.
  29075. * @returns this effect.
  29076. */
  29077. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29078. /**
  29079. * 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)
  29080. * @param uniformName Name of the variable.
  29081. * @param array array to be set.
  29082. * @returns this effect.
  29083. */
  29084. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29085. /**
  29086. * 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)
  29087. * @param uniformName Name of the variable.
  29088. * @param array array to be set.
  29089. * @returns this effect.
  29090. */
  29091. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29092. /**
  29093. * Sets an array on a uniform variable.
  29094. * @param uniformName Name of the variable.
  29095. * @param array array to be set.
  29096. * @returns this effect.
  29097. */
  29098. setArray(uniformName: string, array: number[]): Effect;
  29099. /**
  29100. * 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)
  29101. * @param uniformName Name of the variable.
  29102. * @param array array to be set.
  29103. * @returns this effect.
  29104. */
  29105. setArray2(uniformName: string, array: number[]): Effect;
  29106. /**
  29107. * 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)
  29108. * @param uniformName Name of the variable.
  29109. * @param array array to be set.
  29110. * @returns this effect.
  29111. */
  29112. setArray3(uniformName: string, array: number[]): Effect;
  29113. /**
  29114. * 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)
  29115. * @param uniformName Name of the variable.
  29116. * @param array array to be set.
  29117. * @returns this effect.
  29118. */
  29119. setArray4(uniformName: string, array: number[]): Effect;
  29120. /**
  29121. * Sets matrices on a uniform variable.
  29122. * @param uniformName Name of the variable.
  29123. * @param matrices matrices to be set.
  29124. * @returns this effect.
  29125. */
  29126. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29127. /**
  29128. * Sets matrix on a uniform variable.
  29129. * @param uniformName Name of the variable.
  29130. * @param matrix matrix to be set.
  29131. * @returns this effect.
  29132. */
  29133. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29134. /**
  29135. * 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)
  29136. * @param uniformName Name of the variable.
  29137. * @param matrix matrix to be set.
  29138. * @returns this effect.
  29139. */
  29140. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29141. /**
  29142. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29143. * @param uniformName Name of the variable.
  29144. * @param matrix matrix to be set.
  29145. * @returns this effect.
  29146. */
  29147. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29148. /**
  29149. * Sets a float on a uniform variable.
  29150. * @param uniformName Name of the variable.
  29151. * @param value value to be set.
  29152. * @returns this effect.
  29153. */
  29154. setFloat(uniformName: string, value: number): Effect;
  29155. /**
  29156. * Sets a boolean on a uniform variable.
  29157. * @param uniformName Name of the variable.
  29158. * @param bool value to be set.
  29159. * @returns this effect.
  29160. */
  29161. setBool(uniformName: string, bool: boolean): Effect;
  29162. /**
  29163. * Sets a Vector2 on a uniform variable.
  29164. * @param uniformName Name of the variable.
  29165. * @param vector2 vector2 to be set.
  29166. * @returns this effect.
  29167. */
  29168. setVector2(uniformName: string, vector2: Vector2): Effect;
  29169. /**
  29170. * Sets a float2 on a uniform variable.
  29171. * @param uniformName Name of the variable.
  29172. * @param x First float in float2.
  29173. * @param y Second float in float2.
  29174. * @returns this effect.
  29175. */
  29176. setFloat2(uniformName: string, x: number, y: number): Effect;
  29177. /**
  29178. * Sets a Vector3 on a uniform variable.
  29179. * @param uniformName Name of the variable.
  29180. * @param vector3 Value to be set.
  29181. * @returns this effect.
  29182. */
  29183. setVector3(uniformName: string, vector3: Vector3): Effect;
  29184. /**
  29185. * Sets a float3 on a uniform variable.
  29186. * @param uniformName Name of the variable.
  29187. * @param x First float in float3.
  29188. * @param y Second float in float3.
  29189. * @param z Third float in float3.
  29190. * @returns this effect.
  29191. */
  29192. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29193. /**
  29194. * Sets a Vector4 on a uniform variable.
  29195. * @param uniformName Name of the variable.
  29196. * @param vector4 Value to be set.
  29197. * @returns this effect.
  29198. */
  29199. setVector4(uniformName: string, vector4: Vector4): Effect;
  29200. /**
  29201. * Sets a float4 on a uniform variable.
  29202. * @param uniformName Name of the variable.
  29203. * @param x First float in float4.
  29204. * @param y Second float in float4.
  29205. * @param z Third float in float4.
  29206. * @param w Fourth float in float4.
  29207. * @returns this effect.
  29208. */
  29209. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29210. /**
  29211. * Sets a Color3 on a uniform variable.
  29212. * @param uniformName Name of the variable.
  29213. * @param color3 Value to be set.
  29214. * @returns this effect.
  29215. */
  29216. setColor3(uniformName: string, color3: Color3): Effect;
  29217. /**
  29218. * Sets a Color4 on a uniform variable.
  29219. * @param uniformName Name of the variable.
  29220. * @param color3 Value to be set.
  29221. * @param alpha Alpha value to be set.
  29222. * @returns this effect.
  29223. */
  29224. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29225. /**
  29226. * Sets a Color4 on a uniform variable
  29227. * @param uniformName defines the name of the variable
  29228. * @param color4 defines the value to be set
  29229. * @returns this effect.
  29230. */
  29231. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29232. /**
  29233. * This function will add a new shader to the shader store
  29234. * @param name the name of the shader
  29235. * @param pixelShader optional pixel shader content
  29236. * @param vertexShader optional vertex shader content
  29237. */
  29238. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29239. /**
  29240. * Store of each shader (The can be looked up using effect.key)
  29241. */
  29242. static ShadersStore: {
  29243. [key: string]: string;
  29244. };
  29245. /**
  29246. * Store of each included file for a shader (The can be looked up using effect.key)
  29247. */
  29248. static IncludesShadersStore: {
  29249. [key: string]: string;
  29250. };
  29251. /**
  29252. * Resets the cache of effects.
  29253. */
  29254. static ResetCache(): void;
  29255. }
  29256. }
  29257. declare module "babylonjs/Materials/colorCurves" {
  29258. import { Effect } from "babylonjs/Materials/effect";
  29259. /**
  29260. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29261. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29262. * 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;
  29263. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29264. */
  29265. export class ColorCurves {
  29266. private _dirty;
  29267. private _tempColor;
  29268. private _globalCurve;
  29269. private _highlightsCurve;
  29270. private _midtonesCurve;
  29271. private _shadowsCurve;
  29272. private _positiveCurve;
  29273. private _negativeCurve;
  29274. private _globalHue;
  29275. private _globalDensity;
  29276. private _globalSaturation;
  29277. private _globalExposure;
  29278. /**
  29279. * Gets the global Hue value.
  29280. * 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).
  29281. */
  29282. /**
  29283. * Sets the global Hue value.
  29284. * 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).
  29285. */
  29286. globalHue: number;
  29287. /**
  29288. * Gets the global Density value.
  29289. * 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.
  29290. * Values less than zero provide a filter of opposite hue.
  29291. */
  29292. /**
  29293. * Sets the global Density value.
  29294. * 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.
  29295. * Values less than zero provide a filter of opposite hue.
  29296. */
  29297. globalDensity: number;
  29298. /**
  29299. * Gets the global Saturation value.
  29300. * 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.
  29301. */
  29302. /**
  29303. * Sets the global Saturation value.
  29304. * 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.
  29305. */
  29306. globalSaturation: number;
  29307. /**
  29308. * Gets the global Exposure value.
  29309. * 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.
  29310. */
  29311. /**
  29312. * Sets the global Exposure value.
  29313. * 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.
  29314. */
  29315. globalExposure: number;
  29316. private _highlightsHue;
  29317. private _highlightsDensity;
  29318. private _highlightsSaturation;
  29319. private _highlightsExposure;
  29320. /**
  29321. * Gets the highlights Hue value.
  29322. * 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).
  29323. */
  29324. /**
  29325. * Sets the highlights Hue value.
  29326. * 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).
  29327. */
  29328. highlightsHue: number;
  29329. /**
  29330. * Gets the highlights Density value.
  29331. * 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.
  29332. * Values less than zero provide a filter of opposite hue.
  29333. */
  29334. /**
  29335. * Sets the highlights Density value.
  29336. * 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.
  29337. * Values less than zero provide a filter of opposite hue.
  29338. */
  29339. highlightsDensity: number;
  29340. /**
  29341. * Gets the highlights Saturation value.
  29342. * 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.
  29343. */
  29344. /**
  29345. * Sets the highlights Saturation value.
  29346. * 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.
  29347. */
  29348. highlightsSaturation: number;
  29349. /**
  29350. * Gets the highlights Exposure value.
  29351. * 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.
  29352. */
  29353. /**
  29354. * Sets the highlights Exposure value.
  29355. * 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.
  29356. */
  29357. highlightsExposure: number;
  29358. private _midtonesHue;
  29359. private _midtonesDensity;
  29360. private _midtonesSaturation;
  29361. private _midtonesExposure;
  29362. /**
  29363. * Gets the midtones Hue value.
  29364. * 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).
  29365. */
  29366. /**
  29367. * Sets the midtones Hue value.
  29368. * 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).
  29369. */
  29370. midtonesHue: number;
  29371. /**
  29372. * Gets the midtones Density value.
  29373. * 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.
  29374. * Values less than zero provide a filter of opposite hue.
  29375. */
  29376. /**
  29377. * Sets the midtones Density value.
  29378. * 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.
  29379. * Values less than zero provide a filter of opposite hue.
  29380. */
  29381. midtonesDensity: number;
  29382. /**
  29383. * Gets the midtones Saturation value.
  29384. * 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.
  29385. */
  29386. /**
  29387. * Sets the midtones Saturation value.
  29388. * 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.
  29389. */
  29390. midtonesSaturation: number;
  29391. /**
  29392. * Gets the midtones Exposure value.
  29393. * 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.
  29394. */
  29395. /**
  29396. * Sets the midtones Exposure value.
  29397. * 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.
  29398. */
  29399. midtonesExposure: number;
  29400. private _shadowsHue;
  29401. private _shadowsDensity;
  29402. private _shadowsSaturation;
  29403. private _shadowsExposure;
  29404. /**
  29405. * Gets the shadows Hue value.
  29406. * 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).
  29407. */
  29408. /**
  29409. * Sets the shadows Hue value.
  29410. * 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).
  29411. */
  29412. shadowsHue: number;
  29413. /**
  29414. * Gets the shadows Density value.
  29415. * 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.
  29416. * Values less than zero provide a filter of opposite hue.
  29417. */
  29418. /**
  29419. * Sets the shadows Density value.
  29420. * 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.
  29421. * Values less than zero provide a filter of opposite hue.
  29422. */
  29423. shadowsDensity: number;
  29424. /**
  29425. * Gets the shadows Saturation value.
  29426. * 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.
  29427. */
  29428. /**
  29429. * Sets the shadows Saturation value.
  29430. * 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.
  29431. */
  29432. shadowsSaturation: number;
  29433. /**
  29434. * Gets the shadows Exposure value.
  29435. * 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.
  29436. */
  29437. /**
  29438. * Sets the shadows Exposure value.
  29439. * 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.
  29440. */
  29441. shadowsExposure: number;
  29442. /**
  29443. * Returns the class name
  29444. * @returns The class name
  29445. */
  29446. getClassName(): string;
  29447. /**
  29448. * Binds the color curves to the shader.
  29449. * @param colorCurves The color curve to bind
  29450. * @param effect The effect to bind to
  29451. * @param positiveUniform The positive uniform shader parameter
  29452. * @param neutralUniform The neutral uniform shader parameter
  29453. * @param negativeUniform The negative uniform shader parameter
  29454. */
  29455. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29456. /**
  29457. * Prepare the list of uniforms associated with the ColorCurves effects.
  29458. * @param uniformsList The list of uniforms used in the effect
  29459. */
  29460. static PrepareUniforms(uniformsList: string[]): void;
  29461. /**
  29462. * Returns color grading data based on a hue, density, saturation and exposure value.
  29463. * @param filterHue The hue of the color filter.
  29464. * @param filterDensity The density of the color filter.
  29465. * @param saturation The saturation.
  29466. * @param exposure The exposure.
  29467. * @param result The result data container.
  29468. */
  29469. private getColorGradingDataToRef;
  29470. /**
  29471. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29472. * @param value The input slider value in range [-100,100].
  29473. * @returns Adjusted value.
  29474. */
  29475. private static applyColorGradingSliderNonlinear;
  29476. /**
  29477. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29478. * @param hue The hue (H) input.
  29479. * @param saturation The saturation (S) input.
  29480. * @param brightness The brightness (B) input.
  29481. * @result An RGBA color represented as Vector4.
  29482. */
  29483. private static fromHSBToRef;
  29484. /**
  29485. * Returns a value clamped between min and max
  29486. * @param value The value to clamp
  29487. * @param min The minimum of value
  29488. * @param max The maximum of value
  29489. * @returns The clamped value.
  29490. */
  29491. private static clamp;
  29492. /**
  29493. * Clones the current color curve instance.
  29494. * @return The cloned curves
  29495. */
  29496. clone(): ColorCurves;
  29497. /**
  29498. * Serializes the current color curve instance to a json representation.
  29499. * @return a JSON representation
  29500. */
  29501. serialize(): any;
  29502. /**
  29503. * Parses the color curve from a json representation.
  29504. * @param source the JSON source to parse
  29505. * @return The parsed curves
  29506. */
  29507. static Parse(source: any): ColorCurves;
  29508. }
  29509. }
  29510. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29511. import { Observable } from "babylonjs/Misc/observable";
  29512. import { Nullable } from "babylonjs/types";
  29513. import { Color4 } from "babylonjs/Maths/math";
  29514. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29515. import { Effect } from "babylonjs/Materials/effect";
  29516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29517. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29518. /**
  29519. * Interface to follow in your material defines to integrate easily the
  29520. * Image proccessing functions.
  29521. * @hidden
  29522. */
  29523. export interface IImageProcessingConfigurationDefines {
  29524. IMAGEPROCESSING: boolean;
  29525. VIGNETTE: boolean;
  29526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29527. VIGNETTEBLENDMODEOPAQUE: boolean;
  29528. TONEMAPPING: boolean;
  29529. TONEMAPPING_ACES: boolean;
  29530. CONTRAST: boolean;
  29531. EXPOSURE: boolean;
  29532. COLORCURVES: boolean;
  29533. COLORGRADING: boolean;
  29534. COLORGRADING3D: boolean;
  29535. SAMPLER3DGREENDEPTH: boolean;
  29536. SAMPLER3DBGRMAP: boolean;
  29537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29538. }
  29539. /**
  29540. * @hidden
  29541. */
  29542. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29543. IMAGEPROCESSING: boolean;
  29544. VIGNETTE: boolean;
  29545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29546. VIGNETTEBLENDMODEOPAQUE: boolean;
  29547. TONEMAPPING: boolean;
  29548. TONEMAPPING_ACES: boolean;
  29549. CONTRAST: boolean;
  29550. COLORCURVES: boolean;
  29551. COLORGRADING: boolean;
  29552. COLORGRADING3D: boolean;
  29553. SAMPLER3DGREENDEPTH: boolean;
  29554. SAMPLER3DBGRMAP: boolean;
  29555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29556. EXPOSURE: boolean;
  29557. constructor();
  29558. }
  29559. /**
  29560. * This groups together the common properties used for image processing either in direct forward pass
  29561. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29562. * or not.
  29563. */
  29564. export class ImageProcessingConfiguration {
  29565. /**
  29566. * Default tone mapping applied in BabylonJS.
  29567. */
  29568. static readonly TONEMAPPING_STANDARD: number;
  29569. /**
  29570. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29571. * to other engines rendering to increase portability.
  29572. */
  29573. static readonly TONEMAPPING_ACES: number;
  29574. /**
  29575. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29576. */
  29577. colorCurves: Nullable<ColorCurves>;
  29578. private _colorCurvesEnabled;
  29579. /**
  29580. * Gets wether the color curves effect is enabled.
  29581. */
  29582. /**
  29583. * Sets wether the color curves effect is enabled.
  29584. */
  29585. colorCurvesEnabled: boolean;
  29586. private _colorGradingTexture;
  29587. /**
  29588. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29589. */
  29590. /**
  29591. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29592. */
  29593. colorGradingTexture: Nullable<BaseTexture>;
  29594. private _colorGradingEnabled;
  29595. /**
  29596. * Gets wether the color grading effect is enabled.
  29597. */
  29598. /**
  29599. * Sets wether the color grading effect is enabled.
  29600. */
  29601. colorGradingEnabled: boolean;
  29602. private _colorGradingWithGreenDepth;
  29603. /**
  29604. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29605. */
  29606. /**
  29607. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29608. */
  29609. colorGradingWithGreenDepth: boolean;
  29610. private _colorGradingBGR;
  29611. /**
  29612. * Gets wether the color grading texture contains BGR values.
  29613. */
  29614. /**
  29615. * Sets wether the color grading texture contains BGR values.
  29616. */
  29617. colorGradingBGR: boolean;
  29618. /** @hidden */
  29619. _exposure: number;
  29620. /**
  29621. * Gets the Exposure used in the effect.
  29622. */
  29623. /**
  29624. * Sets the Exposure used in the effect.
  29625. */
  29626. exposure: number;
  29627. private _toneMappingEnabled;
  29628. /**
  29629. * Gets wether the tone mapping effect is enabled.
  29630. */
  29631. /**
  29632. * Sets wether the tone mapping effect is enabled.
  29633. */
  29634. toneMappingEnabled: boolean;
  29635. private _toneMappingType;
  29636. /**
  29637. * Gets the type of tone mapping effect.
  29638. */
  29639. /**
  29640. * Sets the type of tone mapping effect used in BabylonJS.
  29641. */
  29642. toneMappingType: number;
  29643. protected _contrast: number;
  29644. /**
  29645. * Gets the contrast used in the effect.
  29646. */
  29647. /**
  29648. * Sets the contrast used in the effect.
  29649. */
  29650. contrast: number;
  29651. /**
  29652. * Vignette stretch size.
  29653. */
  29654. vignetteStretch: number;
  29655. /**
  29656. * Vignette centre X Offset.
  29657. */
  29658. vignetteCentreX: number;
  29659. /**
  29660. * Vignette centre Y Offset.
  29661. */
  29662. vignetteCentreY: number;
  29663. /**
  29664. * Vignette weight or intensity of the vignette effect.
  29665. */
  29666. vignetteWeight: number;
  29667. /**
  29668. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29669. * if vignetteEnabled is set to true.
  29670. */
  29671. vignetteColor: Color4;
  29672. /**
  29673. * Camera field of view used by the Vignette effect.
  29674. */
  29675. vignetteCameraFov: number;
  29676. private _vignetteBlendMode;
  29677. /**
  29678. * Gets the vignette blend mode allowing different kind of effect.
  29679. */
  29680. /**
  29681. * Sets the vignette blend mode allowing different kind of effect.
  29682. */
  29683. vignetteBlendMode: number;
  29684. private _vignetteEnabled;
  29685. /**
  29686. * Gets wether the vignette effect is enabled.
  29687. */
  29688. /**
  29689. * Sets wether the vignette effect is enabled.
  29690. */
  29691. vignetteEnabled: boolean;
  29692. private _applyByPostProcess;
  29693. /**
  29694. * Gets wether the image processing is applied through a post process or not.
  29695. */
  29696. /**
  29697. * Sets wether the image processing is applied through a post process or not.
  29698. */
  29699. applyByPostProcess: boolean;
  29700. private _isEnabled;
  29701. /**
  29702. * Gets wether the image processing is enabled or not.
  29703. */
  29704. /**
  29705. * Sets wether the image processing is enabled or not.
  29706. */
  29707. isEnabled: boolean;
  29708. /**
  29709. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29710. */
  29711. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29712. /**
  29713. * Method called each time the image processing information changes requires to recompile the effect.
  29714. */
  29715. protected _updateParameters(): void;
  29716. /**
  29717. * Gets the current class name.
  29718. * @return "ImageProcessingConfiguration"
  29719. */
  29720. getClassName(): string;
  29721. /**
  29722. * Prepare the list of uniforms associated with the Image Processing effects.
  29723. * @param uniforms The list of uniforms used in the effect
  29724. * @param defines the list of defines currently in use
  29725. */
  29726. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29727. /**
  29728. * Prepare the list of samplers associated with the Image Processing effects.
  29729. * @param samplersList The list of uniforms used in the effect
  29730. * @param defines the list of defines currently in use
  29731. */
  29732. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29733. /**
  29734. * Prepare the list of defines associated to the shader.
  29735. * @param defines the list of defines to complete
  29736. * @param forPostProcess Define if we are currently in post process mode or not
  29737. */
  29738. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29739. /**
  29740. * Returns true if all the image processing information are ready.
  29741. * @returns True if ready, otherwise, false
  29742. */
  29743. isReady(): boolean;
  29744. /**
  29745. * Binds the image processing to the shader.
  29746. * @param effect The effect to bind to
  29747. * @param aspectRatio Define the current aspect ratio of the effect
  29748. */
  29749. bind(effect: Effect, aspectRatio?: number): void;
  29750. /**
  29751. * Clones the current image processing instance.
  29752. * @return The cloned image processing
  29753. */
  29754. clone(): ImageProcessingConfiguration;
  29755. /**
  29756. * Serializes the current image processing instance to a json representation.
  29757. * @return a JSON representation
  29758. */
  29759. serialize(): any;
  29760. /**
  29761. * Parses the image processing from a json representation.
  29762. * @param source the JSON source to parse
  29763. * @return The parsed image processing
  29764. */
  29765. static Parse(source: any): ImageProcessingConfiguration;
  29766. private static _VIGNETTEMODE_MULTIPLY;
  29767. private static _VIGNETTEMODE_OPAQUE;
  29768. /**
  29769. * Used to apply the vignette as a mix with the pixel color.
  29770. */
  29771. static readonly VIGNETTEMODE_MULTIPLY: number;
  29772. /**
  29773. * Used to apply the vignette as a replacement of the pixel color.
  29774. */
  29775. static readonly VIGNETTEMODE_OPAQUE: number;
  29776. }
  29777. }
  29778. declare module "babylonjs/Materials/fresnelParameters" {
  29779. import { Color3 } from "babylonjs/Maths/math";
  29780. /**
  29781. * This represents all the required information to add a fresnel effect on a material:
  29782. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29783. */
  29784. export class FresnelParameters {
  29785. private _isEnabled;
  29786. /**
  29787. * Define if the fresnel effect is enable or not.
  29788. */
  29789. isEnabled: boolean;
  29790. /**
  29791. * Define the color used on edges (grazing angle)
  29792. */
  29793. leftColor: Color3;
  29794. /**
  29795. * Define the color used on center
  29796. */
  29797. rightColor: Color3;
  29798. /**
  29799. * Define bias applied to computed fresnel term
  29800. */
  29801. bias: number;
  29802. /**
  29803. * Defined the power exponent applied to fresnel term
  29804. */
  29805. power: number;
  29806. /**
  29807. * Clones the current fresnel and its valuues
  29808. * @returns a clone fresnel configuration
  29809. */
  29810. clone(): FresnelParameters;
  29811. /**
  29812. * Serializes the current fresnel parameters to a JSON representation.
  29813. * @return the JSON serialization
  29814. */
  29815. serialize(): any;
  29816. /**
  29817. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29818. * @param parsedFresnelParameters Define the JSON representation
  29819. * @returns the parsed parameters
  29820. */
  29821. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29822. }
  29823. }
  29824. declare module "babylonjs/Misc/decorators" {
  29825. import { Nullable } from "babylonjs/types";
  29826. import { Scene } from "babylonjs/scene";
  29827. import { IAnimatable } from "babylonjs/Misc/tools";
  29828. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29829. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29830. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29831. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29832. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29833. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29834. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29835. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29836. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29837. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29838. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29839. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29840. /**
  29841. * Decorator used to define property that can be serialized as reference to a camera
  29842. * @param sourceName defines the name of the property to decorate
  29843. */
  29844. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29845. /**
  29846. * Class used to help serialization objects
  29847. */
  29848. export class SerializationHelper {
  29849. /** hidden */
  29850. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29851. /** hidden */
  29852. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29853. /** hidden */
  29854. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29855. /** hidden */
  29856. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29857. /**
  29858. * Appends the serialized animations from the source animations
  29859. * @param source Source containing the animations
  29860. * @param destination Target to store the animations
  29861. */
  29862. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29863. /**
  29864. * Static function used to serialized a specific entity
  29865. * @param entity defines the entity to serialize
  29866. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29867. * @returns a JSON compatible object representing the serialization of the entity
  29868. */
  29869. static Serialize<T>(entity: T, serializationObject?: any): any;
  29870. /**
  29871. * Creates a new entity from a serialization data object
  29872. * @param creationFunction defines a function used to instanciated the new entity
  29873. * @param source defines the source serialization data
  29874. * @param scene defines the hosting scene
  29875. * @param rootUrl defines the root url for resources
  29876. * @returns a new entity
  29877. */
  29878. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29879. /**
  29880. * Clones an object
  29881. * @param creationFunction defines the function used to instanciate the new object
  29882. * @param source defines the source object
  29883. * @returns the cloned object
  29884. */
  29885. static Clone<T>(creationFunction: () => T, source: T): T;
  29886. /**
  29887. * Instanciates a new object based on a source one (some data will be shared between both object)
  29888. * @param creationFunction defines the function used to instanciate the new object
  29889. * @param source defines the source object
  29890. * @returns the new object
  29891. */
  29892. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29893. }
  29894. }
  29895. declare module "babylonjs/Cameras/camera" {
  29896. import { SmartArray } from "babylonjs/Misc/smartArray";
  29897. import { Observable } from "babylonjs/Misc/observable";
  29898. import { Nullable } from "babylonjs/types";
  29899. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29900. import { Scene } from "babylonjs/scene";
  29901. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  29902. import { Node } from "babylonjs/node";
  29903. import { Mesh } from "babylonjs/Meshes/mesh";
  29904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29905. import { Ray } from "babylonjs/Culling/ray";
  29906. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29908. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29909. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29910. /**
  29911. * This is the base class of all the camera used in the application.
  29912. * @see http://doc.babylonjs.com/features/cameras
  29913. */
  29914. export class Camera extends Node {
  29915. /** @hidden */
  29916. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29917. /**
  29918. * This is the default projection mode used by the cameras.
  29919. * It helps recreating a feeling of perspective and better appreciate depth.
  29920. * This is the best way to simulate real life cameras.
  29921. */
  29922. static readonly PERSPECTIVE_CAMERA: number;
  29923. /**
  29924. * This helps creating camera with an orthographic mode.
  29925. * 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.
  29926. */
  29927. static readonly ORTHOGRAPHIC_CAMERA: number;
  29928. /**
  29929. * This is the default FOV mode for perspective cameras.
  29930. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29931. */
  29932. static readonly FOVMODE_VERTICAL_FIXED: number;
  29933. /**
  29934. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29935. */
  29936. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29937. /**
  29938. * This specifies ther is no need for a camera rig.
  29939. * Basically only one eye is rendered corresponding to the camera.
  29940. */
  29941. static readonly RIG_MODE_NONE: number;
  29942. /**
  29943. * Simulates a camera Rig with one blue eye and one red eye.
  29944. * This can be use with 3d blue and red glasses.
  29945. */
  29946. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29947. /**
  29948. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29949. */
  29950. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29951. /**
  29952. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29953. */
  29954. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29955. /**
  29956. * Defines that both eyes of the camera will be rendered over under each other.
  29957. */
  29958. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29959. /**
  29960. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29961. */
  29962. static readonly RIG_MODE_VR: number;
  29963. /**
  29964. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29965. */
  29966. static readonly RIG_MODE_WEBVR: number;
  29967. /**
  29968. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29969. */
  29970. static readonly RIG_MODE_CUSTOM: number;
  29971. /**
  29972. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29973. */
  29974. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29975. /**
  29976. * @hidden
  29977. * Might be removed once multiview will be a thing
  29978. */
  29979. static UseAlternateWebVRRendering: boolean;
  29980. /**
  29981. * Define the input manager associated with the camera.
  29982. */
  29983. inputs: CameraInputsManager<Camera>;
  29984. /**
  29985. * Define the current local position of the camera in the scene
  29986. */
  29987. position: Vector3;
  29988. /**
  29989. * The vector the camera should consider as up.
  29990. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29991. */
  29992. upVector: Vector3;
  29993. /**
  29994. * Define the current limit on the left side for an orthographic camera
  29995. * In scene unit
  29996. */
  29997. orthoLeft: Nullable<number>;
  29998. /**
  29999. * Define the current limit on the right side for an orthographic camera
  30000. * In scene unit
  30001. */
  30002. orthoRight: Nullable<number>;
  30003. /**
  30004. * Define the current limit on the bottom side for an orthographic camera
  30005. * In scene unit
  30006. */
  30007. orthoBottom: Nullable<number>;
  30008. /**
  30009. * Define the current limit on the top side for an orthographic camera
  30010. * In scene unit
  30011. */
  30012. orthoTop: Nullable<number>;
  30013. /**
  30014. * Field Of View is set in Radians. (default is 0.8)
  30015. */
  30016. fov: number;
  30017. /**
  30018. * Define the minimum distance the camera can see from.
  30019. * This is important to note that the depth buffer are not infinite and the closer it starts
  30020. * the more your scene might encounter depth fighting issue.
  30021. */
  30022. minZ: number;
  30023. /**
  30024. * Define the maximum distance the camera can see to.
  30025. * This is important to note that the depth buffer are not infinite and the further it end
  30026. * the more your scene might encounter depth fighting issue.
  30027. */
  30028. maxZ: number;
  30029. /**
  30030. * Define the default inertia of the camera.
  30031. * This helps giving a smooth feeling to the camera movement.
  30032. */
  30033. inertia: number;
  30034. /**
  30035. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30036. */
  30037. mode: number;
  30038. /**
  30039. * Define wether the camera is intermediate.
  30040. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30041. */
  30042. isIntermediate: boolean;
  30043. /**
  30044. * Define the viewport of the camera.
  30045. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30046. */
  30047. viewport: Viewport;
  30048. /**
  30049. * Restricts the camera to viewing objects with the same layerMask.
  30050. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30051. */
  30052. layerMask: number;
  30053. /**
  30054. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30055. */
  30056. fovMode: number;
  30057. /**
  30058. * Rig mode of the camera.
  30059. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30060. * This is normally controlled byt the camera themselves as internal use.
  30061. */
  30062. cameraRigMode: number;
  30063. /**
  30064. * Defines the distance between both "eyes" in case of a RIG
  30065. */
  30066. interaxialDistance: number;
  30067. /**
  30068. * Defines if stereoscopic rendering is done side by side or over under.
  30069. */
  30070. isStereoscopicSideBySide: boolean;
  30071. /**
  30072. * 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
  30073. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30074. * else in the scene.
  30075. */
  30076. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30077. /**
  30078. * When set, the camera will render to this render target instead of the default canvas
  30079. */
  30080. outputRenderTarget: Nullable<RenderTargetTexture>;
  30081. /**
  30082. * Observable triggered when the camera view matrix has changed.
  30083. */
  30084. onViewMatrixChangedObservable: Observable<Camera>;
  30085. /**
  30086. * Observable triggered when the camera Projection matrix has changed.
  30087. */
  30088. onProjectionMatrixChangedObservable: Observable<Camera>;
  30089. /**
  30090. * Observable triggered when the inputs have been processed.
  30091. */
  30092. onAfterCheckInputsObservable: Observable<Camera>;
  30093. /**
  30094. * Observable triggered when reset has been called and applied to the camera.
  30095. */
  30096. onRestoreStateObservable: Observable<Camera>;
  30097. /** @hidden */
  30098. _cameraRigParams: any;
  30099. /** @hidden */
  30100. _rigCameras: Camera[];
  30101. /** @hidden */
  30102. _rigPostProcess: Nullable<PostProcess>;
  30103. protected _webvrViewMatrix: Matrix;
  30104. /** @hidden */
  30105. _skipRendering: boolean;
  30106. /** @hidden */
  30107. _alternateCamera: Camera;
  30108. /** @hidden */
  30109. _projectionMatrix: Matrix;
  30110. /** @hidden */
  30111. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30112. /** @hidden */
  30113. _activeMeshes: SmartArray<AbstractMesh>;
  30114. protected _globalPosition: Vector3;
  30115. /** hidden */
  30116. _computedViewMatrix: Matrix;
  30117. private _doNotComputeProjectionMatrix;
  30118. private _transformMatrix;
  30119. private _frustumPlanes;
  30120. private _refreshFrustumPlanes;
  30121. private _storedFov;
  30122. private _stateStored;
  30123. /**
  30124. * Instantiates a new camera object.
  30125. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30126. * @see http://doc.babylonjs.com/features/cameras
  30127. * @param name Defines the name of the camera in the scene
  30128. * @param position Defines the position of the camera
  30129. * @param scene Defines the scene the camera belongs too
  30130. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30131. */
  30132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30133. /**
  30134. * Store current camera state (fov, position, etc..)
  30135. * @returns the camera
  30136. */
  30137. storeState(): Camera;
  30138. /**
  30139. * Restores the camera state values if it has been stored. You must call storeState() first
  30140. */
  30141. protected _restoreStateValues(): boolean;
  30142. /**
  30143. * Restored camera state. You must call storeState() first.
  30144. * @returns true if restored and false otherwise
  30145. */
  30146. restoreState(): boolean;
  30147. /**
  30148. * Gets the class name of the camera.
  30149. * @returns the class name
  30150. */
  30151. getClassName(): string;
  30152. /** @hidden */
  30153. readonly _isCamera: boolean;
  30154. /**
  30155. * Gets a string representation of the camera useful for debug purpose.
  30156. * @param fullDetails Defines that a more verboe level of logging is required
  30157. * @returns the string representation
  30158. */
  30159. toString(fullDetails?: boolean): string;
  30160. /**
  30161. * Gets the current world space position of the camera.
  30162. */
  30163. readonly globalPosition: Vector3;
  30164. /**
  30165. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30166. * @returns the active meshe list
  30167. */
  30168. getActiveMeshes(): SmartArray<AbstractMesh>;
  30169. /**
  30170. * Check wether a mesh is part of the current active mesh list of the camera
  30171. * @param mesh Defines the mesh to check
  30172. * @returns true if active, false otherwise
  30173. */
  30174. isActiveMesh(mesh: Mesh): boolean;
  30175. /**
  30176. * Is this camera ready to be used/rendered
  30177. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30178. * @return true if the camera is ready
  30179. */
  30180. isReady(completeCheck?: boolean): boolean;
  30181. /** @hidden */
  30182. _initCache(): void;
  30183. /** @hidden */
  30184. _updateCache(ignoreParentClass?: boolean): void;
  30185. /** @hidden */
  30186. _isSynchronized(): boolean;
  30187. /** @hidden */
  30188. _isSynchronizedViewMatrix(): boolean;
  30189. /** @hidden */
  30190. _isSynchronizedProjectionMatrix(): boolean;
  30191. /**
  30192. * Attach the input controls to a specific dom element to get the input from.
  30193. * @param element Defines the element the controls should be listened from
  30194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30195. */
  30196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30197. /**
  30198. * Detach the current controls from the specified dom element.
  30199. * @param element Defines the element to stop listening the inputs from
  30200. */
  30201. detachControl(element: HTMLElement): void;
  30202. /**
  30203. * Update the camera state according to the different inputs gathered during the frame.
  30204. */
  30205. update(): void;
  30206. /** @hidden */
  30207. _checkInputs(): void;
  30208. /** @hidden */
  30209. readonly rigCameras: Camera[];
  30210. /**
  30211. * Gets the post process used by the rig cameras
  30212. */
  30213. readonly rigPostProcess: Nullable<PostProcess>;
  30214. /**
  30215. * Internal, gets the first post proces.
  30216. * @returns the first post process to be run on this camera.
  30217. */
  30218. _getFirstPostProcess(): Nullable<PostProcess>;
  30219. private _cascadePostProcessesToRigCams;
  30220. /**
  30221. * Attach a post process to the camera.
  30222. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30223. * @param postProcess The post process to attach to the camera
  30224. * @param insertAt The position of the post process in case several of them are in use in the scene
  30225. * @returns the position the post process has been inserted at
  30226. */
  30227. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30228. /**
  30229. * Detach a post process to the camera.
  30230. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30231. * @param postProcess The post process to detach from the camera
  30232. */
  30233. detachPostProcess(postProcess: PostProcess): void;
  30234. /**
  30235. * Gets the current world matrix of the camera
  30236. */
  30237. getWorldMatrix(): Matrix;
  30238. /** @hidden */
  30239. _getViewMatrix(): Matrix;
  30240. /**
  30241. * Gets the current view matrix of the camera.
  30242. * @param force forces the camera to recompute the matrix without looking at the cached state
  30243. * @returns the view matrix
  30244. */
  30245. getViewMatrix(force?: boolean): Matrix;
  30246. /**
  30247. * Freeze the projection matrix.
  30248. * It will prevent the cache check of the camera projection compute and can speed up perf
  30249. * if no parameter of the camera are meant to change
  30250. * @param projection Defines manually a projection if necessary
  30251. */
  30252. freezeProjectionMatrix(projection?: Matrix): void;
  30253. /**
  30254. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30255. */
  30256. unfreezeProjectionMatrix(): void;
  30257. /**
  30258. * Gets the current projection matrix of the camera.
  30259. * @param force forces the camera to recompute the matrix without looking at the cached state
  30260. * @returns the projection matrix
  30261. */
  30262. getProjectionMatrix(force?: boolean): Matrix;
  30263. /**
  30264. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30265. * @returns a Matrix
  30266. */
  30267. getTransformationMatrix(): Matrix;
  30268. private _updateFrustumPlanes;
  30269. /**
  30270. * Checks if a cullable object (mesh...) is in the camera frustum
  30271. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30272. * @param target The object to check
  30273. * @returns true if the object is in frustum otherwise false
  30274. */
  30275. isInFrustum(target: ICullable): boolean;
  30276. /**
  30277. * Checks if a cullable object (mesh...) is in the camera frustum
  30278. * Unlike isInFrustum this cheks the full bounding box
  30279. * @param target The object to check
  30280. * @returns true if the object is in frustum otherwise false
  30281. */
  30282. isCompletelyInFrustum(target: ICullable): boolean;
  30283. /**
  30284. * Gets a ray in the forward direction from the camera.
  30285. * @param length Defines the length of the ray to create
  30286. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30287. * @param origin Defines the start point of the ray which defaults to the camera position
  30288. * @returns the forward ray
  30289. */
  30290. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30291. /**
  30292. * Releases resources associated with this node.
  30293. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30294. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30295. */
  30296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30297. /**
  30298. * Gets the left camera of a rig setup in case of Rigged Camera
  30299. */
  30300. readonly leftCamera: Nullable<FreeCamera>;
  30301. /**
  30302. * Gets the right camera of a rig setup in case of Rigged Camera
  30303. */
  30304. readonly rightCamera: Nullable<FreeCamera>;
  30305. /**
  30306. * Gets the left camera target of a rig setup in case of Rigged Camera
  30307. * @returns the target position
  30308. */
  30309. getLeftTarget(): Nullable<Vector3>;
  30310. /**
  30311. * Gets the right camera target of a rig setup in case of Rigged Camera
  30312. * @returns the target position
  30313. */
  30314. getRightTarget(): Nullable<Vector3>;
  30315. /**
  30316. * @hidden
  30317. */
  30318. setCameraRigMode(mode: number, rigParams: any): void;
  30319. /** @hidden */
  30320. static _setStereoscopicRigMode(camera: Camera): void;
  30321. /** @hidden */
  30322. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30323. /** @hidden */
  30324. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30325. /** @hidden */
  30326. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30327. /** @hidden */
  30328. _getVRProjectionMatrix(): Matrix;
  30329. protected _updateCameraRotationMatrix(): void;
  30330. protected _updateWebVRCameraRotationMatrix(): void;
  30331. /**
  30332. * This function MUST be overwritten by the different WebVR cameras available.
  30333. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30334. * @hidden
  30335. */
  30336. _getWebVRProjectionMatrix(): Matrix;
  30337. /**
  30338. * This function MUST be overwritten by the different WebVR cameras available.
  30339. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30340. * @hidden
  30341. */
  30342. _getWebVRViewMatrix(): Matrix;
  30343. /** @hidden */
  30344. setCameraRigParameter(name: string, value: any): void;
  30345. /**
  30346. * needs to be overridden by children so sub has required properties to be copied
  30347. * @hidden
  30348. */
  30349. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30350. /**
  30351. * May need to be overridden by children
  30352. * @hidden
  30353. */
  30354. _updateRigCameras(): void;
  30355. /** @hidden */
  30356. _setupInputs(): void;
  30357. /**
  30358. * Serialiaze the camera setup to a json represention
  30359. * @returns the JSON representation
  30360. */
  30361. serialize(): any;
  30362. /**
  30363. * Clones the current camera.
  30364. * @param name The cloned camera name
  30365. * @returns the cloned camera
  30366. */
  30367. clone(name: string): Camera;
  30368. /**
  30369. * Gets the direction of the camera relative to a given local axis.
  30370. * @param localAxis Defines the reference axis to provide a relative direction.
  30371. * @return the direction
  30372. */
  30373. getDirection(localAxis: Vector3): Vector3;
  30374. /**
  30375. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30376. * @param localAxis Defines the reference axis to provide a relative direction.
  30377. * @param result Defines the vector to store the result in
  30378. */
  30379. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30380. /**
  30381. * Gets a camera constructor for a given camera type
  30382. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30383. * @param name The name of the camera the result will be able to instantiate
  30384. * @param scene The scene the result will construct the camera in
  30385. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30386. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30387. * @returns a factory method to construc the camera
  30388. */
  30389. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30390. /**
  30391. * Compute the world matrix of the camera.
  30392. * @returns the camera workd matrix
  30393. */
  30394. computeWorldMatrix(): Matrix;
  30395. /**
  30396. * Parse a JSON and creates the camera from the parsed information
  30397. * @param parsedCamera The JSON to parse
  30398. * @param scene The scene to instantiate the camera in
  30399. * @returns the newly constructed camera
  30400. */
  30401. static Parse(parsedCamera: any, scene: Scene): Camera;
  30402. }
  30403. }
  30404. declare module "babylonjs/Misc/tools" {
  30405. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30406. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30407. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30408. import { Observable } from "babylonjs/Misc/observable";
  30409. import { DomManagement } from "babylonjs/Misc/domManagement";
  30410. import { Camera } from "babylonjs/Cameras/camera";
  30411. import { Engine } from "babylonjs/Engines/engine";
  30412. import { Animation } from "babylonjs/Animations/animation";
  30413. /**
  30414. * Interface for any object that can request an animation frame
  30415. */
  30416. export interface ICustomAnimationFrameRequester {
  30417. /**
  30418. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30419. */
  30420. renderFunction?: Function;
  30421. /**
  30422. * Called to request the next frame to render to
  30423. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30424. */
  30425. requestAnimationFrame: Function;
  30426. /**
  30427. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30428. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30429. */
  30430. requestID?: number;
  30431. }
  30432. /**
  30433. * Interface containing an array of animations
  30434. */
  30435. export interface IAnimatable {
  30436. /**
  30437. * Array of animations
  30438. */
  30439. animations: Array<Animation>;
  30440. }
  30441. /** Interface used by value gradients (color, factor, ...) */
  30442. export interface IValueGradient {
  30443. /**
  30444. * Gets or sets the gradient value (between 0 and 1)
  30445. */
  30446. gradient: number;
  30447. }
  30448. /** Class used to store color4 gradient */
  30449. export class ColorGradient implements IValueGradient {
  30450. /**
  30451. * Gets or sets the gradient value (between 0 and 1)
  30452. */
  30453. gradient: number;
  30454. /**
  30455. * Gets or sets first associated color
  30456. */
  30457. color1: Color4;
  30458. /**
  30459. * Gets or sets second associated color
  30460. */
  30461. color2?: Color4;
  30462. /**
  30463. * Will get a color picked randomly between color1 and color2.
  30464. * If color2 is undefined then color1 will be used
  30465. * @param result defines the target Color4 to store the result in
  30466. */
  30467. getColorToRef(result: Color4): void;
  30468. }
  30469. /** Class used to store color 3 gradient */
  30470. export class Color3Gradient implements IValueGradient {
  30471. /**
  30472. * Gets or sets the gradient value (between 0 and 1)
  30473. */
  30474. gradient: number;
  30475. /**
  30476. * Gets or sets the associated color
  30477. */
  30478. color: Color3;
  30479. }
  30480. /** Class used to store factor gradient */
  30481. export class FactorGradient implements IValueGradient {
  30482. /**
  30483. * Gets or sets the gradient value (between 0 and 1)
  30484. */
  30485. gradient: number;
  30486. /**
  30487. * Gets or sets first associated factor
  30488. */
  30489. factor1: number;
  30490. /**
  30491. * Gets or sets second associated factor
  30492. */
  30493. factor2?: number;
  30494. /**
  30495. * Will get a number picked randomly between factor1 and factor2.
  30496. * If factor2 is undefined then factor1 will be used
  30497. * @returns the picked number
  30498. */
  30499. getFactor(): number;
  30500. }
  30501. /**
  30502. * @ignore
  30503. * Application error to support additional information when loading a file
  30504. */
  30505. export class LoadFileError extends Error {
  30506. /** defines the optional XHR request */
  30507. request?: XMLHttpRequest | undefined;
  30508. private static _setPrototypeOf;
  30509. /**
  30510. * Creates a new LoadFileError
  30511. * @param message defines the message of the error
  30512. * @param request defines the optional XHR request
  30513. */
  30514. constructor(message: string,
  30515. /** defines the optional XHR request */
  30516. request?: XMLHttpRequest | undefined);
  30517. }
  30518. /**
  30519. * Class used to define a retry strategy when error happens while loading assets
  30520. */
  30521. export class RetryStrategy {
  30522. /**
  30523. * Function used to defines an exponential back off strategy
  30524. * @param maxRetries defines the maximum number of retries (3 by default)
  30525. * @param baseInterval defines the interval between retries
  30526. * @returns the strategy function to use
  30527. */
  30528. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30529. }
  30530. /**
  30531. * File request interface
  30532. */
  30533. export interface IFileRequest {
  30534. /**
  30535. * Raised when the request is complete (success or error).
  30536. */
  30537. onCompleteObservable: Observable<IFileRequest>;
  30538. /**
  30539. * Aborts the request for a file.
  30540. */
  30541. abort: () => void;
  30542. }
  30543. /**
  30544. * Class containing a set of static utilities functions
  30545. */
  30546. export class Tools {
  30547. /**
  30548. * Gets or sets the base URL to use to load assets
  30549. */
  30550. static BaseUrl: string;
  30551. /**
  30552. * Enable/Disable Custom HTTP Request Headers globally.
  30553. * default = false
  30554. * @see CustomRequestHeaders
  30555. */
  30556. static UseCustomRequestHeaders: boolean;
  30557. /**
  30558. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30559. * i.e. when loading files, where the server/service expects an Authorization header.
  30560. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30561. */
  30562. static CustomRequestHeaders: {
  30563. [key: string]: string;
  30564. };
  30565. /**
  30566. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30567. */
  30568. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30569. /**
  30570. * Default behaviour for cors in the application.
  30571. * It can be a string if the expected behavior is identical in the entire app.
  30572. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30573. */
  30574. static CorsBehavior: string | ((url: string | string[]) => string);
  30575. /**
  30576. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30577. * @ignorenaming
  30578. */
  30579. static UseFallbackTexture: boolean;
  30580. /**
  30581. * Use this object to register external classes like custom textures or material
  30582. * to allow the laoders to instantiate them
  30583. */
  30584. static RegisteredExternalClasses: {
  30585. [key: string]: Object;
  30586. };
  30587. /**
  30588. * Texture content used if a texture cannot loaded
  30589. * @ignorenaming
  30590. */
  30591. static fallbackTexture: string;
  30592. /**
  30593. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30594. * @param u defines the coordinate on X axis
  30595. * @param v defines the coordinate on Y axis
  30596. * @param width defines the width of the source data
  30597. * @param height defines the height of the source data
  30598. * @param pixels defines the source byte array
  30599. * @param color defines the output color
  30600. */
  30601. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30602. /**
  30603. * Interpolates between a and b via alpha
  30604. * @param a The lower value (returned when alpha = 0)
  30605. * @param b The upper value (returned when alpha = 1)
  30606. * @param alpha The interpolation-factor
  30607. * @return The mixed value
  30608. */
  30609. static Mix(a: number, b: number, alpha: number): number;
  30610. /**
  30611. * Tries to instantiate a new object from a given class name
  30612. * @param className defines the class name to instantiate
  30613. * @returns the new object or null if the system was not able to do the instantiation
  30614. */
  30615. static Instantiate(className: string): any;
  30616. /**
  30617. * Provides a slice function that will work even on IE
  30618. * @param data defines the array to slice
  30619. * @param start defines the start of the data (optional)
  30620. * @param end defines the end of the data (optional)
  30621. * @returns the new sliced array
  30622. */
  30623. static Slice<T>(data: T, start?: number, end?: number): T;
  30624. /**
  30625. * Polyfill for setImmediate
  30626. * @param action defines the action to execute after the current execution block
  30627. */
  30628. static SetImmediate(action: () => void): void;
  30629. /**
  30630. * Function indicating if a number is an exponent of 2
  30631. * @param value defines the value to test
  30632. * @returns true if the value is an exponent of 2
  30633. */
  30634. static IsExponentOfTwo(value: number): boolean;
  30635. private static _tmpFloatArray;
  30636. /**
  30637. * Returns the nearest 32-bit single precision float representation of a Number
  30638. * @param value A Number. If the parameter is of a different type, it will get converted
  30639. * to a number or to NaN if it cannot be converted
  30640. * @returns number
  30641. */
  30642. static FloatRound(value: number): number;
  30643. /**
  30644. * Find the next highest power of two.
  30645. * @param x Number to start search from.
  30646. * @return Next highest power of two.
  30647. */
  30648. static CeilingPOT(x: number): number;
  30649. /**
  30650. * Find the next lowest power of two.
  30651. * @param x Number to start search from.
  30652. * @return Next lowest power of two.
  30653. */
  30654. static FloorPOT(x: number): number;
  30655. /**
  30656. * Find the nearest power of two.
  30657. * @param x Number to start search from.
  30658. * @return Next nearest power of two.
  30659. */
  30660. static NearestPOT(x: number): number;
  30661. /**
  30662. * Get the closest exponent of two
  30663. * @param value defines the value to approximate
  30664. * @param max defines the maximum value to return
  30665. * @param mode defines how to define the closest value
  30666. * @returns closest exponent of two of the given value
  30667. */
  30668. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30669. /**
  30670. * Extracts the filename from a path
  30671. * @param path defines the path to use
  30672. * @returns the filename
  30673. */
  30674. static GetFilename(path: string): string;
  30675. /**
  30676. * Extracts the "folder" part of a path (everything before the filename).
  30677. * @param uri The URI to extract the info from
  30678. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30679. * @returns The "folder" part of the path
  30680. */
  30681. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30682. /**
  30683. * Extracts text content from a DOM element hierarchy
  30684. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30685. */
  30686. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30687. /**
  30688. * Convert an angle in radians to degrees
  30689. * @param angle defines the angle to convert
  30690. * @returns the angle in degrees
  30691. */
  30692. static ToDegrees(angle: number): number;
  30693. /**
  30694. * Convert an angle in degrees to radians
  30695. * @param angle defines the angle to convert
  30696. * @returns the angle in radians
  30697. */
  30698. static ToRadians(angle: number): number;
  30699. /**
  30700. * Encode a buffer to a base64 string
  30701. * @param buffer defines the buffer to encode
  30702. * @returns the encoded string
  30703. */
  30704. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30705. /**
  30706. * Extracts minimum and maximum values from a list of indexed positions
  30707. * @param positions defines the positions to use
  30708. * @param indices defines the indices to the positions
  30709. * @param indexStart defines the start index
  30710. * @param indexCount defines the end index
  30711. * @param bias defines bias value to add to the result
  30712. * @return minimum and maximum values
  30713. */
  30714. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30715. minimum: Vector3;
  30716. maximum: Vector3;
  30717. };
  30718. /**
  30719. * Extracts minimum and maximum values from a list of positions
  30720. * @param positions defines the positions to use
  30721. * @param start defines the start index in the positions array
  30722. * @param count defines the number of positions to handle
  30723. * @param bias defines bias value to add to the result
  30724. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30725. * @return minimum and maximum values
  30726. */
  30727. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30728. minimum: Vector3;
  30729. maximum: Vector3;
  30730. };
  30731. /**
  30732. * Returns an array if obj is not an array
  30733. * @param obj defines the object to evaluate as an array
  30734. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30735. * @returns either obj directly if obj is an array or a new array containing obj
  30736. */
  30737. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30738. /**
  30739. * Gets the pointer prefix to use
  30740. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30741. */
  30742. static GetPointerPrefix(): string;
  30743. /**
  30744. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30745. * @param func - the function to be called
  30746. * @param requester - the object that will request the next frame. Falls back to window.
  30747. * @returns frame number
  30748. */
  30749. static QueueNewFrame(func: () => void, requester?: any): number;
  30750. /**
  30751. * Ask the browser to promote the current element to fullscreen rendering mode
  30752. * @param element defines the DOM element to promote
  30753. */
  30754. static RequestFullscreen(element: HTMLElement): void;
  30755. /**
  30756. * Asks the browser to exit fullscreen mode
  30757. */
  30758. static ExitFullscreen(): void;
  30759. /**
  30760. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30761. * @param url define the url we are trying
  30762. * @param element define the dom element where to configure the cors policy
  30763. */
  30764. static SetCorsBehavior(url: string | string[], element: {
  30765. crossOrigin: string | null;
  30766. }): void;
  30767. /**
  30768. * Removes unwanted characters from an url
  30769. * @param url defines the url to clean
  30770. * @returns the cleaned url
  30771. */
  30772. static CleanUrl(url: string): string;
  30773. /**
  30774. * Gets or sets a function used to pre-process url before using them to load assets
  30775. */
  30776. static PreprocessUrl: (url: string) => string;
  30777. /**
  30778. * Loads an image as an HTMLImageElement.
  30779. * @param input url string, ArrayBuffer, or Blob to load
  30780. * @param onLoad callback called when the image successfully loads
  30781. * @param onError callback called when the image fails to load
  30782. * @param offlineProvider offline provider for caching
  30783. * @returns the HTMLImageElement of the loaded image
  30784. */
  30785. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30786. /**
  30787. * Loads a file
  30788. * @param url url string, ArrayBuffer, or Blob to load
  30789. * @param onSuccess callback called when the file successfully loads
  30790. * @param onProgress callback called while file is loading (if the server supports this mode)
  30791. * @param offlineProvider defines the offline provider for caching
  30792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30793. * @param onError callback called when the file fails to load
  30794. * @returns a file request object
  30795. */
  30796. 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;
  30797. /**
  30798. * Load a script (identified by an url). When the url returns, the
  30799. * content of this file is added into a new script element, attached to the DOM (body element)
  30800. * @param scriptUrl defines the url of the script to laod
  30801. * @param onSuccess defines the callback called when the script is loaded
  30802. * @param onError defines the callback to call if an error occurs
  30803. */
  30804. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30805. /**
  30806. * Loads a file from a blob
  30807. * @param fileToLoad defines the blob to use
  30808. * @param callback defines the callback to call when data is loaded
  30809. * @param progressCallback defines the callback to call during loading process
  30810. * @returns a file request object
  30811. */
  30812. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30813. /**
  30814. * Loads a file
  30815. * @param fileToLoad defines the file to load
  30816. * @param callback defines the callback to call when data is loaded
  30817. * @param progressCallBack defines the callback to call during loading process
  30818. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30819. * @returns a file request object
  30820. */
  30821. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30822. /**
  30823. * Creates a data url from a given string content
  30824. * @param content defines the content to convert
  30825. * @returns the new data url link
  30826. */
  30827. static FileAsURL(content: string): string;
  30828. /**
  30829. * Format the given number to a specific decimal format
  30830. * @param value defines the number to format
  30831. * @param decimals defines the number of decimals to use
  30832. * @returns the formatted string
  30833. */
  30834. static Format(value: number, decimals?: number): string;
  30835. /**
  30836. * Checks if a given vector is inside a specific range
  30837. * @param v defines the vector to test
  30838. * @param min defines the minimum range
  30839. * @param max defines the maximum range
  30840. */
  30841. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30842. /**
  30843. * Tries to copy an object by duplicating every property
  30844. * @param source defines the source object
  30845. * @param destination defines the target object
  30846. * @param doNotCopyList defines a list of properties to avoid
  30847. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30848. */
  30849. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30850. /**
  30851. * Gets a boolean indicating if the given object has no own property
  30852. * @param obj defines the object to test
  30853. * @returns true if object has no own property
  30854. */
  30855. static IsEmpty(obj: any): boolean;
  30856. /**
  30857. * Function used to register events at window level
  30858. * @param events defines the events to register
  30859. */
  30860. static RegisterTopRootEvents(events: {
  30861. name: string;
  30862. handler: Nullable<(e: FocusEvent) => any>;
  30863. }[]): void;
  30864. /**
  30865. * Function used to unregister events from window level
  30866. * @param events defines the events to unregister
  30867. */
  30868. static UnregisterTopRootEvents(events: {
  30869. name: string;
  30870. handler: Nullable<(e: FocusEvent) => any>;
  30871. }[]): void;
  30872. /**
  30873. * Dumps the current bound framebuffer
  30874. * @param width defines the rendering width
  30875. * @param height defines the rendering height
  30876. * @param engine defines the hosting engine
  30877. * @param successCallback defines the callback triggered once the data are available
  30878. * @param mimeType defines the mime type of the result
  30879. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30880. */
  30881. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30882. /**
  30883. * Converts the canvas data to blob.
  30884. * This acts as a polyfill for browsers not supporting the to blob function.
  30885. * @param canvas Defines the canvas to extract the data from
  30886. * @param successCallback Defines the callback triggered once the data are available
  30887. * @param mimeType Defines the mime type of the result
  30888. */
  30889. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30890. /**
  30891. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30892. * @param successCallback defines the callback triggered once the data are available
  30893. * @param mimeType defines the mime type of the result
  30894. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30895. */
  30896. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30897. /**
  30898. * Downloads a blob in the browser
  30899. * @param blob defines the blob to download
  30900. * @param fileName defines the name of the downloaded file
  30901. */
  30902. static Download(blob: Blob, fileName: string): void;
  30903. /**
  30904. * Captures a screenshot of the current rendering
  30905. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30906. * @param engine defines the rendering engine
  30907. * @param camera defines the source camera
  30908. * @param size This parameter can be set to a single number or to an object with the
  30909. * following (optional) properties: precision, width, height. If a single number is passed,
  30910. * it will be used for both width and height. If an object is passed, the screenshot size
  30911. * will be derived from the parameters. The precision property is a multiplier allowing
  30912. * rendering at a higher or lower resolution
  30913. * @param successCallback defines the callback receives a single parameter which contains the
  30914. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30915. * src parameter of an <img> to display it
  30916. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30917. * Check your browser for supported MIME types
  30918. */
  30919. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30920. /**
  30921. * Generates an image screenshot from the specified camera.
  30922. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30923. * @param engine The engine to use for rendering
  30924. * @param camera The camera to use for rendering
  30925. * @param size This parameter can be set to a single number or to an object with the
  30926. * following (optional) properties: precision, width, height. If a single number is passed,
  30927. * it will be used for both width and height. If an object is passed, the screenshot size
  30928. * will be derived from the parameters. The precision property is a multiplier allowing
  30929. * rendering at a higher or lower resolution
  30930. * @param successCallback The callback receives a single parameter which contains the
  30931. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30932. * src parameter of an <img> to display it
  30933. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30934. * Check your browser for supported MIME types
  30935. * @param samples Texture samples (default: 1)
  30936. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30937. * @param fileName A name for for the downloaded file.
  30938. */
  30939. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30940. /**
  30941. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30942. * Be aware Math.random() could cause collisions, but:
  30943. * "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"
  30944. * @returns a pseudo random id
  30945. */
  30946. static RandomId(): string;
  30947. /**
  30948. * Test if the given uri is a base64 string
  30949. * @param uri The uri to test
  30950. * @return True if the uri is a base64 string or false otherwise
  30951. */
  30952. static IsBase64(uri: string): boolean;
  30953. /**
  30954. * Decode the given base64 uri.
  30955. * @param uri The uri to decode
  30956. * @return The decoded base64 data.
  30957. */
  30958. static DecodeBase64(uri: string): ArrayBuffer;
  30959. /**
  30960. * No log
  30961. */
  30962. static readonly NoneLogLevel: number;
  30963. /**
  30964. * Only message logs
  30965. */
  30966. static readonly MessageLogLevel: number;
  30967. /**
  30968. * Only warning logs
  30969. */
  30970. static readonly WarningLogLevel: number;
  30971. /**
  30972. * Only error logs
  30973. */
  30974. static readonly ErrorLogLevel: number;
  30975. /**
  30976. * All logs
  30977. */
  30978. static readonly AllLogLevel: number;
  30979. /**
  30980. * Gets a value indicating the number of loading errors
  30981. * @ignorenaming
  30982. */
  30983. static readonly errorsCount: number;
  30984. /**
  30985. * Callback called when a new log is added
  30986. */
  30987. static OnNewCacheEntry: (entry: string) => void;
  30988. /**
  30989. * Log a message to the console
  30990. * @param message defines the message to log
  30991. */
  30992. static Log(message: string): void;
  30993. /**
  30994. * Write a warning message to the console
  30995. * @param message defines the message to log
  30996. */
  30997. static Warn(message: string): void;
  30998. /**
  30999. * Write an error message to the console
  31000. * @param message defines the message to log
  31001. */
  31002. static Error(message: string): void;
  31003. /**
  31004. * Gets current log cache (list of logs)
  31005. */
  31006. static readonly LogCache: string;
  31007. /**
  31008. * Clears the log cache
  31009. */
  31010. static ClearLogCache(): void;
  31011. /**
  31012. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31013. */
  31014. static LogLevels: number;
  31015. /**
  31016. * Checks if the loaded document was accessed via `file:`-Protocol.
  31017. * @returns boolean
  31018. */
  31019. static IsFileURL(): boolean;
  31020. /**
  31021. * Checks if the window object exists
  31022. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31023. */
  31024. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31025. /**
  31026. * No performance log
  31027. */
  31028. static readonly PerformanceNoneLogLevel: number;
  31029. /**
  31030. * Use user marks to log performance
  31031. */
  31032. static readonly PerformanceUserMarkLogLevel: number;
  31033. /**
  31034. * Log performance to the console
  31035. */
  31036. static readonly PerformanceConsoleLogLevel: number;
  31037. private static _performance;
  31038. /**
  31039. * Sets the current performance log level
  31040. */
  31041. static PerformanceLogLevel: number;
  31042. private static _StartPerformanceCounterDisabled;
  31043. private static _EndPerformanceCounterDisabled;
  31044. private static _StartUserMark;
  31045. private static _EndUserMark;
  31046. private static _StartPerformanceConsole;
  31047. private static _EndPerformanceConsole;
  31048. /**
  31049. * Injects the @see CustomRequestHeaders into the given request
  31050. * @param request the request that should be used for injection
  31051. */
  31052. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31053. /**
  31054. * Starts a performance counter
  31055. */
  31056. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31057. /**
  31058. * Ends a specific performance coutner
  31059. */
  31060. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31061. /**
  31062. * Gets either window.performance.now() if supported or Date.now() else
  31063. */
  31064. static readonly Now: number;
  31065. /**
  31066. * This method will return the name of the class used to create the instance of the given object.
  31067. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31068. * @param object the object to get the class name from
  31069. * @param isType defines if the object is actually a type
  31070. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31071. */
  31072. static GetClassName(object: any, isType?: boolean): string;
  31073. /**
  31074. * Gets the first element of an array satisfying a given predicate
  31075. * @param array defines the array to browse
  31076. * @param predicate defines the predicate to use
  31077. * @returns null if not found or the element
  31078. */
  31079. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31080. /**
  31081. * This method will return the name of the full name of the class, including its owning module (if any).
  31082. * 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).
  31083. * @param object the object to get the class name from
  31084. * @param isType defines if the object is actually a type
  31085. * @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.
  31086. * @ignorenaming
  31087. */
  31088. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31089. /**
  31090. * Returns a promise that resolves after the given amount of time.
  31091. * @param delay Number of milliseconds to delay
  31092. * @returns Promise that resolves after the given amount of time
  31093. */
  31094. static DelayAsync(delay: number): Promise<void>;
  31095. /**
  31096. * Gets the current gradient from an array of IValueGradient
  31097. * @param ratio defines the current ratio to get
  31098. * @param gradients defines the array of IValueGradient
  31099. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31100. */
  31101. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31102. }
  31103. /**
  31104. * This class is used to track a performance counter which is number based.
  31105. * The user has access to many properties which give statistics of different nature.
  31106. *
  31107. * The implementer can track two kinds of Performance Counter: time and count.
  31108. * 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.
  31109. * 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.
  31110. */
  31111. export class PerfCounter {
  31112. /**
  31113. * Gets or sets a global boolean to turn on and off all the counters
  31114. */
  31115. static Enabled: boolean;
  31116. /**
  31117. * Returns the smallest value ever
  31118. */
  31119. readonly min: number;
  31120. /**
  31121. * Returns the biggest value ever
  31122. */
  31123. readonly max: number;
  31124. /**
  31125. * Returns the average value since the performance counter is running
  31126. */
  31127. readonly average: number;
  31128. /**
  31129. * Returns the average value of the last second the counter was monitored
  31130. */
  31131. readonly lastSecAverage: number;
  31132. /**
  31133. * Returns the current value
  31134. */
  31135. readonly current: number;
  31136. /**
  31137. * Gets the accumulated total
  31138. */
  31139. readonly total: number;
  31140. /**
  31141. * Gets the total value count
  31142. */
  31143. readonly count: number;
  31144. /**
  31145. * Creates a new counter
  31146. */
  31147. constructor();
  31148. /**
  31149. * Call this method to start monitoring a new frame.
  31150. * 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.
  31151. */
  31152. fetchNewFrame(): void;
  31153. /**
  31154. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31155. * @param newCount the count value to add to the monitored count
  31156. * @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.
  31157. */
  31158. addCount(newCount: number, fetchResult: boolean): void;
  31159. /**
  31160. * Start monitoring this performance counter
  31161. */
  31162. beginMonitoring(): void;
  31163. /**
  31164. * Compute the time lapsed since the previous beginMonitoring() call.
  31165. * @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
  31166. */
  31167. endMonitoring(newFrame?: boolean): void;
  31168. private _fetchResult;
  31169. private _startMonitoringTime;
  31170. private _min;
  31171. private _max;
  31172. private _average;
  31173. private _current;
  31174. private _totalValueCount;
  31175. private _totalAccumulated;
  31176. private _lastSecAverage;
  31177. private _lastSecAccumulated;
  31178. private _lastSecTime;
  31179. private _lastSecValueCount;
  31180. }
  31181. /**
  31182. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31183. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31184. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31185. * @param name The name of the class, case should be preserved
  31186. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31187. */
  31188. export function className(name: string, module?: string): (target: Object) => void;
  31189. /**
  31190. * An implementation of a loop for asynchronous functions.
  31191. */
  31192. export class AsyncLoop {
  31193. /**
  31194. * Defines the number of iterations for the loop
  31195. */
  31196. iterations: number;
  31197. /**
  31198. * Defines the current index of the loop.
  31199. */
  31200. index: number;
  31201. private _done;
  31202. private _fn;
  31203. private _successCallback;
  31204. /**
  31205. * Constructor.
  31206. * @param iterations the number of iterations.
  31207. * @param func the function to run each iteration
  31208. * @param successCallback the callback that will be called upon succesful execution
  31209. * @param offset starting offset.
  31210. */
  31211. constructor(
  31212. /**
  31213. * Defines the number of iterations for the loop
  31214. */
  31215. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31216. /**
  31217. * Execute the next iteration. Must be called after the last iteration was finished.
  31218. */
  31219. executeNext(): void;
  31220. /**
  31221. * Break the loop and run the success callback.
  31222. */
  31223. breakLoop(): void;
  31224. /**
  31225. * Create and run an async loop.
  31226. * @param iterations the number of iterations.
  31227. * @param fn the function to run each iteration
  31228. * @param successCallback the callback that will be called upon succesful execution
  31229. * @param offset starting offset.
  31230. * @returns the created async loop object
  31231. */
  31232. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31233. /**
  31234. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31235. * @param iterations total number of iterations
  31236. * @param syncedIterations number of synchronous iterations in each async iteration.
  31237. * @param fn the function to call each iteration.
  31238. * @param callback a success call back that will be called when iterating stops.
  31239. * @param breakFunction a break condition (optional)
  31240. * @param timeout timeout settings for the setTimeout function. default - 0.
  31241. * @returns the created async loop object
  31242. */
  31243. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31244. }
  31245. }
  31246. declare module "babylonjs/Animations/animationGroup" {
  31247. import { Animatable } from "babylonjs/Animations/animatable";
  31248. import { Animation } from "babylonjs/Animations/animation";
  31249. import { Scene, IDisposable } from "babylonjs/scene";
  31250. import { Observable } from "babylonjs/Misc/observable";
  31251. import { Nullable } from "babylonjs/types";
  31252. /**
  31253. * This class defines the direct association between an animation and a target
  31254. */
  31255. export class TargetedAnimation {
  31256. /**
  31257. * Animation to perform
  31258. */
  31259. animation: Animation;
  31260. /**
  31261. * Target to animate
  31262. */
  31263. target: any;
  31264. }
  31265. /**
  31266. * Use this class to create coordinated animations on multiple targets
  31267. */
  31268. export class AnimationGroup implements IDisposable {
  31269. /** The name of the animation group */
  31270. name: string;
  31271. private _scene;
  31272. private _targetedAnimations;
  31273. private _animatables;
  31274. private _from;
  31275. private _to;
  31276. private _isStarted;
  31277. private _isPaused;
  31278. private _speedRatio;
  31279. /**
  31280. * Gets or sets the unique id of the node
  31281. */
  31282. uniqueId: number;
  31283. /**
  31284. * This observable will notify when one animation have ended
  31285. */
  31286. onAnimationEndObservable: Observable<TargetedAnimation>;
  31287. /**
  31288. * Observer raised when one animation loops
  31289. */
  31290. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31291. /**
  31292. * This observable will notify when all animations have ended.
  31293. */
  31294. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31295. /**
  31296. * This observable will notify when all animations have paused.
  31297. */
  31298. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31299. /**
  31300. * This observable will notify when all animations are playing.
  31301. */
  31302. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31303. /**
  31304. * Gets the first frame
  31305. */
  31306. readonly from: number;
  31307. /**
  31308. * Gets the last frame
  31309. */
  31310. readonly to: number;
  31311. /**
  31312. * Define if the animations are started
  31313. */
  31314. readonly isStarted: boolean;
  31315. /**
  31316. * Gets a value indicating that the current group is playing
  31317. */
  31318. readonly isPlaying: boolean;
  31319. /**
  31320. * Gets or sets the speed ratio to use for all animations
  31321. */
  31322. /**
  31323. * Gets or sets the speed ratio to use for all animations
  31324. */
  31325. speedRatio: number;
  31326. /**
  31327. * Gets the targeted animations for this animation group
  31328. */
  31329. readonly targetedAnimations: Array<TargetedAnimation>;
  31330. /**
  31331. * returning the list of animatables controlled by this animation group.
  31332. */
  31333. readonly animatables: Array<Animatable>;
  31334. /**
  31335. * Instantiates a new Animation Group.
  31336. * This helps managing several animations at once.
  31337. * @see http://doc.babylonjs.com/how_to/group
  31338. * @param name Defines the name of the group
  31339. * @param scene Defines the scene the group belongs to
  31340. */
  31341. constructor(
  31342. /** The name of the animation group */
  31343. name: string, scene?: Nullable<Scene>);
  31344. /**
  31345. * Add an animation (with its target) in the group
  31346. * @param animation defines the animation we want to add
  31347. * @param target defines the target of the animation
  31348. * @returns the TargetedAnimation object
  31349. */
  31350. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31351. /**
  31352. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31353. * It can add constant keys at begin or end
  31354. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31355. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31356. * @returns the animation group
  31357. */
  31358. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31359. /**
  31360. * Start all animations on given targets
  31361. * @param loop defines if animations must loop
  31362. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31363. * @param from defines the from key (optional)
  31364. * @param to defines the to key (optional)
  31365. * @returns the current animation group
  31366. */
  31367. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31368. /**
  31369. * Pause all animations
  31370. * @returns the animation group
  31371. */
  31372. pause(): AnimationGroup;
  31373. /**
  31374. * Play all animations to initial state
  31375. * This function will start() the animations if they were not started or will restart() them if they were paused
  31376. * @param loop defines if animations must loop
  31377. * @returns the animation group
  31378. */
  31379. play(loop?: boolean): AnimationGroup;
  31380. /**
  31381. * Reset all animations to initial state
  31382. * @returns the animation group
  31383. */
  31384. reset(): AnimationGroup;
  31385. /**
  31386. * Restart animations from key 0
  31387. * @returns the animation group
  31388. */
  31389. restart(): AnimationGroup;
  31390. /**
  31391. * Stop all animations
  31392. * @returns the animation group
  31393. */
  31394. stop(): AnimationGroup;
  31395. /**
  31396. * Set animation weight for all animatables
  31397. * @param weight defines the weight to use
  31398. * @return the animationGroup
  31399. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31400. */
  31401. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31402. /**
  31403. * Synchronize and normalize all animatables with a source animatable
  31404. * @param root defines the root animatable to synchronize with
  31405. * @return the animationGroup
  31406. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31407. */
  31408. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31409. /**
  31410. * Goes to a specific frame in this animation group
  31411. * @param frame the frame number to go to
  31412. * @return the animationGroup
  31413. */
  31414. goToFrame(frame: number): AnimationGroup;
  31415. /**
  31416. * Dispose all associated resources
  31417. */
  31418. dispose(): void;
  31419. private _checkAnimationGroupEnded;
  31420. /**
  31421. * Returns a new AnimationGroup object parsed from the source provided.
  31422. * @param parsedAnimationGroup defines the source
  31423. * @param scene defines the scene that will receive the animationGroup
  31424. * @returns a new AnimationGroup
  31425. */
  31426. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31427. /**
  31428. * Returns the string "AnimationGroup"
  31429. * @returns "AnimationGroup"
  31430. */
  31431. getClassName(): string;
  31432. /**
  31433. * Creates a detailled string about the object
  31434. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31435. * @returns a string representing the object
  31436. */
  31437. toString(fullDetails?: boolean): string;
  31438. }
  31439. }
  31440. declare module "babylonjs/Collisions/collisionCoordinator" {
  31441. import { Nullable } from "babylonjs/types";
  31442. import { Scene } from "babylonjs/scene";
  31443. import { Vector3 } from "babylonjs/Maths/math";
  31444. import { Collider } from "babylonjs/Collisions/collider";
  31445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31446. /** @hidden */
  31447. export interface ICollisionCoordinator {
  31448. createCollider(): Collider;
  31449. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31450. init(scene: Scene): void;
  31451. }
  31452. /** @hidden */
  31453. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31454. private _scene;
  31455. private _scaledPosition;
  31456. private _scaledVelocity;
  31457. private _finalPosition;
  31458. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31459. createCollider(): Collider;
  31460. init(scene: Scene): void;
  31461. private _collideWithWorld;
  31462. }
  31463. }
  31464. declare module "babylonjs/scene" {
  31465. import { Nullable } from "babylonjs/types";
  31466. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31467. import { Observable } from "babylonjs/Misc/observable";
  31468. import { SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31469. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31470. import { Geometry } from "babylonjs/Meshes/geometry";
  31471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31474. import { Mesh } from "babylonjs/Meshes/mesh";
  31475. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31476. import { Bone } from "babylonjs/Bones/bone";
  31477. import { Skeleton } from "babylonjs/Bones/skeleton";
  31478. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31479. import { Camera } from "babylonjs/Cameras/camera";
  31480. import { AbstractScene } from "babylonjs/abstractScene";
  31481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31483. import { Material } from "babylonjs/Materials/material";
  31484. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31485. import { Effect } from "babylonjs/Materials/effect";
  31486. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31487. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31488. import { Animation } from "babylonjs/Animations/animation";
  31489. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  31490. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31491. import { Animatable } from "babylonjs/Animations/animatable";
  31492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31493. import { Light } from "babylonjs/Lights/light";
  31494. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31495. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31496. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31497. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31498. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31499. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31500. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31501. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31502. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31503. import { Engine } from "babylonjs/Engines/engine";
  31504. import { Ray } from "babylonjs/Culling/ray";
  31505. import { Node } from "babylonjs/node";
  31506. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31507. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31508. import { Collider } from "babylonjs/Collisions/collider";
  31509. /**
  31510. * Define an interface for all classes that will hold resources
  31511. */
  31512. export interface IDisposable {
  31513. /**
  31514. * Releases all held resources
  31515. */
  31516. dispose(): void;
  31517. }
  31518. /** Interface defining initialization parameters for Scene class */
  31519. export interface SceneOptions {
  31520. /**
  31521. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31522. * It will improve performance when the number of geometries becomes important.
  31523. */
  31524. useGeometryUniqueIdsMap?: boolean;
  31525. /**
  31526. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31527. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31528. */
  31529. useMaterialMeshMap?: boolean;
  31530. /**
  31531. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31532. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31533. */
  31534. useClonedMeshhMap?: boolean;
  31535. }
  31536. /**
  31537. * Represents a scene to be rendered by the engine.
  31538. * @see http://doc.babylonjs.com/features/scene
  31539. */
  31540. export class Scene extends AbstractScene implements IAnimatable {
  31541. private static _uniqueIdCounter;
  31542. /** The fog is deactivated */
  31543. static readonly FOGMODE_NONE: number;
  31544. /** The fog density is following an exponential function */
  31545. static readonly FOGMODE_EXP: number;
  31546. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31547. static readonly FOGMODE_EXP2: number;
  31548. /** The fog density is following a linear function. */
  31549. static readonly FOGMODE_LINEAR: number;
  31550. /**
  31551. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31552. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31553. */
  31554. static MinDeltaTime: number;
  31555. /**
  31556. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31557. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31558. */
  31559. static MaxDeltaTime: number;
  31560. /**
  31561. * Factory used to create the default material.
  31562. * @param name The name of the material to create
  31563. * @param scene The scene to create the material for
  31564. * @returns The default material
  31565. */
  31566. static DefaultMaterialFactory(scene: Scene): Material;
  31567. /**
  31568. * Factory used to create the a collision coordinator.
  31569. * @returns The collision coordinator
  31570. */
  31571. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31572. /** @hidden */
  31573. readonly _isScene: boolean;
  31574. /**
  31575. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31576. */
  31577. autoClear: boolean;
  31578. /**
  31579. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31580. */
  31581. autoClearDepthAndStencil: boolean;
  31582. /**
  31583. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31584. */
  31585. clearColor: Color4;
  31586. /**
  31587. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31588. */
  31589. ambientColor: Color3;
  31590. /** @hidden */
  31591. _environmentBRDFTexture: BaseTexture;
  31592. /** @hidden */
  31593. protected _environmentTexture: Nullable<BaseTexture>;
  31594. /**
  31595. * Texture used in all pbr material as the reflection texture.
  31596. * As in the majority of the scene they are the same (exception for multi room and so on),
  31597. * this is easier to reference from here than from all the materials.
  31598. */
  31599. /**
  31600. * Texture used in all pbr material as the reflection texture.
  31601. * As in the majority of the scene they are the same (exception for multi room and so on),
  31602. * this is easier to set here than in all the materials.
  31603. */
  31604. environmentTexture: Nullable<BaseTexture>;
  31605. /** @hidden */
  31606. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31607. /**
  31608. * Default image processing configuration used either in the rendering
  31609. * Forward main pass or through the imageProcessingPostProcess if present.
  31610. * As in the majority of the scene they are the same (exception for multi camera),
  31611. * this is easier to reference from here than from all the materials and post process.
  31612. *
  31613. * No setter as we it is a shared configuration, you can set the values instead.
  31614. */
  31615. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31616. private _forceWireframe;
  31617. /**
  31618. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31619. */
  31620. forceWireframe: boolean;
  31621. private _forcePointsCloud;
  31622. /**
  31623. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31624. */
  31625. forcePointsCloud: boolean;
  31626. /**
  31627. * Gets or sets the active clipplane 1
  31628. */
  31629. clipPlane: Nullable<Plane>;
  31630. /**
  31631. * Gets or sets the active clipplane 2
  31632. */
  31633. clipPlane2: Nullable<Plane>;
  31634. /**
  31635. * Gets or sets the active clipplane 3
  31636. */
  31637. clipPlane3: Nullable<Plane>;
  31638. /**
  31639. * Gets or sets the active clipplane 4
  31640. */
  31641. clipPlane4: Nullable<Plane>;
  31642. /**
  31643. * Gets or sets a boolean indicating if animations are enabled
  31644. */
  31645. animationsEnabled: boolean;
  31646. private _animationPropertiesOverride;
  31647. /**
  31648. * Gets or sets the animation properties override
  31649. */
  31650. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31651. /**
  31652. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31653. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31654. */
  31655. useConstantAnimationDeltaTime: boolean;
  31656. /**
  31657. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31658. * Please note that it requires to run a ray cast through the scene on every frame
  31659. */
  31660. constantlyUpdateMeshUnderPointer: boolean;
  31661. /**
  31662. * Defines the HTML cursor to use when hovering over interactive elements
  31663. */
  31664. hoverCursor: string;
  31665. /**
  31666. * Defines the HTML default cursor to use (empty by default)
  31667. */
  31668. defaultCursor: string;
  31669. /**
  31670. * This is used to call preventDefault() on pointer down
  31671. * in order to block unwanted artifacts like system double clicks
  31672. */
  31673. preventDefaultOnPointerDown: boolean;
  31674. /**
  31675. * This is used to call preventDefault() on pointer up
  31676. * in order to block unwanted artifacts like system double clicks
  31677. */
  31678. preventDefaultOnPointerUp: boolean;
  31679. /**
  31680. * Gets or sets user defined metadata
  31681. */
  31682. metadata: any;
  31683. /**
  31684. * For internal use only. Please do not use.
  31685. */
  31686. reservedDataStore: any;
  31687. /**
  31688. * Gets the name of the plugin used to load this scene (null by default)
  31689. */
  31690. loadingPluginName: string;
  31691. /**
  31692. * Use this array to add regular expressions used to disable offline support for specific urls
  31693. */
  31694. disableOfflineSupportExceptionRules: RegExp[];
  31695. /**
  31696. * An event triggered when the scene is disposed.
  31697. */
  31698. onDisposeObservable: Observable<Scene>;
  31699. private _onDisposeObserver;
  31700. /** Sets a function to be executed when this scene is disposed. */
  31701. onDispose: () => void;
  31702. /**
  31703. * An event triggered before rendering the scene (right after animations and physics)
  31704. */
  31705. onBeforeRenderObservable: Observable<Scene>;
  31706. private _onBeforeRenderObserver;
  31707. /** Sets a function to be executed before rendering this scene */
  31708. beforeRender: Nullable<() => void>;
  31709. /**
  31710. * An event triggered after rendering the scene
  31711. */
  31712. onAfterRenderObservable: Observable<Scene>;
  31713. private _onAfterRenderObserver;
  31714. /** Sets a function to be executed after rendering this scene */
  31715. afterRender: Nullable<() => void>;
  31716. /**
  31717. * An event triggered before animating the scene
  31718. */
  31719. onBeforeAnimationsObservable: Observable<Scene>;
  31720. /**
  31721. * An event triggered after animations processing
  31722. */
  31723. onAfterAnimationsObservable: Observable<Scene>;
  31724. /**
  31725. * An event triggered before draw calls are ready to be sent
  31726. */
  31727. onBeforeDrawPhaseObservable: Observable<Scene>;
  31728. /**
  31729. * An event triggered after draw calls have been sent
  31730. */
  31731. onAfterDrawPhaseObservable: Observable<Scene>;
  31732. /**
  31733. * An event triggered when the scene is ready
  31734. */
  31735. onReadyObservable: Observable<Scene>;
  31736. /**
  31737. * An event triggered before rendering a camera
  31738. */
  31739. onBeforeCameraRenderObservable: Observable<Camera>;
  31740. private _onBeforeCameraRenderObserver;
  31741. /** Sets a function to be executed before rendering a camera*/
  31742. beforeCameraRender: () => void;
  31743. /**
  31744. * An event triggered after rendering a camera
  31745. */
  31746. onAfterCameraRenderObservable: Observable<Camera>;
  31747. private _onAfterCameraRenderObserver;
  31748. /** Sets a function to be executed after rendering a camera*/
  31749. afterCameraRender: () => void;
  31750. /**
  31751. * An event triggered when active meshes evaluation is about to start
  31752. */
  31753. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31754. /**
  31755. * An event triggered when active meshes evaluation is done
  31756. */
  31757. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31758. /**
  31759. * An event triggered when particles rendering is about to start
  31760. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31761. */
  31762. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31763. /**
  31764. * An event triggered when particles rendering is done
  31765. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31766. */
  31767. onAfterParticlesRenderingObservable: Observable<Scene>;
  31768. /**
  31769. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31770. */
  31771. onDataLoadedObservable: Observable<Scene>;
  31772. /**
  31773. * An event triggered when a camera is created
  31774. */
  31775. onNewCameraAddedObservable: Observable<Camera>;
  31776. /**
  31777. * An event triggered when a camera is removed
  31778. */
  31779. onCameraRemovedObservable: Observable<Camera>;
  31780. /**
  31781. * An event triggered when a light is created
  31782. */
  31783. onNewLightAddedObservable: Observable<Light>;
  31784. /**
  31785. * An event triggered when a light is removed
  31786. */
  31787. onLightRemovedObservable: Observable<Light>;
  31788. /**
  31789. * An event triggered when a geometry is created
  31790. */
  31791. onNewGeometryAddedObservable: Observable<Geometry>;
  31792. /**
  31793. * An event triggered when a geometry is removed
  31794. */
  31795. onGeometryRemovedObservable: Observable<Geometry>;
  31796. /**
  31797. * An event triggered when a transform node is created
  31798. */
  31799. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31800. /**
  31801. * An event triggered when a transform node is removed
  31802. */
  31803. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31804. /**
  31805. * An event triggered when a mesh is created
  31806. */
  31807. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31808. /**
  31809. * An event triggered when a mesh is removed
  31810. */
  31811. onMeshRemovedObservable: Observable<AbstractMesh>;
  31812. /**
  31813. * An event triggered when a material is created
  31814. */
  31815. onNewMaterialAddedObservable: Observable<Material>;
  31816. /**
  31817. * An event triggered when a material is removed
  31818. */
  31819. onMaterialRemovedObservable: Observable<Material>;
  31820. /**
  31821. * An event triggered when a texture is created
  31822. */
  31823. onNewTextureAddedObservable: Observable<BaseTexture>;
  31824. /**
  31825. * An event triggered when a texture is removed
  31826. */
  31827. onTextureRemovedObservable: Observable<BaseTexture>;
  31828. /**
  31829. * An event triggered when render targets are about to be rendered
  31830. * Can happen multiple times per frame.
  31831. */
  31832. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31833. /**
  31834. * An event triggered when render targets were rendered.
  31835. * Can happen multiple times per frame.
  31836. */
  31837. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31838. /**
  31839. * An event triggered before calculating deterministic simulation step
  31840. */
  31841. onBeforeStepObservable: Observable<Scene>;
  31842. /**
  31843. * An event triggered after calculating deterministic simulation step
  31844. */
  31845. onAfterStepObservable: Observable<Scene>;
  31846. /**
  31847. * An event triggered when the activeCamera property is updated
  31848. */
  31849. onActiveCameraChanged: Observable<Scene>;
  31850. /**
  31851. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31852. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31853. * 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)
  31854. */
  31855. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31856. /**
  31857. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31858. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31859. * 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)
  31860. */
  31861. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31862. /**
  31863. * This Observable will when a mesh has been imported into the scene.
  31864. */
  31865. onMeshImportedObservable: Observable<AbstractMesh>;
  31866. private _registeredForLateAnimationBindings;
  31867. /**
  31868. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31869. */
  31870. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31871. /**
  31872. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31873. */
  31874. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31875. /**
  31876. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31877. */
  31878. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31879. private _onPointerMove;
  31880. private _onPointerDown;
  31881. private _onPointerUp;
  31882. /** Callback called when a pointer move is detected */
  31883. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31884. /** Callback called when a pointer down is detected */
  31885. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31886. /** Callback called when a pointer up is detected */
  31887. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31888. /** Callback called when a pointer pick is detected */
  31889. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31890. /**
  31891. * 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).
  31892. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31893. */
  31894. onPrePointerObservable: Observable<PointerInfoPre>;
  31895. /**
  31896. * Observable event triggered each time an input event is received from the rendering canvas
  31897. */
  31898. onPointerObservable: Observable<PointerInfo>;
  31899. /**
  31900. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31901. */
  31902. readonly unTranslatedPointer: Vector2;
  31903. /** The distance in pixel that you have to move to prevent some events */
  31904. static DragMovementThreshold: number;
  31905. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31906. static LongPressDelay: number;
  31907. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31908. static DoubleClickDelay: number;
  31909. /** If you need to check double click without raising a single click at first click, enable this flag */
  31910. static ExclusiveDoubleClickMode: boolean;
  31911. private _initClickEvent;
  31912. private _initActionManager;
  31913. private _delayedSimpleClick;
  31914. private _delayedSimpleClickTimeout;
  31915. private _previousDelayedSimpleClickTimeout;
  31916. private _meshPickProceed;
  31917. private _previousButtonPressed;
  31918. private _currentPickResult;
  31919. private _previousPickResult;
  31920. private _totalPointersPressed;
  31921. private _doubleClickOccured;
  31922. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31923. cameraToUseForPointers: Nullable<Camera>;
  31924. private _pointerX;
  31925. private _pointerY;
  31926. private _unTranslatedPointerX;
  31927. private _unTranslatedPointerY;
  31928. private _startingPointerPosition;
  31929. private _previousStartingPointerPosition;
  31930. private _startingPointerTime;
  31931. private _previousStartingPointerTime;
  31932. private _pointerCaptures;
  31933. private _timeAccumulator;
  31934. private _currentStepId;
  31935. private _currentInternalStep;
  31936. /** @hidden */
  31937. _mirroredCameraPosition: Nullable<Vector3>;
  31938. /**
  31939. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31940. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31941. */
  31942. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31943. /**
  31944. * Observable event triggered each time an keyboard event is received from the hosting window
  31945. */
  31946. onKeyboardObservable: Observable<KeyboardInfo>;
  31947. private _onKeyDown;
  31948. private _onKeyUp;
  31949. private _onCanvasFocusObserver;
  31950. private _onCanvasBlurObserver;
  31951. private _useRightHandedSystem;
  31952. /**
  31953. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31954. */
  31955. useRightHandedSystem: boolean;
  31956. /**
  31957. * Sets the step Id used by deterministic lock step
  31958. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31959. * @param newStepId defines the step Id
  31960. */
  31961. setStepId(newStepId: number): void;
  31962. /**
  31963. * Gets the step Id used by deterministic lock step
  31964. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31965. * @returns the step Id
  31966. */
  31967. getStepId(): number;
  31968. /**
  31969. * Gets the internal step used by deterministic lock step
  31970. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31971. * @returns the internal step
  31972. */
  31973. getInternalStep(): number;
  31974. private _fogEnabled;
  31975. /**
  31976. * Gets or sets a boolean indicating if fog is enabled on this scene
  31977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31978. * (Default is true)
  31979. */
  31980. fogEnabled: boolean;
  31981. private _fogMode;
  31982. /**
  31983. * Gets or sets the fog mode to use
  31984. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31985. * | mode | value |
  31986. * | --- | --- |
  31987. * | FOGMODE_NONE | 0 |
  31988. * | FOGMODE_EXP | 1 |
  31989. * | FOGMODE_EXP2 | 2 |
  31990. * | FOGMODE_LINEAR | 3 |
  31991. */
  31992. fogMode: number;
  31993. /**
  31994. * Gets or sets the fog color to use
  31995. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31996. * (Default is Color3(0.2, 0.2, 0.3))
  31997. */
  31998. fogColor: Color3;
  31999. /**
  32000. * Gets or sets the fog density to use
  32001. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32002. * (Default is 0.1)
  32003. */
  32004. fogDensity: number;
  32005. /**
  32006. * Gets or sets the fog start distance to use
  32007. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32008. * (Default is 0)
  32009. */
  32010. fogStart: number;
  32011. /**
  32012. * Gets or sets the fog end distance to use
  32013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32014. * (Default is 1000)
  32015. */
  32016. fogEnd: number;
  32017. private _shadowsEnabled;
  32018. /**
  32019. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32020. */
  32021. shadowsEnabled: boolean;
  32022. private _lightsEnabled;
  32023. /**
  32024. * Gets or sets a boolean indicating if lights are enabled on this scene
  32025. */
  32026. lightsEnabled: boolean;
  32027. /** All of the active cameras added to this scene. */
  32028. activeCameras: Camera[];
  32029. private _activeCamera;
  32030. /** Gets or sets the current active camera */
  32031. activeCamera: Nullable<Camera>;
  32032. private _defaultMaterial;
  32033. /** The default material used on meshes when no material is affected */
  32034. /** The default material used on meshes when no material is affected */
  32035. defaultMaterial: Material;
  32036. private _texturesEnabled;
  32037. /**
  32038. * Gets or sets a boolean indicating if textures are enabled on this scene
  32039. */
  32040. texturesEnabled: boolean;
  32041. /**
  32042. * Gets or sets a boolean indicating if particles are enabled on this scene
  32043. */
  32044. particlesEnabled: boolean;
  32045. /**
  32046. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32047. */
  32048. spritesEnabled: boolean;
  32049. private _skeletonsEnabled;
  32050. /**
  32051. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32052. */
  32053. skeletonsEnabled: boolean;
  32054. /**
  32055. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32056. */
  32057. lensFlaresEnabled: boolean;
  32058. /**
  32059. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32061. */
  32062. collisionsEnabled: boolean;
  32063. private _collisionCoordinator;
  32064. /** @hidden */
  32065. readonly collisionCoordinator: ICollisionCoordinator;
  32066. /**
  32067. * Defines the gravity applied to this scene (used only for collisions)
  32068. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32069. */
  32070. gravity: Vector3;
  32071. /**
  32072. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32073. */
  32074. postProcessesEnabled: boolean;
  32075. /**
  32076. * The list of postprocesses added to the scene
  32077. */
  32078. postProcesses: PostProcess[];
  32079. /**
  32080. * Gets the current postprocess manager
  32081. */
  32082. postProcessManager: PostProcessManager;
  32083. /**
  32084. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32085. */
  32086. renderTargetsEnabled: boolean;
  32087. /**
  32088. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32089. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32090. */
  32091. dumpNextRenderTargets: boolean;
  32092. /**
  32093. * The list of user defined render targets added to the scene
  32094. */
  32095. customRenderTargets: RenderTargetTexture[];
  32096. /**
  32097. * Defines if texture loading must be delayed
  32098. * If true, textures will only be loaded when they need to be rendered
  32099. */
  32100. useDelayedTextureLoading: boolean;
  32101. /**
  32102. * Gets the list of meshes imported to the scene through SceneLoader
  32103. */
  32104. importedMeshesFiles: String[];
  32105. /**
  32106. * Gets or sets a boolean indicating if probes are enabled on this scene
  32107. */
  32108. probesEnabled: boolean;
  32109. /**
  32110. * Gets or sets the current offline provider to use to store scene data
  32111. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32112. */
  32113. offlineProvider: IOfflineProvider;
  32114. /**
  32115. * Gets or sets the action manager associated with the scene
  32116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32117. */
  32118. actionManager: AbstractActionManager;
  32119. private _meshesForIntersections;
  32120. /**
  32121. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32122. */
  32123. proceduralTexturesEnabled: boolean;
  32124. private _engine;
  32125. private _totalVertices;
  32126. /** @hidden */
  32127. _activeIndices: PerfCounter;
  32128. /** @hidden */
  32129. _activeParticles: PerfCounter;
  32130. /** @hidden */
  32131. _activeBones: PerfCounter;
  32132. private _animationRatio;
  32133. private _animationTimeLast;
  32134. private _animationTime;
  32135. /**
  32136. * Gets or sets a general scale for animation speed
  32137. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32138. */
  32139. animationTimeScale: number;
  32140. /** @hidden */
  32141. _cachedMaterial: Nullable<Material>;
  32142. /** @hidden */
  32143. _cachedEffect: Nullable<Effect>;
  32144. /** @hidden */
  32145. _cachedVisibility: Nullable<number>;
  32146. private _renderId;
  32147. private _frameId;
  32148. private _executeWhenReadyTimeoutId;
  32149. private _intermediateRendering;
  32150. private _viewUpdateFlag;
  32151. private _projectionUpdateFlag;
  32152. private _alternateViewUpdateFlag;
  32153. private _alternateProjectionUpdateFlag;
  32154. /** @hidden */
  32155. _toBeDisposed: Nullable<IDisposable>[];
  32156. private _activeRequests;
  32157. private _pendingData;
  32158. private _isDisposed;
  32159. /**
  32160. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32161. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32162. */
  32163. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32164. private _activeMeshes;
  32165. private _processedMaterials;
  32166. private _renderTargets;
  32167. /** @hidden */
  32168. _activeParticleSystems: SmartArray<IParticleSystem>;
  32169. private _activeSkeletons;
  32170. private _softwareSkinnedMeshes;
  32171. private _renderingManager;
  32172. /** @hidden */
  32173. _activeAnimatables: Animatable[];
  32174. private _transformMatrix;
  32175. private _sceneUbo;
  32176. private _alternateSceneUbo;
  32177. private _pickWithRayInverseMatrix;
  32178. private _viewMatrix;
  32179. private _projectionMatrix;
  32180. private _alternateViewMatrix;
  32181. private _alternateProjectionMatrix;
  32182. private _alternateTransformMatrix;
  32183. private _useAlternateCameraConfiguration;
  32184. private _alternateRendering;
  32185. private _wheelEventName;
  32186. /** @hidden */
  32187. _forcedViewPosition: Nullable<Vector3>;
  32188. /** @hidden */
  32189. readonly _isAlternateRenderingEnabled: boolean;
  32190. private _frustumPlanes;
  32191. /**
  32192. * Gets the list of frustum planes (built from the active camera)
  32193. */
  32194. readonly frustumPlanes: Plane[];
  32195. /**
  32196. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32197. * This is useful if there are more lights that the maximum simulteanous authorized
  32198. */
  32199. requireLightSorting: boolean;
  32200. /** @hidden */
  32201. readonly useMaterialMeshMap: boolean;
  32202. /** @hidden */
  32203. readonly useClonedMeshhMap: boolean;
  32204. private _pointerOverMesh;
  32205. private _pickedDownMesh;
  32206. private _pickedUpMesh;
  32207. private _externalData;
  32208. private _uid;
  32209. /**
  32210. * @hidden
  32211. * Backing store of defined scene components.
  32212. */
  32213. _components: ISceneComponent[];
  32214. /**
  32215. * @hidden
  32216. * Backing store of defined scene components.
  32217. */
  32218. _serializableComponents: ISceneSerializableComponent[];
  32219. /**
  32220. * List of components to register on the next registration step.
  32221. */
  32222. private _transientComponents;
  32223. /**
  32224. * Registers the transient components if needed.
  32225. */
  32226. private _registerTransientComponents;
  32227. /**
  32228. * @hidden
  32229. * Add a component to the scene.
  32230. * Note that the ccomponent could be registered on th next frame if this is called after
  32231. * the register component stage.
  32232. * @param component Defines the component to add to the scene
  32233. */
  32234. _addComponent(component: ISceneComponent): void;
  32235. /**
  32236. * @hidden
  32237. * Gets a component from the scene.
  32238. * @param name defines the name of the component to retrieve
  32239. * @returns the component or null if not present
  32240. */
  32241. _getComponent(name: string): Nullable<ISceneComponent>;
  32242. /**
  32243. * @hidden
  32244. * Defines the actions happening before camera updates.
  32245. */
  32246. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32247. /**
  32248. * @hidden
  32249. * Defines the actions happening before clear the canvas.
  32250. */
  32251. _beforeClearStage: Stage<SimpleStageAction>;
  32252. /**
  32253. * @hidden
  32254. * Defines the actions when collecting render targets for the frame.
  32255. */
  32256. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32257. /**
  32258. * @hidden
  32259. * Defines the actions happening for one camera in the frame.
  32260. */
  32261. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32262. /**
  32263. * @hidden
  32264. * Defines the actions happening during the per mesh ready checks.
  32265. */
  32266. _isReadyForMeshStage: Stage<MeshStageAction>;
  32267. /**
  32268. * @hidden
  32269. * Defines the actions happening before evaluate active mesh checks.
  32270. */
  32271. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32272. /**
  32273. * @hidden
  32274. * Defines the actions happening during the evaluate sub mesh checks.
  32275. */
  32276. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32277. /**
  32278. * @hidden
  32279. * Defines the actions happening during the active mesh stage.
  32280. */
  32281. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32282. /**
  32283. * @hidden
  32284. * Defines the actions happening during the per camera render target step.
  32285. */
  32286. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32287. /**
  32288. * @hidden
  32289. * Defines the actions happening just before the active camera is drawing.
  32290. */
  32291. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32292. /**
  32293. * @hidden
  32294. * Defines the actions happening just before a render target is drawing.
  32295. */
  32296. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32297. /**
  32298. * @hidden
  32299. * Defines the actions happening just before a rendering group is drawing.
  32300. */
  32301. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32302. /**
  32303. * @hidden
  32304. * Defines the actions happening just before a mesh is drawing.
  32305. */
  32306. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32307. /**
  32308. * @hidden
  32309. * Defines the actions happening just after a mesh has been drawn.
  32310. */
  32311. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32312. /**
  32313. * @hidden
  32314. * Defines the actions happening just after a rendering group has been drawn.
  32315. */
  32316. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32317. /**
  32318. * @hidden
  32319. * Defines the actions happening just after the active camera has been drawn.
  32320. */
  32321. _afterCameraDrawStage: Stage<CameraStageAction>;
  32322. /**
  32323. * @hidden
  32324. * Defines the actions happening just after a render target has been drawn.
  32325. */
  32326. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32327. /**
  32328. * @hidden
  32329. * Defines the actions happening just after rendering all cameras and computing intersections.
  32330. */
  32331. _afterRenderStage: Stage<SimpleStageAction>;
  32332. /**
  32333. * @hidden
  32334. * Defines the actions happening when a pointer move event happens.
  32335. */
  32336. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32337. /**
  32338. * @hidden
  32339. * Defines the actions happening when a pointer down event happens.
  32340. */
  32341. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32342. /**
  32343. * @hidden
  32344. * Defines the actions happening when a pointer up event happens.
  32345. */
  32346. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32347. /**
  32348. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32349. */
  32350. private geometriesByUniqueId;
  32351. /**
  32352. * Creates a new Scene
  32353. * @param engine defines the engine to use to render this scene
  32354. * @param options defines the scene options
  32355. */
  32356. constructor(engine: Engine, options?: SceneOptions);
  32357. private _defaultMeshCandidates;
  32358. /**
  32359. * @hidden
  32360. */
  32361. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32362. private _defaultSubMeshCandidates;
  32363. /**
  32364. * @hidden
  32365. */
  32366. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32367. /**
  32368. * Sets the default candidate providers for the scene.
  32369. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32370. * and getCollidingSubMeshCandidates to their default function
  32371. */
  32372. setDefaultCandidateProviders(): void;
  32373. /**
  32374. * Gets the mesh that is currently under the pointer
  32375. */
  32376. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32377. /**
  32378. * Gets or sets the current on-screen X position of the pointer
  32379. */
  32380. pointerX: number;
  32381. /**
  32382. * Gets or sets the current on-screen Y position of the pointer
  32383. */
  32384. pointerY: number;
  32385. /**
  32386. * Gets the cached material (ie. the latest rendered one)
  32387. * @returns the cached material
  32388. */
  32389. getCachedMaterial(): Nullable<Material>;
  32390. /**
  32391. * Gets the cached effect (ie. the latest rendered one)
  32392. * @returns the cached effect
  32393. */
  32394. getCachedEffect(): Nullable<Effect>;
  32395. /**
  32396. * Gets the cached visibility state (ie. the latest rendered one)
  32397. * @returns the cached visibility state
  32398. */
  32399. getCachedVisibility(): Nullable<number>;
  32400. /**
  32401. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32402. * @param material defines the current material
  32403. * @param effect defines the current effect
  32404. * @param visibility defines the current visibility state
  32405. * @returns true if one parameter is not cached
  32406. */
  32407. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32408. /**
  32409. * Gets the engine associated with the scene
  32410. * @returns an Engine
  32411. */
  32412. getEngine(): Engine;
  32413. /**
  32414. * Gets the total number of vertices rendered per frame
  32415. * @returns the total number of vertices rendered per frame
  32416. */
  32417. getTotalVertices(): number;
  32418. /**
  32419. * Gets the performance counter for total vertices
  32420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32421. */
  32422. readonly totalVerticesPerfCounter: PerfCounter;
  32423. /**
  32424. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32425. * @returns the total number of active indices rendered per frame
  32426. */
  32427. getActiveIndices(): number;
  32428. /**
  32429. * Gets the performance counter for active indices
  32430. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32431. */
  32432. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32433. /**
  32434. * Gets the total number of active particles rendered per frame
  32435. * @returns the total number of active particles rendered per frame
  32436. */
  32437. getActiveParticles(): number;
  32438. /**
  32439. * Gets the performance counter for active particles
  32440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32441. */
  32442. readonly activeParticlesPerfCounter: PerfCounter;
  32443. /**
  32444. * Gets the total number of active bones rendered per frame
  32445. * @returns the total number of active bones rendered per frame
  32446. */
  32447. getActiveBones(): number;
  32448. /**
  32449. * Gets the performance counter for active bones
  32450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32451. */
  32452. readonly activeBonesPerfCounter: PerfCounter;
  32453. /**
  32454. * Gets the array of active meshes
  32455. * @returns an array of AbstractMesh
  32456. */
  32457. getActiveMeshes(): SmartArray<AbstractMesh>;
  32458. /**
  32459. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32460. * @returns a number
  32461. */
  32462. getAnimationRatio(): number;
  32463. /**
  32464. * Gets an unique Id for the current render phase
  32465. * @returns a number
  32466. */
  32467. getRenderId(): number;
  32468. /**
  32469. * Gets an unique Id for the current frame
  32470. * @returns a number
  32471. */
  32472. getFrameId(): number;
  32473. /** Call this function if you want to manually increment the render Id*/
  32474. incrementRenderId(): void;
  32475. private _updatePointerPosition;
  32476. private _createUbo;
  32477. private _createAlternateUbo;
  32478. private _setRayOnPointerInfo;
  32479. /**
  32480. * Use this method to simulate a pointer move on a mesh
  32481. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32482. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32483. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32484. * @returns the current scene
  32485. */
  32486. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32487. private _processPointerMove;
  32488. private _checkPrePointerObservable;
  32489. /**
  32490. * Use this method to simulate a pointer down on a mesh
  32491. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32492. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32493. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32494. * @returns the current scene
  32495. */
  32496. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32497. private _processPointerDown;
  32498. /**
  32499. * Use this method to simulate a pointer up on a mesh
  32500. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32501. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32502. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32503. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32504. * @returns the current scene
  32505. */
  32506. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32507. private _processPointerUp;
  32508. /**
  32509. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32510. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32511. * @returns true if the pointer was captured
  32512. */
  32513. isPointerCaptured(pointerId?: number): boolean;
  32514. /** @hidden */
  32515. _isPointerSwiping(): boolean;
  32516. /**
  32517. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32518. * @param attachUp defines if you want to attach events to pointerup
  32519. * @param attachDown defines if you want to attach events to pointerdown
  32520. * @param attachMove defines if you want to attach events to pointermove
  32521. */
  32522. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32523. /** Detaches all event handlers*/
  32524. detachControl(): void;
  32525. /**
  32526. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32527. * Delay loaded resources are not taking in account
  32528. * @return true if all required resources are ready
  32529. */
  32530. isReady(): boolean;
  32531. /** Resets all cached information relative to material (including effect and visibility) */
  32532. resetCachedMaterial(): void;
  32533. /**
  32534. * Registers a function to be called before every frame render
  32535. * @param func defines the function to register
  32536. */
  32537. registerBeforeRender(func: () => void): void;
  32538. /**
  32539. * Unregisters a function called before every frame render
  32540. * @param func defines the function to unregister
  32541. */
  32542. unregisterBeforeRender(func: () => void): void;
  32543. /**
  32544. * Registers a function to be called after every frame render
  32545. * @param func defines the function to register
  32546. */
  32547. registerAfterRender(func: () => void): void;
  32548. /**
  32549. * Unregisters a function called after every frame render
  32550. * @param func defines the function to unregister
  32551. */
  32552. unregisterAfterRender(func: () => void): void;
  32553. private _executeOnceBeforeRender;
  32554. /**
  32555. * The provided function will run before render once and will be disposed afterwards.
  32556. * A timeout delay can be provided so that the function will be executed in N ms.
  32557. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32558. * @param func The function to be executed.
  32559. * @param timeout optional delay in ms
  32560. */
  32561. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32562. /** @hidden */
  32563. _addPendingData(data: any): void;
  32564. /** @hidden */
  32565. _removePendingData(data: any): void;
  32566. /**
  32567. * Returns the number of items waiting to be loaded
  32568. * @returns the number of items waiting to be loaded
  32569. */
  32570. getWaitingItemsCount(): number;
  32571. /**
  32572. * Returns a boolean indicating if the scene is still loading data
  32573. */
  32574. readonly isLoading: boolean;
  32575. /**
  32576. * Registers a function to be executed when the scene is ready
  32577. * @param {Function} func - the function to be executed
  32578. */
  32579. executeWhenReady(func: () => void): void;
  32580. /**
  32581. * Returns a promise that resolves when the scene is ready
  32582. * @returns A promise that resolves when the scene is ready
  32583. */
  32584. whenReadyAsync(): Promise<void>;
  32585. /** @hidden */
  32586. _checkIsReady(): void;
  32587. /**
  32588. * Will start the animation sequence of a given target
  32589. * @param target defines the target
  32590. * @param from defines from which frame should animation start
  32591. * @param to defines until which frame should animation run.
  32592. * @param weight defines the weight to apply to the animation (1.0 by default)
  32593. * @param loop defines if the animation loops
  32594. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  32595. * @param onAnimationEnd defines the function to be executed when the animation ends
  32596. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  32597. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  32598. * @param onAnimationLoop defines the callback to call when an animation loops
  32599. * @returns the animatable object created for this animation
  32600. */
  32601. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  32602. /**
  32603. * Will start the animation sequence of a given target
  32604. * @param target defines the target
  32605. * @param from defines from which frame should animation start
  32606. * @param to defines until which frame should animation run.
  32607. * @param loop defines if the animation loops
  32608. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  32609. * @param onAnimationEnd defines the function to be executed when the animation ends
  32610. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  32611. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  32612. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  32613. * @param onAnimationLoop defines the callback to call when an animation loops
  32614. * @returns the animatable object created for this animation
  32615. */
  32616. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  32617. /**
  32618. * Will start the animation sequence of a given target and its hierarchy
  32619. * @param target defines the target
  32620. * @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.
  32621. * @param from defines from which frame should animation start
  32622. * @param to defines until which frame should animation run.
  32623. * @param loop defines if the animation loops
  32624. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  32625. * @param onAnimationEnd defines the function to be executed when the animation ends
  32626. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  32627. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  32628. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  32629. * @param onAnimationLoop defines the callback to call when an animation loops
  32630. * @returns the list of created animatables
  32631. */
  32632. 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[];
  32633. /**
  32634. * Begin a new animation on a given node
  32635. * @param target defines the target where the animation will take place
  32636. * @param animations defines the list of animations to start
  32637. * @param from defines the initial value
  32638. * @param to defines the final value
  32639. * @param loop defines if you want animation to loop (off by default)
  32640. * @param speedRatio defines the speed ratio to apply to all animations
  32641. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32642. * @param onAnimationLoop defines the callback to call when an animation loops
  32643. * @returns the list of created animatables
  32644. */
  32645. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  32646. /**
  32647. * Begin a new animation on a given node and its hierarchy
  32648. * @param target defines the root node where the animation will take place
  32649. * @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.
  32650. * @param animations defines the list of animations to start
  32651. * @param from defines the initial value
  32652. * @param to defines the final value
  32653. * @param loop defines if you want animation to loop (off by default)
  32654. * @param speedRatio defines the speed ratio to apply to all animations
  32655. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32656. * @param onAnimationLoop defines the callback to call when an animation loops
  32657. * @returns the list of animatables created for all nodes
  32658. */
  32659. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  32660. /**
  32661. * Gets the animatable associated with a specific target
  32662. * @param target defines the target of the animatable
  32663. * @returns the required animatable if found
  32664. */
  32665. getAnimatableByTarget(target: any): Nullable<Animatable>;
  32666. /**
  32667. * Gets all animatables associated with a given target
  32668. * @param target defines the target to look animatables for
  32669. * @returns an array of Animatables
  32670. */
  32671. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  32672. /**
  32673. * Gets all animatable attached to the scene
  32674. */
  32675. readonly animatables: Animatable[];
  32676. /**
  32677. * Will stop the animation of the given target
  32678. * @param target - the target
  32679. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32680. * @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)
  32681. */
  32682. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32683. /**
  32684. * Stops and removes all animations that have been applied to the scene
  32685. */
  32686. stopAllAnimations(): void;
  32687. /**
  32688. * Resets the last animation time frame.
  32689. * Useful to override when animations start running when loading a scene for the first time.
  32690. */
  32691. resetLastAnimationTimeFrame(): void;
  32692. private _animate;
  32693. /** @hidden */
  32694. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  32695. private _processLateAnimationBindingsForMatrices;
  32696. private _processLateAnimationBindingsForQuaternions;
  32697. private _processLateAnimationBindings;
  32698. /** @hidden */
  32699. _switchToAlternateCameraConfiguration(active: boolean): void;
  32700. /**
  32701. * Gets the current view matrix
  32702. * @returns a Matrix
  32703. */
  32704. getViewMatrix(): Matrix;
  32705. /**
  32706. * Gets the current projection matrix
  32707. * @returns a Matrix
  32708. */
  32709. getProjectionMatrix(): Matrix;
  32710. /**
  32711. * Gets the current transform matrix
  32712. * @returns a Matrix made of View * Projection
  32713. */
  32714. getTransformMatrix(): Matrix;
  32715. /**
  32716. * Sets the current transform matrix
  32717. * @param view defines the View matrix to use
  32718. * @param projection defines the Projection matrix to use
  32719. */
  32720. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32721. /** @hidden */
  32722. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32723. /**
  32724. * Gets the uniform buffer used to store scene data
  32725. * @returns a UniformBuffer
  32726. */
  32727. getSceneUniformBuffer(): UniformBuffer;
  32728. /**
  32729. * Gets an unique (relatively to the current scene) Id
  32730. * @returns an unique number for the scene
  32731. */
  32732. getUniqueId(): number;
  32733. /**
  32734. * Add a mesh to the list of scene's meshes
  32735. * @param newMesh defines the mesh to add
  32736. * @param recursive if all child meshes should also be added to the scene
  32737. */
  32738. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32739. /**
  32740. * Remove a mesh for the list of scene's meshes
  32741. * @param toRemove defines the mesh to remove
  32742. * @param recursive if all child meshes should also be removed from the scene
  32743. * @returns the index where the mesh was in the mesh list
  32744. */
  32745. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32746. /**
  32747. * Add a transform node to the list of scene's transform nodes
  32748. * @param newTransformNode defines the transform node to add
  32749. */
  32750. addTransformNode(newTransformNode: TransformNode): void;
  32751. /**
  32752. * Remove a transform node for the list of scene's transform nodes
  32753. * @param toRemove defines the transform node to remove
  32754. * @returns the index where the transform node was in the transform node list
  32755. */
  32756. removeTransformNode(toRemove: TransformNode): number;
  32757. /**
  32758. * Remove a skeleton for the list of scene's skeletons
  32759. * @param toRemove defines the skeleton to remove
  32760. * @returns the index where the skeleton was in the skeleton list
  32761. */
  32762. removeSkeleton(toRemove: Skeleton): number;
  32763. /**
  32764. * Remove a morph target for the list of scene's morph targets
  32765. * @param toRemove defines the morph target to remove
  32766. * @returns the index where the morph target was in the morph target list
  32767. */
  32768. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32769. /**
  32770. * Remove a light for the list of scene's lights
  32771. * @param toRemove defines the light to remove
  32772. * @returns the index where the light was in the light list
  32773. */
  32774. removeLight(toRemove: Light): number;
  32775. /**
  32776. * Remove a camera for the list of scene's cameras
  32777. * @param toRemove defines the camera to remove
  32778. * @returns the index where the camera was in the camera list
  32779. */
  32780. removeCamera(toRemove: Camera): number;
  32781. /**
  32782. * Remove a particle system for the list of scene's particle systems
  32783. * @param toRemove defines the particle system to remove
  32784. * @returns the index where the particle system was in the particle system list
  32785. */
  32786. removeParticleSystem(toRemove: IParticleSystem): number;
  32787. /**
  32788. * Remove a animation for the list of scene's animations
  32789. * @param toRemove defines the animation to remove
  32790. * @returns the index where the animation was in the animation list
  32791. */
  32792. removeAnimation(toRemove: Animation): number;
  32793. /**
  32794. * Removes the given animation group from this scene.
  32795. * @param toRemove The animation group to remove
  32796. * @returns The index of the removed animation group
  32797. */
  32798. removeAnimationGroup(toRemove: AnimationGroup): number;
  32799. /**
  32800. * Removes the given multi-material from this scene.
  32801. * @param toRemove The multi-material to remove
  32802. * @returns The index of the removed multi-material
  32803. */
  32804. removeMultiMaterial(toRemove: MultiMaterial): number;
  32805. /**
  32806. * Removes the given material from this scene.
  32807. * @param toRemove The material to remove
  32808. * @returns The index of the removed material
  32809. */
  32810. removeMaterial(toRemove: Material): number;
  32811. /**
  32812. * Removes the given action manager from this scene.
  32813. * @param toRemove The action manager to remove
  32814. * @returns The index of the removed action manager
  32815. */
  32816. removeActionManager(toRemove: AbstractActionManager): number;
  32817. /**
  32818. * Removes the given texture from this scene.
  32819. * @param toRemove The texture to remove
  32820. * @returns The index of the removed texture
  32821. */
  32822. removeTexture(toRemove: BaseTexture): number;
  32823. /**
  32824. * Adds the given light to this scene
  32825. * @param newLight The light to add
  32826. */
  32827. addLight(newLight: Light): void;
  32828. /**
  32829. * Sorts the list list based on light priorities
  32830. */
  32831. sortLightsByPriority(): void;
  32832. /**
  32833. * Adds the given camera to this scene
  32834. * @param newCamera The camera to add
  32835. */
  32836. addCamera(newCamera: Camera): void;
  32837. /**
  32838. * Adds the given skeleton to this scene
  32839. * @param newSkeleton The skeleton to add
  32840. */
  32841. addSkeleton(newSkeleton: Skeleton): void;
  32842. /**
  32843. * Adds the given particle system to this scene
  32844. * @param newParticleSystem The particle system to add
  32845. */
  32846. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32847. /**
  32848. * Adds the given animation to this scene
  32849. * @param newAnimation The animation to add
  32850. */
  32851. addAnimation(newAnimation: Animation): void;
  32852. /**
  32853. * Adds the given animation group to this scene.
  32854. * @param newAnimationGroup The animation group to add
  32855. */
  32856. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32857. /**
  32858. * Adds the given multi-material to this scene
  32859. * @param newMultiMaterial The multi-material to add
  32860. */
  32861. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32862. /**
  32863. * Adds the given material to this scene
  32864. * @param newMaterial The material to add
  32865. */
  32866. addMaterial(newMaterial: Material): void;
  32867. /**
  32868. * Adds the given morph target to this scene
  32869. * @param newMorphTargetManager The morph target to add
  32870. */
  32871. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32872. /**
  32873. * Adds the given geometry to this scene
  32874. * @param newGeometry The geometry to add
  32875. */
  32876. addGeometry(newGeometry: Geometry): void;
  32877. /**
  32878. * Adds the given action manager to this scene
  32879. * @param newActionManager The action manager to add
  32880. */
  32881. addActionManager(newActionManager: AbstractActionManager): void;
  32882. /**
  32883. * Adds the given texture to this scene.
  32884. * @param newTexture The texture to add
  32885. */
  32886. addTexture(newTexture: BaseTexture): void;
  32887. /**
  32888. * Switch active camera
  32889. * @param newCamera defines the new active camera
  32890. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32891. */
  32892. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32893. /**
  32894. * sets the active camera of the scene using its ID
  32895. * @param id defines the camera's ID
  32896. * @return the new active camera or null if none found.
  32897. */
  32898. setActiveCameraByID(id: string): Nullable<Camera>;
  32899. /**
  32900. * sets the active camera of the scene using its name
  32901. * @param name defines the camera's name
  32902. * @returns the new active camera or null if none found.
  32903. */
  32904. setActiveCameraByName(name: string): Nullable<Camera>;
  32905. /**
  32906. * get an animation group using its name
  32907. * @param name defines the material's name
  32908. * @return the animation group or null if none found.
  32909. */
  32910. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32911. /**
  32912. * get a material using its id
  32913. * @param id defines the material's ID
  32914. * @return the material or null if none found.
  32915. */
  32916. getMaterialByID(id: string): Nullable<Material>;
  32917. /**
  32918. * Gets a material using its name
  32919. * @param name defines the material's name
  32920. * @return the material or null if none found.
  32921. */
  32922. getMaterialByName(name: string): Nullable<Material>;
  32923. /**
  32924. * Gets a camera using its id
  32925. * @param id defines the id to look for
  32926. * @returns the camera or null if not found
  32927. */
  32928. getCameraByID(id: string): Nullable<Camera>;
  32929. /**
  32930. * Gets a camera using its unique id
  32931. * @param uniqueId defines the unique id to look for
  32932. * @returns the camera or null if not found
  32933. */
  32934. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32935. /**
  32936. * Gets a camera using its name
  32937. * @param name defines the camera's name
  32938. * @return the camera or null if none found.
  32939. */
  32940. getCameraByName(name: string): Nullable<Camera>;
  32941. /**
  32942. * Gets a bone using its id
  32943. * @param id defines the bone's id
  32944. * @return the bone or null if not found
  32945. */
  32946. getBoneByID(id: string): Nullable<Bone>;
  32947. /**
  32948. * Gets a bone using its id
  32949. * @param name defines the bone's name
  32950. * @return the bone or null if not found
  32951. */
  32952. getBoneByName(name: string): Nullable<Bone>;
  32953. /**
  32954. * Gets a light node using its name
  32955. * @param name defines the the light's name
  32956. * @return the light or null if none found.
  32957. */
  32958. getLightByName(name: string): Nullable<Light>;
  32959. /**
  32960. * Gets a light node using its id
  32961. * @param id defines the light's id
  32962. * @return the light or null if none found.
  32963. */
  32964. getLightByID(id: string): Nullable<Light>;
  32965. /**
  32966. * Gets a light node using its scene-generated unique ID
  32967. * @param uniqueId defines the light's unique id
  32968. * @return the light or null if none found.
  32969. */
  32970. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32971. /**
  32972. * Gets a particle system by id
  32973. * @param id defines the particle system id
  32974. * @return the corresponding system or null if none found
  32975. */
  32976. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32977. /**
  32978. * Gets a geometry using its ID
  32979. * @param id defines the geometry's id
  32980. * @return the geometry or null if none found.
  32981. */
  32982. getGeometryByID(id: string): Nullable<Geometry>;
  32983. private _getGeometryByUniqueID;
  32984. /**
  32985. * Add a new geometry to this scene
  32986. * @param geometry defines the geometry to be added to the scene.
  32987. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32988. * @return a boolean defining if the geometry was added or not
  32989. */
  32990. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32991. /**
  32992. * Removes an existing geometry
  32993. * @param geometry defines the geometry to be removed from the scene
  32994. * @return a boolean defining if the geometry was removed or not
  32995. */
  32996. removeGeometry(geometry: Geometry): boolean;
  32997. /**
  32998. * Gets the list of geometries attached to the scene
  32999. * @returns an array of Geometry
  33000. */
  33001. getGeometries(): Geometry[];
  33002. /**
  33003. * Gets the first added mesh found of a given ID
  33004. * @param id defines the id to search for
  33005. * @return the mesh found or null if not found at all
  33006. */
  33007. getMeshByID(id: string): Nullable<AbstractMesh>;
  33008. /**
  33009. * Gets a list of meshes using their id
  33010. * @param id defines the id to search for
  33011. * @returns a list of meshes
  33012. */
  33013. getMeshesByID(id: string): Array<AbstractMesh>;
  33014. /**
  33015. * Gets the first added transform node found of a given ID
  33016. * @param id defines the id to search for
  33017. * @return the found transform node or null if not found at all.
  33018. */
  33019. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33020. /**
  33021. * Gets a list of transform nodes using their id
  33022. * @param id defines the id to search for
  33023. * @returns a list of transform nodes
  33024. */
  33025. getTransformNodesByID(id: string): Array<TransformNode>;
  33026. /**
  33027. * Gets a mesh with its auto-generated unique id
  33028. * @param uniqueId defines the unique id to search for
  33029. * @return the found mesh or null if not found at all.
  33030. */
  33031. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33032. /**
  33033. * Gets a the last added mesh using a given id
  33034. * @param id defines the id to search for
  33035. * @return the found mesh or null if not found at all.
  33036. */
  33037. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33038. /**
  33039. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33040. * @param id defines the id to search for
  33041. * @return the found node or null if not found at all
  33042. */
  33043. getLastEntryByID(id: string): Nullable<Node>;
  33044. /**
  33045. * Gets a node (Mesh, Camera, Light) using a given id
  33046. * @param id defines the id to search for
  33047. * @return the found node or null if not found at all
  33048. */
  33049. getNodeByID(id: string): Nullable<Node>;
  33050. /**
  33051. * Gets a node (Mesh, Camera, Light) using a given name
  33052. * @param name defines the name to search for
  33053. * @return the found node or null if not found at all.
  33054. */
  33055. getNodeByName(name: string): Nullable<Node>;
  33056. /**
  33057. * Gets a mesh using a given name
  33058. * @param name defines the name to search for
  33059. * @return the found mesh or null if not found at all.
  33060. */
  33061. getMeshByName(name: string): Nullable<AbstractMesh>;
  33062. /**
  33063. * Gets a transform node using a given name
  33064. * @param name defines the name to search for
  33065. * @return the found transform node or null if not found at all.
  33066. */
  33067. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33068. /**
  33069. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33070. * @param id defines the id to search for
  33071. * @return the found skeleton or null if not found at all.
  33072. */
  33073. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33074. /**
  33075. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33076. * @param id defines the id to search for
  33077. * @return the found skeleton or null if not found at all.
  33078. */
  33079. getSkeletonById(id: string): Nullable<Skeleton>;
  33080. /**
  33081. * Gets a skeleton using a given name
  33082. * @param name defines the name to search for
  33083. * @return the found skeleton or null if not found at all.
  33084. */
  33085. getSkeletonByName(name: string): Nullable<Skeleton>;
  33086. /**
  33087. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33088. * @param id defines the id to search for
  33089. * @return the found morph target manager or null if not found at all.
  33090. */
  33091. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33092. /**
  33093. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33094. * @param id defines the id to search for
  33095. * @return the found morph target or null if not found at all.
  33096. */
  33097. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33098. /**
  33099. * Gets a boolean indicating if the given mesh is active
  33100. * @param mesh defines the mesh to look for
  33101. * @returns true if the mesh is in the active list
  33102. */
  33103. isActiveMesh(mesh: AbstractMesh): boolean;
  33104. /**
  33105. * Return a unique id as a string which can serve as an identifier for the scene
  33106. */
  33107. readonly uid: string;
  33108. /**
  33109. * Add an externaly attached data from its key.
  33110. * This method call will fail and return false, if such key already exists.
  33111. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33112. * @param key the unique key that identifies the data
  33113. * @param data the data object to associate to the key for this Engine instance
  33114. * @return true if no such key were already present and the data was added successfully, false otherwise
  33115. */
  33116. addExternalData<T>(key: string, data: T): boolean;
  33117. /**
  33118. * Get an externaly attached data from its key
  33119. * @param key the unique key that identifies the data
  33120. * @return the associated data, if present (can be null), or undefined if not present
  33121. */
  33122. getExternalData<T>(key: string): Nullable<T>;
  33123. /**
  33124. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33125. * @param key the unique key that identifies the data
  33126. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33127. * @return the associated data, can be null if the factory returned null.
  33128. */
  33129. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33130. /**
  33131. * Remove an externaly attached data from the Engine instance
  33132. * @param key the unique key that identifies the data
  33133. * @return true if the data was successfully removed, false if it doesn't exist
  33134. */
  33135. removeExternalData(key: string): boolean;
  33136. private _evaluateSubMesh;
  33137. /**
  33138. * Clear the processed materials smart array preventing retention point in material dispose.
  33139. */
  33140. freeProcessedMaterials(): void;
  33141. private _preventFreeActiveMeshesAndRenderingGroups;
  33142. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33143. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33144. * when disposing several meshes in a row or a hierarchy of meshes.
  33145. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33146. */
  33147. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33148. /**
  33149. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33150. */
  33151. freeActiveMeshes(): void;
  33152. /**
  33153. * Clear the info related to rendering groups preventing retention points during dispose.
  33154. */
  33155. freeRenderingGroups(): void;
  33156. /** @hidden */
  33157. _isInIntermediateRendering(): boolean;
  33158. /**
  33159. * Lambda returning the list of potentially active meshes.
  33160. */
  33161. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33162. /**
  33163. * Lambda returning the list of potentially active sub meshes.
  33164. */
  33165. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33166. /**
  33167. * Lambda returning the list of potentially intersecting sub meshes.
  33168. */
  33169. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33170. /**
  33171. * Lambda returning the list of potentially colliding sub meshes.
  33172. */
  33173. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33174. private _activeMeshesFrozen;
  33175. /**
  33176. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33177. * @returns the current scene
  33178. */
  33179. freezeActiveMeshes(): Scene;
  33180. /**
  33181. * Use this function to restart evaluating active meshes on every frame
  33182. * @returns the current scene
  33183. */
  33184. unfreezeActiveMeshes(): Scene;
  33185. private _evaluateActiveMeshes;
  33186. private _activeMesh;
  33187. /**
  33188. * Update the transform matrix to update from the current active camera
  33189. * @param force defines a boolean used to force the update even if cache is up to date
  33190. */
  33191. updateTransformMatrix(force?: boolean): void;
  33192. /**
  33193. * 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)
  33194. * @param alternateCamera defines the camera to use
  33195. */
  33196. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33197. /** @hidden */
  33198. _allowPostProcessClearColor: boolean;
  33199. private _renderForCamera;
  33200. private _processSubCameras;
  33201. private _checkIntersections;
  33202. /** @hidden */
  33203. _advancePhysicsEngineStep(step: number): void;
  33204. /**
  33205. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33206. */
  33207. getDeterministicFrameTime: () => number;
  33208. /**
  33209. * Render the scene
  33210. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33211. */
  33212. render(updateCameras?: boolean): void;
  33213. /**
  33214. * Freeze all materials
  33215. * A frozen material will not be updatable but should be faster to render
  33216. */
  33217. freezeMaterials(): void;
  33218. /**
  33219. * Unfreeze all materials
  33220. * A frozen material will not be updatable but should be faster to render
  33221. */
  33222. unfreezeMaterials(): void;
  33223. /**
  33224. * Releases all held ressources
  33225. */
  33226. dispose(): void;
  33227. /**
  33228. * Gets if the scene is already disposed
  33229. */
  33230. readonly isDisposed: boolean;
  33231. /**
  33232. * Call this function to reduce memory footprint of the scene.
  33233. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33234. */
  33235. clearCachedVertexData(): void;
  33236. /**
  33237. * This function will remove the local cached buffer data from texture.
  33238. * It will save memory but will prevent the texture from being rebuilt
  33239. */
  33240. cleanCachedTextureBuffer(): void;
  33241. /**
  33242. * Get the world extend vectors with an optional filter
  33243. *
  33244. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33245. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33246. */
  33247. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33248. min: Vector3;
  33249. max: Vector3;
  33250. };
  33251. /**
  33252. * Creates a ray that can be used to pick in the scene
  33253. * @param x defines the x coordinate of the origin (on-screen)
  33254. * @param y defines the y coordinate of the origin (on-screen)
  33255. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33256. * @param camera defines the camera to use for the picking
  33257. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33258. * @returns a Ray
  33259. */
  33260. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33261. /**
  33262. * Creates a ray that can be used to pick in the scene
  33263. * @param x defines the x coordinate of the origin (on-screen)
  33264. * @param y defines the y coordinate of the origin (on-screen)
  33265. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33266. * @param result defines the ray where to store the picking ray
  33267. * @param camera defines the camera to use for the picking
  33268. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33269. * @returns the current scene
  33270. */
  33271. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33272. /**
  33273. * Creates a ray that can be used to pick in the scene
  33274. * @param x defines the x coordinate of the origin (on-screen)
  33275. * @param y defines the y coordinate of the origin (on-screen)
  33276. * @param camera defines the camera to use for the picking
  33277. * @returns a Ray
  33278. */
  33279. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33280. /**
  33281. * Creates a ray that can be used to pick in the scene
  33282. * @param x defines the x coordinate of the origin (on-screen)
  33283. * @param y defines the y coordinate of the origin (on-screen)
  33284. * @param result defines the ray where to store the picking ray
  33285. * @param camera defines the camera to use for the picking
  33286. * @returns the current scene
  33287. */
  33288. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33289. private _internalPick;
  33290. private _internalMultiPick;
  33291. private _tempPickingRay;
  33292. /** Launch a ray to try to pick a mesh in the scene
  33293. * @param x position on screen
  33294. * @param y position on screen
  33295. * @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
  33296. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33297. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33298. * @returns a PickingInfo
  33299. */
  33300. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33301. private _cachedRayForTransform;
  33302. /** Use the given ray to pick a mesh in the scene
  33303. * @param ray The ray to use to pick meshes
  33304. * @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
  33305. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33306. * @returns a PickingInfo
  33307. */
  33308. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33309. /**
  33310. * Launch a ray to try to pick a mesh in the scene
  33311. * @param x X position on screen
  33312. * @param y Y position on screen
  33313. * @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
  33314. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33315. * @returns an array of PickingInfo
  33316. */
  33317. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33318. /**
  33319. * Launch a ray to try to pick a mesh in the scene
  33320. * @param ray Ray to use
  33321. * @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
  33322. * @returns an array of PickingInfo
  33323. */
  33324. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33325. /**
  33326. * Force the value of meshUnderPointer
  33327. * @param mesh defines the mesh to use
  33328. */
  33329. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33330. /**
  33331. * Gets the mesh under the pointer
  33332. * @returns a Mesh or null if no mesh is under the pointer
  33333. */
  33334. getPointerOverMesh(): Nullable<AbstractMesh>;
  33335. /** @hidden */
  33336. _rebuildGeometries(): void;
  33337. /** @hidden */
  33338. _rebuildTextures(): void;
  33339. private _getByTags;
  33340. /**
  33341. * Get a list of meshes by tags
  33342. * @param tagsQuery defines the tags query to use
  33343. * @param forEach defines a predicate used to filter results
  33344. * @returns an array of Mesh
  33345. */
  33346. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33347. /**
  33348. * Get a list of cameras by tags
  33349. * @param tagsQuery defines the tags query to use
  33350. * @param forEach defines a predicate used to filter results
  33351. * @returns an array of Camera
  33352. */
  33353. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33354. /**
  33355. * Get a list of lights by tags
  33356. * @param tagsQuery defines the tags query to use
  33357. * @param forEach defines a predicate used to filter results
  33358. * @returns an array of Light
  33359. */
  33360. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33361. /**
  33362. * Get a list of materials by tags
  33363. * @param tagsQuery defines the tags query to use
  33364. * @param forEach defines a predicate used to filter results
  33365. * @returns an array of Material
  33366. */
  33367. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33368. /**
  33369. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33370. * This allowed control for front to back rendering or reversly depending of the special needs.
  33371. *
  33372. * @param renderingGroupId The rendering group id corresponding to its index
  33373. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33374. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33375. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33376. */
  33377. 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;
  33378. /**
  33379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33380. *
  33381. * @param renderingGroupId The rendering group id corresponding to its index
  33382. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33383. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33384. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33385. */
  33386. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33387. /**
  33388. * Gets the current auto clear configuration for one rendering group of the rendering
  33389. * manager.
  33390. * @param index the rendering group index to get the information for
  33391. * @returns The auto clear setup for the requested rendering group
  33392. */
  33393. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33394. private _blockMaterialDirtyMechanism;
  33395. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33396. blockMaterialDirtyMechanism: boolean;
  33397. /**
  33398. * Will flag all materials as dirty to trigger new shader compilation
  33399. * @param flag defines the flag used to specify which material part must be marked as dirty
  33400. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33401. */
  33402. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33403. /** @hidden */
  33404. _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;
  33405. /** @hidden */
  33406. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33407. }
  33408. }
  33409. declare module "babylonjs/assetContainer" {
  33410. import { AbstractScene } from "babylonjs/abstractScene";
  33411. import { Scene } from "babylonjs/scene";
  33412. import { Mesh } from "babylonjs/Meshes/mesh";
  33413. /**
  33414. * Set of assets to keep when moving a scene into an asset container.
  33415. */
  33416. export class KeepAssets extends AbstractScene {
  33417. }
  33418. /**
  33419. * Container with a set of assets that can be added or removed from a scene.
  33420. */
  33421. export class AssetContainer extends AbstractScene {
  33422. /**
  33423. * The scene the AssetContainer belongs to.
  33424. */
  33425. scene: Scene;
  33426. /**
  33427. * Instantiates an AssetContainer.
  33428. * @param scene The scene the AssetContainer belongs to.
  33429. */
  33430. constructor(scene: Scene);
  33431. /**
  33432. * Adds all the assets from the container to the scene.
  33433. */
  33434. addAllToScene(): void;
  33435. /**
  33436. * Removes all the assets in the container from the scene
  33437. */
  33438. removeAllFromScene(): void;
  33439. /**
  33440. * Disposes all the assets in the container
  33441. */
  33442. dispose(): void;
  33443. private _moveAssets;
  33444. /**
  33445. * Removes all the assets contained in the scene and adds them to the container.
  33446. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33447. */
  33448. moveAllFromScene(keepAssets?: KeepAssets): void;
  33449. /**
  33450. * 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.
  33451. * @returns the root mesh
  33452. */
  33453. createRootMesh(): Mesh;
  33454. }
  33455. }
  33456. declare module "babylonjs/abstractScene" {
  33457. import { Scene } from "babylonjs/scene";
  33458. import { Nullable } from "babylonjs/types";
  33459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33460. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33461. import { Geometry } from "babylonjs/Meshes/geometry";
  33462. import { Skeleton } from "babylonjs/Bones/skeleton";
  33463. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33464. import { AssetContainer } from "babylonjs/assetContainer";
  33465. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33466. import { Animation } from "babylonjs/Animations/animation";
  33467. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33469. import { Material } from "babylonjs/Materials/material";
  33470. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33471. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33472. import { Camera } from "babylonjs/Cameras/camera";
  33473. import { Light } from "babylonjs/Lights/light";
  33474. import { Node } from "babylonjs/node";
  33475. /**
  33476. * Defines how the parser contract is defined.
  33477. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33478. */
  33479. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33480. /**
  33481. * Defines how the individual parser contract is defined.
  33482. * These parser can parse an individual asset
  33483. */
  33484. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33485. /**
  33486. * Base class of the scene acting as a container for the different elements composing a scene.
  33487. * This class is dynamically extended by the different components of the scene increasing
  33488. * flexibility and reducing coupling
  33489. */
  33490. export abstract class AbstractScene {
  33491. /**
  33492. * Stores the list of available parsers in the application.
  33493. */
  33494. private static _BabylonFileParsers;
  33495. /**
  33496. * Stores the list of available individual parsers in the application.
  33497. */
  33498. private static _IndividualBabylonFileParsers;
  33499. /**
  33500. * Adds a parser in the list of available ones
  33501. * @param name Defines the name of the parser
  33502. * @param parser Defines the parser to add
  33503. */
  33504. static AddParser(name: string, parser: BabylonFileParser): void;
  33505. /**
  33506. * Gets a general parser from the list of avaialble ones
  33507. * @param name Defines the name of the parser
  33508. * @returns the requested parser or null
  33509. */
  33510. static GetParser(name: string): Nullable<BabylonFileParser>;
  33511. /**
  33512. * Adds n individual parser in the list of available ones
  33513. * @param name Defines the name of the parser
  33514. * @param parser Defines the parser to add
  33515. */
  33516. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33517. /**
  33518. * Gets an individual parser from the list of avaialble ones
  33519. * @param name Defines the name of the parser
  33520. * @returns the requested parser or null
  33521. */
  33522. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33523. /**
  33524. * Parser json data and populate both a scene and its associated container object
  33525. * @param jsonData Defines the data to parse
  33526. * @param scene Defines the scene to parse the data for
  33527. * @param container Defines the container attached to the parsing sequence
  33528. * @param rootUrl Defines the root url of the data
  33529. */
  33530. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33531. /**
  33532. * Gets the list of root nodes (ie. nodes with no parent)
  33533. */
  33534. rootNodes: Node[];
  33535. /** All of the cameras added to this scene
  33536. * @see http://doc.babylonjs.com/babylon101/cameras
  33537. */
  33538. cameras: Camera[];
  33539. /**
  33540. * All of the lights added to this scene
  33541. * @see http://doc.babylonjs.com/babylon101/lights
  33542. */
  33543. lights: Light[];
  33544. /**
  33545. * All of the (abstract) meshes added to this scene
  33546. */
  33547. meshes: AbstractMesh[];
  33548. /**
  33549. * The list of skeletons added to the scene
  33550. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33551. */
  33552. skeletons: Skeleton[];
  33553. /**
  33554. * All of the particle systems added to this scene
  33555. * @see http://doc.babylonjs.com/babylon101/particles
  33556. */
  33557. particleSystems: IParticleSystem[];
  33558. /**
  33559. * Gets a list of Animations associated with the scene
  33560. */
  33561. animations: Animation[];
  33562. /**
  33563. * All of the animation groups added to this scene
  33564. * @see http://doc.babylonjs.com/how_to/group
  33565. */
  33566. animationGroups: AnimationGroup[];
  33567. /**
  33568. * All of the multi-materials added to this scene
  33569. * @see http://doc.babylonjs.com/how_to/multi_materials
  33570. */
  33571. multiMaterials: MultiMaterial[];
  33572. /**
  33573. * All of the materials added to this scene
  33574. * In the context of a Scene, it is not supposed to be modified manually.
  33575. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33576. * Note also that the order of the Material wihin the array is not significant and might change.
  33577. * @see http://doc.babylonjs.com/babylon101/materials
  33578. */
  33579. materials: Material[];
  33580. /**
  33581. * The list of morph target managers added to the scene
  33582. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33583. */
  33584. morphTargetManagers: MorphTargetManager[];
  33585. /**
  33586. * The list of geometries used in the scene.
  33587. */
  33588. geometries: Geometry[];
  33589. /**
  33590. * All of the tranform nodes added to this scene
  33591. * In the context of a Scene, it is not supposed to be modified manually.
  33592. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33593. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33594. * @see http://doc.babylonjs.com/how_to/transformnode
  33595. */
  33596. transformNodes: TransformNode[];
  33597. /**
  33598. * ActionManagers available on the scene.
  33599. */
  33600. actionManagers: AbstractActionManager[];
  33601. /**
  33602. * Textures to keep.
  33603. */
  33604. textures: BaseTexture[];
  33605. }
  33606. }
  33607. declare module "babylonjs/Audio/sound" {
  33608. import { Observable } from "babylonjs/Misc/observable";
  33609. import { Vector3 } from "babylonjs/Maths/math";
  33610. import { Nullable } from "babylonjs/types";
  33611. import { Scene } from "babylonjs/scene";
  33612. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33613. /**
  33614. * Defines a sound that can be played in the application.
  33615. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33617. */
  33618. export class Sound {
  33619. /**
  33620. * The name of the sound in the scene.
  33621. */
  33622. name: string;
  33623. /**
  33624. * Does the sound autoplay once loaded.
  33625. */
  33626. autoplay: boolean;
  33627. /**
  33628. * Does the sound loop after it finishes playing once.
  33629. */
  33630. loop: boolean;
  33631. /**
  33632. * Does the sound use a custom attenuation curve to simulate the falloff
  33633. * happening when the source gets further away from the camera.
  33634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33635. */
  33636. useCustomAttenuation: boolean;
  33637. /**
  33638. * The sound track id this sound belongs to.
  33639. */
  33640. soundTrackId: number;
  33641. /**
  33642. * Is this sound currently played.
  33643. */
  33644. isPlaying: boolean;
  33645. /**
  33646. * Is this sound currently paused.
  33647. */
  33648. isPaused: boolean;
  33649. /**
  33650. * Does this sound enables spatial sound.
  33651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33652. */
  33653. spatialSound: boolean;
  33654. /**
  33655. * Define the reference distance the sound should be heard perfectly.
  33656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33657. */
  33658. refDistance: number;
  33659. /**
  33660. * Define the roll off factor of spatial sounds.
  33661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33662. */
  33663. rolloffFactor: number;
  33664. /**
  33665. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33667. */
  33668. maxDistance: number;
  33669. /**
  33670. * Define the distance attenuation model the sound will follow.
  33671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33672. */
  33673. distanceModel: string;
  33674. /**
  33675. * @hidden
  33676. * Back Compat
  33677. **/
  33678. onended: () => any;
  33679. /**
  33680. * Observable event when the current playing sound finishes.
  33681. */
  33682. onEndedObservable: Observable<Sound>;
  33683. private _panningModel;
  33684. private _playbackRate;
  33685. private _streaming;
  33686. private _startTime;
  33687. private _startOffset;
  33688. private _position;
  33689. /** @hidden */
  33690. _positionInEmitterSpace: boolean;
  33691. private _localDirection;
  33692. private _volume;
  33693. private _isReadyToPlay;
  33694. private _isDirectional;
  33695. private _readyToPlayCallback;
  33696. private _audioBuffer;
  33697. private _soundSource;
  33698. private _streamingSource;
  33699. private _soundPanner;
  33700. private _soundGain;
  33701. private _inputAudioNode;
  33702. private _outputAudioNode;
  33703. private _coneInnerAngle;
  33704. private _coneOuterAngle;
  33705. private _coneOuterGain;
  33706. private _scene;
  33707. private _connectedTransformNode;
  33708. private _customAttenuationFunction;
  33709. private _registerFunc;
  33710. private _isOutputConnected;
  33711. private _htmlAudioElement;
  33712. private _urlType;
  33713. /** @hidden */
  33714. static _SceneComponentInitialization: (scene: Scene) => void;
  33715. /**
  33716. * Create a sound and attach it to a scene
  33717. * @param name Name of your sound
  33718. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33719. * @param scene defines the scene the sound belongs to
  33720. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33721. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33722. */
  33723. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33724. /**
  33725. * Release the sound and its associated resources
  33726. */
  33727. dispose(): void;
  33728. /**
  33729. * Gets if the sounds is ready to be played or not.
  33730. * @returns true if ready, otherwise false
  33731. */
  33732. isReady(): boolean;
  33733. private _soundLoaded;
  33734. /**
  33735. * Sets the data of the sound from an audiobuffer
  33736. * @param audioBuffer The audioBuffer containing the data
  33737. */
  33738. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33739. /**
  33740. * Updates the current sounds options such as maxdistance, loop...
  33741. * @param options A JSON object containing values named as the object properties
  33742. */
  33743. updateOptions(options: any): void;
  33744. private _createSpatialParameters;
  33745. private _updateSpatialParameters;
  33746. /**
  33747. * Switch the panning model to HRTF:
  33748. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33750. */
  33751. switchPanningModelToHRTF(): void;
  33752. /**
  33753. * Switch the panning model to Equal Power:
  33754. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33756. */
  33757. switchPanningModelToEqualPower(): void;
  33758. private _switchPanningModel;
  33759. /**
  33760. * Connect this sound to a sound track audio node like gain...
  33761. * @param soundTrackAudioNode the sound track audio node to connect to
  33762. */
  33763. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33764. /**
  33765. * Transform this sound into a directional source
  33766. * @param coneInnerAngle Size of the inner cone in degree
  33767. * @param coneOuterAngle Size of the outer cone in degree
  33768. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33769. */
  33770. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33771. /**
  33772. * Gets or sets the inner angle for the directional cone.
  33773. */
  33774. /**
  33775. * Gets or sets the inner angle for the directional cone.
  33776. */
  33777. directionalConeInnerAngle: number;
  33778. /**
  33779. * Gets or sets the outer angle for the directional cone.
  33780. */
  33781. /**
  33782. * Gets or sets the outer angle for the directional cone.
  33783. */
  33784. directionalConeOuterAngle: number;
  33785. /**
  33786. * Sets the position of the emitter if spatial sound is enabled
  33787. * @param newPosition Defines the new posisiton
  33788. */
  33789. setPosition(newPosition: Vector3): void;
  33790. /**
  33791. * Sets the local direction of the emitter if spatial sound is enabled
  33792. * @param newLocalDirection Defines the new local direction
  33793. */
  33794. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33795. private _updateDirection;
  33796. /** @hidden */
  33797. updateDistanceFromListener(): void;
  33798. /**
  33799. * Sets a new custom attenuation function for the sound.
  33800. * @param callback Defines the function used for the attenuation
  33801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33802. */
  33803. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33804. /**
  33805. * Play the sound
  33806. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33807. * @param offset (optional) Start the sound setting it at a specific time
  33808. */
  33809. play(time?: number, offset?: number): void;
  33810. private _onended;
  33811. /**
  33812. * Stop the sound
  33813. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33814. */
  33815. stop(time?: number): void;
  33816. /**
  33817. * Put the sound in pause
  33818. */
  33819. pause(): void;
  33820. /**
  33821. * Sets a dedicated volume for this sounds
  33822. * @param newVolume Define the new volume of the sound
  33823. * @param time Define in how long the sound should be at this value
  33824. */
  33825. setVolume(newVolume: number, time?: number): void;
  33826. /**
  33827. * Set the sound play back rate
  33828. * @param newPlaybackRate Define the playback rate the sound should be played at
  33829. */
  33830. setPlaybackRate(newPlaybackRate: number): void;
  33831. /**
  33832. * Gets the volume of the sound.
  33833. * @returns the volume of the sound
  33834. */
  33835. getVolume(): number;
  33836. /**
  33837. * Attach the sound to a dedicated mesh
  33838. * @param transformNode The transform node to connect the sound with
  33839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33840. */
  33841. attachToMesh(transformNode: TransformNode): void;
  33842. /**
  33843. * Detach the sound from the previously attached mesh
  33844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33845. */
  33846. detachFromMesh(): void;
  33847. private _onRegisterAfterWorldMatrixUpdate;
  33848. /**
  33849. * Clone the current sound in the scene.
  33850. * @returns the new sound clone
  33851. */
  33852. clone(): Nullable<Sound>;
  33853. /**
  33854. * Gets the current underlying audio buffer containing the data
  33855. * @returns the audio buffer
  33856. */
  33857. getAudioBuffer(): Nullable<AudioBuffer>;
  33858. /**
  33859. * Serializes the Sound in a JSON representation
  33860. * @returns the JSON representation of the sound
  33861. */
  33862. serialize(): any;
  33863. /**
  33864. * Parse a JSON representation of a sound to innstantiate in a given scene
  33865. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33866. * @param scene Define the scene the new parsed sound should be created in
  33867. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33868. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33869. * @returns the newly parsed sound
  33870. */
  33871. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33872. }
  33873. }
  33874. declare module "babylonjs/Actions/directAudioActions" {
  33875. import { Action } from "babylonjs/Actions/action";
  33876. import { Condition } from "babylonjs/Actions/condition";
  33877. import { Sound } from "babylonjs/Audio/sound";
  33878. /**
  33879. * This defines an action helpful to play a defined sound on a triggered action.
  33880. */
  33881. export class PlaySoundAction extends Action {
  33882. private _sound;
  33883. /**
  33884. * Instantiate the action
  33885. * @param triggerOptions defines the trigger options
  33886. * @param sound defines the sound to play
  33887. * @param condition defines the trigger related conditions
  33888. */
  33889. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33890. /** @hidden */
  33891. _prepare(): void;
  33892. /**
  33893. * Execute the action and play the sound.
  33894. */
  33895. execute(): void;
  33896. /**
  33897. * Serializes the actions and its related information.
  33898. * @param parent defines the object to serialize in
  33899. * @returns the serialized object
  33900. */
  33901. serialize(parent: any): any;
  33902. }
  33903. /**
  33904. * This defines an action helpful to stop a defined sound on a triggered action.
  33905. */
  33906. export class StopSoundAction extends Action {
  33907. private _sound;
  33908. /**
  33909. * Instantiate the action
  33910. * @param triggerOptions defines the trigger options
  33911. * @param sound defines the sound to stop
  33912. * @param condition defines the trigger related conditions
  33913. */
  33914. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33915. /** @hidden */
  33916. _prepare(): void;
  33917. /**
  33918. * Execute the action and stop the sound.
  33919. */
  33920. execute(): void;
  33921. /**
  33922. * Serializes the actions and its related information.
  33923. * @param parent defines the object to serialize in
  33924. * @returns the serialized object
  33925. */
  33926. serialize(parent: any): any;
  33927. }
  33928. }
  33929. declare module "babylonjs/Actions/interpolateValueAction" {
  33930. import { Action } from "babylonjs/Actions/action";
  33931. import { Condition } from "babylonjs/Actions/condition";
  33932. import { Observable } from "babylonjs/Misc/observable";
  33933. /**
  33934. * This defines an action responsible to change the value of a property
  33935. * by interpolating between its current value and the newly set one once triggered.
  33936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33937. */
  33938. export class InterpolateValueAction extends Action {
  33939. /**
  33940. * Defines the path of the property where the value should be interpolated
  33941. */
  33942. propertyPath: string;
  33943. /**
  33944. * Defines the target value at the end of the interpolation.
  33945. */
  33946. value: any;
  33947. /**
  33948. * Defines the time it will take for the property to interpolate to the value.
  33949. */
  33950. duration: number;
  33951. /**
  33952. * Defines if the other scene animations should be stopped when the action has been triggered
  33953. */
  33954. stopOtherAnimations?: boolean;
  33955. /**
  33956. * Defines a callback raised once the interpolation animation has been done.
  33957. */
  33958. onInterpolationDone?: () => void;
  33959. /**
  33960. * Observable triggered once the interpolation animation has been done.
  33961. */
  33962. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33963. private _target;
  33964. private _effectiveTarget;
  33965. private _property;
  33966. /**
  33967. * Instantiate the action
  33968. * @param triggerOptions defines the trigger options
  33969. * @param target defines the object containing the value to interpolate
  33970. * @param propertyPath defines the path to the property in the target object
  33971. * @param value defines the target value at the end of the interpolation
  33972. * @param duration deines the time it will take for the property to interpolate to the value.
  33973. * @param condition defines the trigger related conditions
  33974. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33975. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33976. */
  33977. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33978. /** @hidden */
  33979. _prepare(): void;
  33980. /**
  33981. * Execute the action starts the value interpolation.
  33982. */
  33983. execute(): void;
  33984. /**
  33985. * Serializes the actions and its related information.
  33986. * @param parent defines the object to serialize in
  33987. * @returns the serialized object
  33988. */
  33989. serialize(parent: any): any;
  33990. }
  33991. }
  33992. declare module "babylonjs/Actions/index" {
  33993. export * from "babylonjs/Actions/action";
  33994. export * from "babylonjs/Actions/actionEvent";
  33995. export * from "babylonjs/Actions/actionManager";
  33996. export * from "babylonjs/Actions/condition";
  33997. export * from "babylonjs/Actions/directActions";
  33998. export * from "babylonjs/Actions/directAudioActions";
  33999. export * from "babylonjs/Actions/interpolateValueAction";
  34000. }
  34001. declare module "babylonjs/Animations/index" {
  34002. export * from "babylonjs/Animations/animatable";
  34003. export * from "babylonjs/Animations/animation";
  34004. export * from "babylonjs/Animations/animationGroup";
  34005. export * from "babylonjs/Animations/animationPropertiesOverride";
  34006. export * from "babylonjs/Animations/easing";
  34007. export * from "babylonjs/Animations/runtimeAnimation";
  34008. }
  34009. declare module "babylonjs/Audio/soundTrack" {
  34010. import { Sound } from "babylonjs/Audio/sound";
  34011. import { Analyser } from "babylonjs/Audio/analyser";
  34012. import { Scene } from "babylonjs/scene";
  34013. /**
  34014. * Options allowed during the creation of a sound track.
  34015. */
  34016. export interface ISoundTrackOptions {
  34017. /**
  34018. * The volume the sound track should take during creation
  34019. */
  34020. volume?: number;
  34021. /**
  34022. * Define if the sound track is the main sound track of the scene
  34023. */
  34024. mainTrack?: boolean;
  34025. }
  34026. /**
  34027. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34028. * It will be also used in a future release to apply effects on a specific track.
  34029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34030. */
  34031. export class SoundTrack {
  34032. /**
  34033. * The unique identifier of the sound track in the scene.
  34034. */
  34035. id: number;
  34036. /**
  34037. * The list of sounds included in the sound track.
  34038. */
  34039. soundCollection: Array<Sound>;
  34040. private _outputAudioNode;
  34041. private _scene;
  34042. private _isMainTrack;
  34043. private _connectedAnalyser;
  34044. private _options;
  34045. private _isInitialized;
  34046. /**
  34047. * Creates a new sound track.
  34048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34049. * @param scene Define the scene the sound track belongs to
  34050. * @param options
  34051. */
  34052. constructor(scene: Scene, options?: ISoundTrackOptions);
  34053. private _initializeSoundTrackAudioGraph;
  34054. /**
  34055. * Release the sound track and its associated resources
  34056. */
  34057. dispose(): void;
  34058. /**
  34059. * Adds a sound to this sound track
  34060. * @param sound define the cound to add
  34061. * @ignoreNaming
  34062. */
  34063. AddSound(sound: Sound): void;
  34064. /**
  34065. * Removes a sound to this sound track
  34066. * @param sound define the cound to remove
  34067. * @ignoreNaming
  34068. */
  34069. RemoveSound(sound: Sound): void;
  34070. /**
  34071. * Set a global volume for the full sound track.
  34072. * @param newVolume Define the new volume of the sound track
  34073. */
  34074. setVolume(newVolume: number): void;
  34075. /**
  34076. * Switch the panning model to HRTF:
  34077. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34079. */
  34080. switchPanningModelToHRTF(): void;
  34081. /**
  34082. * Switch the panning model to Equal Power:
  34083. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34085. */
  34086. switchPanningModelToEqualPower(): void;
  34087. /**
  34088. * Connect the sound track to an audio analyser allowing some amazing
  34089. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34091. * @param analyser The analyser to connect to the engine
  34092. */
  34093. connectToAnalyser(analyser: Analyser): void;
  34094. }
  34095. }
  34096. declare module "babylonjs/Audio/audioSceneComponent" {
  34097. import { Sound } from "babylonjs/Audio/sound";
  34098. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34099. import { Nullable } from "babylonjs/types";
  34100. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34101. import { Scene } from "babylonjs/scene";
  34102. import { AbstractScene } from "babylonjs/abstractScene";
  34103. module "babylonjs/abstractScene" {
  34104. interface AbstractScene {
  34105. /**
  34106. * The list of sounds used in the scene.
  34107. */
  34108. sounds: Nullable<Array<Sound>>;
  34109. }
  34110. }
  34111. module "babylonjs/scene" {
  34112. interface Scene {
  34113. /**
  34114. * @hidden
  34115. * Backing field
  34116. */
  34117. _mainSoundTrack: SoundTrack;
  34118. /**
  34119. * The main sound track played by the scene.
  34120. * It cotains your primary collection of sounds.
  34121. */
  34122. mainSoundTrack: SoundTrack;
  34123. /**
  34124. * The list of sound tracks added to the scene
  34125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34126. */
  34127. soundTracks: Nullable<Array<SoundTrack>>;
  34128. /**
  34129. * Gets a sound using a given name
  34130. * @param name defines the name to search for
  34131. * @return the found sound or null if not found at all.
  34132. */
  34133. getSoundByName(name: string): Nullable<Sound>;
  34134. /**
  34135. * Gets or sets if audio support is enabled
  34136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34137. */
  34138. audioEnabled: boolean;
  34139. /**
  34140. * Gets or sets if audio will be output to headphones
  34141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34142. */
  34143. headphone: boolean;
  34144. }
  34145. }
  34146. /**
  34147. * Defines the sound scene component responsible to manage any sounds
  34148. * in a given scene.
  34149. */
  34150. export class AudioSceneComponent implements ISceneSerializableComponent {
  34151. /**
  34152. * The component name helpfull to identify the component in the list of scene components.
  34153. */
  34154. readonly name: string;
  34155. /**
  34156. * The scene the component belongs to.
  34157. */
  34158. scene: Scene;
  34159. private _audioEnabled;
  34160. /**
  34161. * Gets whether audio is enabled or not.
  34162. * Please use related enable/disable method to switch state.
  34163. */
  34164. readonly audioEnabled: boolean;
  34165. private _headphone;
  34166. /**
  34167. * Gets whether audio is outputing to headphone or not.
  34168. * Please use the according Switch methods to change output.
  34169. */
  34170. readonly headphone: boolean;
  34171. /**
  34172. * Creates a new instance of the component for the given scene
  34173. * @param scene Defines the scene to register the component in
  34174. */
  34175. constructor(scene: Scene);
  34176. /**
  34177. * Registers the component in a given scene
  34178. */
  34179. register(): void;
  34180. /**
  34181. * Rebuilds the elements related to this component in case of
  34182. * context lost for instance.
  34183. */
  34184. rebuild(): void;
  34185. /**
  34186. * Serializes the component data to the specified json object
  34187. * @param serializationObject The object to serialize to
  34188. */
  34189. serialize(serializationObject: any): void;
  34190. /**
  34191. * Adds all the element from the container to the scene
  34192. * @param container the container holding the elements
  34193. */
  34194. addFromContainer(container: AbstractScene): void;
  34195. /**
  34196. * Removes all the elements in the container from the scene
  34197. * @param container contains the elements to remove
  34198. */
  34199. removeFromContainer(container: AbstractScene): void;
  34200. /**
  34201. * Disposes the component and the associated ressources.
  34202. */
  34203. dispose(): void;
  34204. /**
  34205. * Disables audio in the associated scene.
  34206. */
  34207. disableAudio(): void;
  34208. /**
  34209. * Enables audio in the associated scene.
  34210. */
  34211. enableAudio(): void;
  34212. /**
  34213. * Switch audio to headphone output.
  34214. */
  34215. switchAudioModeForHeadphones(): void;
  34216. /**
  34217. * Switch audio to normal speakers.
  34218. */
  34219. switchAudioModeForNormalSpeakers(): void;
  34220. private _afterRender;
  34221. }
  34222. }
  34223. declare module "babylonjs/Audio/weightedsound" {
  34224. import { Sound } from "babylonjs/Audio/sound";
  34225. /**
  34226. * Wraps one or more Sound objects and selects one with random weight for playback.
  34227. */
  34228. export class WeightedSound {
  34229. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34230. loop: boolean;
  34231. private _coneInnerAngle;
  34232. private _coneOuterAngle;
  34233. private _volume;
  34234. /** A Sound is currently playing. */
  34235. isPlaying: boolean;
  34236. /** A Sound is currently paused. */
  34237. isPaused: boolean;
  34238. private _sounds;
  34239. private _weights;
  34240. private _currentIndex?;
  34241. /**
  34242. * Creates a new WeightedSound from the list of sounds given.
  34243. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34244. * @param sounds Array of Sounds that will be selected from.
  34245. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34246. */
  34247. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34248. /**
  34249. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34250. */
  34251. /**
  34252. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34253. */
  34254. directionalConeInnerAngle: number;
  34255. /**
  34256. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34257. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34258. */
  34259. /**
  34260. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34261. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34262. */
  34263. directionalConeOuterAngle: number;
  34264. /**
  34265. * Playback volume.
  34266. */
  34267. /**
  34268. * Playback volume.
  34269. */
  34270. volume: number;
  34271. private _onended;
  34272. /**
  34273. * Suspend playback
  34274. */
  34275. pause(): void;
  34276. /**
  34277. * Stop playback
  34278. */
  34279. stop(): void;
  34280. /**
  34281. * Start playback.
  34282. * @param startOffset Position the clip head at a specific time in seconds.
  34283. */
  34284. play(startOffset?: number): void;
  34285. }
  34286. }
  34287. declare module "babylonjs/Audio/index" {
  34288. export * from "babylonjs/Audio/analyser";
  34289. export * from "babylonjs/Audio/audioEngine";
  34290. export * from "babylonjs/Audio/audioSceneComponent";
  34291. export * from "babylonjs/Audio/sound";
  34292. export * from "babylonjs/Audio/soundTrack";
  34293. export * from "babylonjs/Audio/weightedsound";
  34294. }
  34295. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34296. import { Behavior } from "babylonjs/Behaviors/behavior";
  34297. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34298. import { BackEase } from "babylonjs/Animations/easing";
  34299. /**
  34300. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34302. */
  34303. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34304. /**
  34305. * Gets the name of the behavior.
  34306. */
  34307. readonly name: string;
  34308. /**
  34309. * The easing function used by animations
  34310. */
  34311. static EasingFunction: BackEase;
  34312. /**
  34313. * The easing mode used by animations
  34314. */
  34315. static EasingMode: number;
  34316. /**
  34317. * The duration of the animation, in milliseconds
  34318. */
  34319. transitionDuration: number;
  34320. /**
  34321. * Length of the distance animated by the transition when lower radius is reached
  34322. */
  34323. lowerRadiusTransitionRange: number;
  34324. /**
  34325. * Length of the distance animated by the transition when upper radius is reached
  34326. */
  34327. upperRadiusTransitionRange: number;
  34328. private _autoTransitionRange;
  34329. /**
  34330. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34331. */
  34332. /**
  34333. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34334. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34335. */
  34336. autoTransitionRange: boolean;
  34337. private _attachedCamera;
  34338. private _onAfterCheckInputsObserver;
  34339. private _onMeshTargetChangedObserver;
  34340. /**
  34341. * Initializes the behavior.
  34342. */
  34343. init(): void;
  34344. /**
  34345. * Attaches the behavior to its arc rotate camera.
  34346. * @param camera Defines the camera to attach the behavior to
  34347. */
  34348. attach(camera: ArcRotateCamera): void;
  34349. /**
  34350. * Detaches the behavior from its current arc rotate camera.
  34351. */
  34352. detach(): void;
  34353. private _radiusIsAnimating;
  34354. private _radiusBounceTransition;
  34355. private _animatables;
  34356. private _cachedWheelPrecision;
  34357. /**
  34358. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34359. * @param radiusLimit The limit to check against.
  34360. * @return Bool to indicate if at limit.
  34361. */
  34362. private _isRadiusAtLimit;
  34363. /**
  34364. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34365. * @param radiusDelta The delta by which to animate to. Can be negative.
  34366. */
  34367. private _applyBoundRadiusAnimation;
  34368. /**
  34369. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34370. */
  34371. protected _clearAnimationLocks(): void;
  34372. /**
  34373. * Stops and removes all animations that have been applied to the camera
  34374. */
  34375. stopAllAnimations(): void;
  34376. }
  34377. }
  34378. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34379. import { Behavior } from "babylonjs/Behaviors/behavior";
  34380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34381. import { ExponentialEase } from "babylonjs/Animations/easing";
  34382. import { Nullable } from "babylonjs/types";
  34383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34384. import { Vector3 } from "babylonjs/Maths/math";
  34385. /**
  34386. * 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.
  34387. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34388. */
  34389. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34390. /**
  34391. * Gets the name of the behavior.
  34392. */
  34393. readonly name: string;
  34394. private _mode;
  34395. private _radiusScale;
  34396. private _positionScale;
  34397. private _defaultElevation;
  34398. private _elevationReturnTime;
  34399. private _elevationReturnWaitTime;
  34400. private _zoomStopsAnimation;
  34401. private _framingTime;
  34402. /**
  34403. * The easing function used by animations
  34404. */
  34405. static EasingFunction: ExponentialEase;
  34406. /**
  34407. * The easing mode used by animations
  34408. */
  34409. static EasingMode: number;
  34410. /**
  34411. * Sets the current mode used by the behavior
  34412. */
  34413. /**
  34414. * Gets current mode used by the behavior.
  34415. */
  34416. mode: number;
  34417. /**
  34418. * Sets the scale applied to the radius (1 by default)
  34419. */
  34420. /**
  34421. * Gets the scale applied to the radius
  34422. */
  34423. radiusScale: number;
  34424. /**
  34425. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34426. */
  34427. /**
  34428. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34429. */
  34430. positionScale: number;
  34431. /**
  34432. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34433. * behaviour is triggered, in radians.
  34434. */
  34435. /**
  34436. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34437. * behaviour is triggered, in radians.
  34438. */
  34439. defaultElevation: number;
  34440. /**
  34441. * Sets the time (in milliseconds) taken to return to the default beta position.
  34442. * Negative value indicates camera should not return to default.
  34443. */
  34444. /**
  34445. * Gets the time (in milliseconds) taken to return to the default beta position.
  34446. * Negative value indicates camera should not return to default.
  34447. */
  34448. elevationReturnTime: number;
  34449. /**
  34450. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34451. */
  34452. /**
  34453. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34454. */
  34455. elevationReturnWaitTime: number;
  34456. /**
  34457. * Sets the flag that indicates if user zooming should stop animation.
  34458. */
  34459. /**
  34460. * Gets the flag that indicates if user zooming should stop animation.
  34461. */
  34462. zoomStopsAnimation: boolean;
  34463. /**
  34464. * Sets the transition time when framing the mesh, in milliseconds
  34465. */
  34466. /**
  34467. * Gets the transition time when framing the mesh, in milliseconds
  34468. */
  34469. framingTime: number;
  34470. /**
  34471. * Define if the behavior should automatically change the configured
  34472. * camera limits and sensibilities.
  34473. */
  34474. autoCorrectCameraLimitsAndSensibility: boolean;
  34475. private _onPrePointerObservableObserver;
  34476. private _onAfterCheckInputsObserver;
  34477. private _onMeshTargetChangedObserver;
  34478. private _attachedCamera;
  34479. private _isPointerDown;
  34480. private _lastInteractionTime;
  34481. /**
  34482. * Initializes the behavior.
  34483. */
  34484. init(): void;
  34485. /**
  34486. * Attaches the behavior to its arc rotate camera.
  34487. * @param camera Defines the camera to attach the behavior to
  34488. */
  34489. attach(camera: ArcRotateCamera): void;
  34490. /**
  34491. * Detaches the behavior from its current arc rotate camera.
  34492. */
  34493. detach(): void;
  34494. private _animatables;
  34495. private _betaIsAnimating;
  34496. private _betaTransition;
  34497. private _radiusTransition;
  34498. private _vectorTransition;
  34499. /**
  34500. * Targets the given mesh and updates zoom level accordingly.
  34501. * @param mesh The mesh to target.
  34502. * @param radius Optional. If a cached radius position already exists, overrides default.
  34503. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34504. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34505. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34506. */
  34507. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34508. /**
  34509. * Targets the given mesh with its children and updates zoom level accordingly.
  34510. * @param mesh The mesh to target.
  34511. * @param radius Optional. If a cached radius position already exists, overrides default.
  34512. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34513. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34514. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34515. */
  34516. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34517. /**
  34518. * Targets the given meshes with their children and updates zoom level accordingly.
  34519. * @param meshes The mesh to target.
  34520. * @param radius Optional. If a cached radius position already exists, overrides default.
  34521. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34522. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34523. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34524. */
  34525. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34526. /**
  34527. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34528. * @param minimumWorld Determines the smaller position of the bounding box extend
  34529. * @param maximumWorld Determines the bigger position of the bounding box extend
  34530. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34531. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34532. */
  34533. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34534. /**
  34535. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34536. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34537. * frustum width.
  34538. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34539. * to fully enclose the mesh in the viewing frustum.
  34540. */
  34541. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34542. /**
  34543. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34544. * is automatically returned to its default position (expected to be above ground plane).
  34545. */
  34546. private _maintainCameraAboveGround;
  34547. /**
  34548. * Returns the frustum slope based on the canvas ratio and camera FOV
  34549. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34550. */
  34551. private _getFrustumSlope;
  34552. /**
  34553. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34554. */
  34555. private _clearAnimationLocks;
  34556. /**
  34557. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34558. */
  34559. private _applyUserInteraction;
  34560. /**
  34561. * Stops and removes all animations that have been applied to the camera
  34562. */
  34563. stopAllAnimations(): void;
  34564. /**
  34565. * Gets a value indicating if the user is moving the camera
  34566. */
  34567. readonly isUserIsMoving: boolean;
  34568. /**
  34569. * The camera can move all the way towards the mesh.
  34570. */
  34571. static IgnoreBoundsSizeMode: number;
  34572. /**
  34573. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34574. */
  34575. static FitFrustumSidesMode: number;
  34576. }
  34577. }
  34578. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34579. import { Nullable } from "babylonjs/types";
  34580. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34581. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34582. /**
  34583. * Manage the pointers inputs to control an arc rotate camera.
  34584. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34585. */
  34586. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34587. /**
  34588. * Defines the camera the input is attached to.
  34589. */
  34590. camera: ArcRotateCamera;
  34591. /**
  34592. * Defines the buttons associated with the input to handle camera move.
  34593. */
  34594. buttons: number[];
  34595. /**
  34596. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34597. */
  34598. angularSensibilityX: number;
  34599. /**
  34600. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34601. */
  34602. angularSensibilityY: number;
  34603. /**
  34604. * Defines the pointer pinch precision or how fast is the camera zooming.
  34605. */
  34606. pinchPrecision: number;
  34607. /**
  34608. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34609. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34610. */
  34611. pinchDeltaPercentage: number;
  34612. /**
  34613. * Defines the pointer panning sensibility or how fast is the camera moving.
  34614. */
  34615. panningSensibility: number;
  34616. /**
  34617. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34618. */
  34619. multiTouchPanning: boolean;
  34620. /**
  34621. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34622. */
  34623. multiTouchPanAndZoom: boolean;
  34624. /**
  34625. * Revers pinch action direction.
  34626. */
  34627. pinchInwards: boolean;
  34628. private _isPanClick;
  34629. private _pointerInput;
  34630. private _observer;
  34631. private _onMouseMove;
  34632. private _onGestureStart;
  34633. private _onGesture;
  34634. private _MSGestureHandler;
  34635. private _onLostFocus;
  34636. private _onContextMenu;
  34637. /**
  34638. * Attach the input controls to a specific dom element to get the input from.
  34639. * @param element Defines the element the controls should be listened from
  34640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34641. */
  34642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34643. /**
  34644. * Detach the current controls from the specified dom element.
  34645. * @param element Defines the element to stop listening the inputs from
  34646. */
  34647. detachControl(element: Nullable<HTMLElement>): void;
  34648. /**
  34649. * Gets the class name of the current intput.
  34650. * @returns the class name
  34651. */
  34652. getClassName(): string;
  34653. /**
  34654. * Get the friendly name associated with the input class.
  34655. * @returns the input friendly name
  34656. */
  34657. getSimpleName(): string;
  34658. }
  34659. }
  34660. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34661. import { Nullable } from "babylonjs/types";
  34662. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34663. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34664. /**
  34665. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34667. */
  34668. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34669. /**
  34670. * Defines the camera the input is attached to.
  34671. */
  34672. camera: ArcRotateCamera;
  34673. /**
  34674. * Defines the list of key codes associated with the up action (increase alpha)
  34675. */
  34676. keysUp: number[];
  34677. /**
  34678. * Defines the list of key codes associated with the down action (decrease alpha)
  34679. */
  34680. keysDown: number[];
  34681. /**
  34682. * Defines the list of key codes associated with the left action (increase beta)
  34683. */
  34684. keysLeft: number[];
  34685. /**
  34686. * Defines the list of key codes associated with the right action (decrease beta)
  34687. */
  34688. keysRight: number[];
  34689. /**
  34690. * Defines the list of key codes associated with the reset action.
  34691. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34692. */
  34693. keysReset: number[];
  34694. /**
  34695. * Defines the panning sensibility of the inputs.
  34696. * (How fast is the camera paning)
  34697. */
  34698. panningSensibility: number;
  34699. /**
  34700. * Defines the zooming sensibility of the inputs.
  34701. * (How fast is the camera zooming)
  34702. */
  34703. zoomingSensibility: number;
  34704. /**
  34705. * Defines wether maintaining the alt key down switch the movement mode from
  34706. * orientation to zoom.
  34707. */
  34708. useAltToZoom: boolean;
  34709. /**
  34710. * Rotation speed of the camera
  34711. */
  34712. angularSpeed: number;
  34713. private _keys;
  34714. private _ctrlPressed;
  34715. private _altPressed;
  34716. private _onCanvasBlurObserver;
  34717. private _onKeyboardObserver;
  34718. private _engine;
  34719. private _scene;
  34720. /**
  34721. * Attach the input controls to a specific dom element to get the input from.
  34722. * @param element Defines the element the controls should be listened from
  34723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34724. */
  34725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34726. /**
  34727. * Detach the current controls from the specified dom element.
  34728. * @param element Defines the element to stop listening the inputs from
  34729. */
  34730. detachControl(element: Nullable<HTMLElement>): void;
  34731. /**
  34732. * Update the current camera state depending on the inputs that have been used this frame.
  34733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34734. */
  34735. checkInputs(): void;
  34736. /**
  34737. * Gets the class name of the current intput.
  34738. * @returns the class name
  34739. */
  34740. getClassName(): string;
  34741. /**
  34742. * Get the friendly name associated with the input class.
  34743. * @returns the input friendly name
  34744. */
  34745. getSimpleName(): string;
  34746. }
  34747. }
  34748. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34749. import { Nullable } from "babylonjs/types";
  34750. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34751. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34752. /**
  34753. * Manage the mouse wheel inputs to control an arc rotate camera.
  34754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34755. */
  34756. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34757. /**
  34758. * Defines the camera the input is attached to.
  34759. */
  34760. camera: ArcRotateCamera;
  34761. /**
  34762. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34763. */
  34764. wheelPrecision: number;
  34765. /**
  34766. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34767. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34768. */
  34769. wheelDeltaPercentage: number;
  34770. private _wheel;
  34771. private _observer;
  34772. /**
  34773. * Attach the input controls to a specific dom element to get the input from.
  34774. * @param element Defines the element the controls should be listened from
  34775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34776. */
  34777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34778. /**
  34779. * Detach the current controls from the specified dom element.
  34780. * @param element Defines the element to stop listening the inputs from
  34781. */
  34782. detachControl(element: Nullable<HTMLElement>): void;
  34783. /**
  34784. * Gets the class name of the current intput.
  34785. * @returns the class name
  34786. */
  34787. getClassName(): string;
  34788. /**
  34789. * Get the friendly name associated with the input class.
  34790. * @returns the input friendly name
  34791. */
  34792. getSimpleName(): string;
  34793. }
  34794. }
  34795. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34796. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34797. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34798. /**
  34799. * Default Inputs manager for the ArcRotateCamera.
  34800. * It groups all the default supported inputs for ease of use.
  34801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34802. */
  34803. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34804. /**
  34805. * Instantiates a new ArcRotateCameraInputsManager.
  34806. * @param camera Defines the camera the inputs belong to
  34807. */
  34808. constructor(camera: ArcRotateCamera);
  34809. /**
  34810. * Add mouse wheel input support to the input manager.
  34811. * @returns the current input manager
  34812. */
  34813. addMouseWheel(): ArcRotateCameraInputsManager;
  34814. /**
  34815. * Add pointers input support to the input manager.
  34816. * @returns the current input manager
  34817. */
  34818. addPointers(): ArcRotateCameraInputsManager;
  34819. /**
  34820. * Add keyboard input support to the input manager.
  34821. * @returns the current input manager
  34822. */
  34823. addKeyboard(): ArcRotateCameraInputsManager;
  34824. }
  34825. }
  34826. declare module "babylonjs/Cameras/arcRotateCamera" {
  34827. import { Observable } from "babylonjs/Misc/observable";
  34828. import { Nullable } from "babylonjs/types";
  34829. import { Scene } from "babylonjs/scene";
  34830. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34832. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34833. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34834. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34835. import { Camera } from "babylonjs/Cameras/camera";
  34836. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34837. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34838. import { Collider } from "babylonjs/Collisions/collider";
  34839. /**
  34840. * This represents an orbital type of camera.
  34841. *
  34842. * 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.
  34843. * 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.
  34844. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34845. */
  34846. export class ArcRotateCamera extends TargetCamera {
  34847. /**
  34848. * Defines the rotation angle of the camera along the longitudinal axis.
  34849. */
  34850. alpha: number;
  34851. /**
  34852. * Defines the rotation angle of the camera along the latitudinal axis.
  34853. */
  34854. beta: number;
  34855. /**
  34856. * Defines the radius of the camera from it s target point.
  34857. */
  34858. radius: number;
  34859. protected _target: Vector3;
  34860. protected _targetHost: Nullable<AbstractMesh>;
  34861. /**
  34862. * Defines the target point of the camera.
  34863. * The camera looks towards it form the radius distance.
  34864. */
  34865. target: Vector3;
  34866. /**
  34867. * Current inertia value on the longitudinal axis.
  34868. * The bigger this number the longer it will take for the camera to stop.
  34869. */
  34870. inertialAlphaOffset: number;
  34871. /**
  34872. * Current inertia value on the latitudinal axis.
  34873. * The bigger this number the longer it will take for the camera to stop.
  34874. */
  34875. inertialBetaOffset: number;
  34876. /**
  34877. * Current inertia value on the radius axis.
  34878. * The bigger this number the longer it will take for the camera to stop.
  34879. */
  34880. inertialRadiusOffset: number;
  34881. /**
  34882. * Minimum allowed angle on the longitudinal axis.
  34883. * This can help limiting how the Camera is able to move in the scene.
  34884. */
  34885. lowerAlphaLimit: Nullable<number>;
  34886. /**
  34887. * Maximum allowed angle on the longitudinal axis.
  34888. * This can help limiting how the Camera is able to move in the scene.
  34889. */
  34890. upperAlphaLimit: Nullable<number>;
  34891. /**
  34892. * Minimum allowed angle on the latitudinal axis.
  34893. * This can help limiting how the Camera is able to move in the scene.
  34894. */
  34895. lowerBetaLimit: number;
  34896. /**
  34897. * Maximum allowed angle on the latitudinal axis.
  34898. * This can help limiting how the Camera is able to move in the scene.
  34899. */
  34900. upperBetaLimit: number;
  34901. /**
  34902. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34903. * This can help limiting how the Camera is able to move in the scene.
  34904. */
  34905. lowerRadiusLimit: Nullable<number>;
  34906. /**
  34907. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34908. * This can help limiting how the Camera is able to move in the scene.
  34909. */
  34910. upperRadiusLimit: Nullable<number>;
  34911. /**
  34912. * Defines the current inertia value used during panning of the camera along the X axis.
  34913. */
  34914. inertialPanningX: number;
  34915. /**
  34916. * Defines the current inertia value used during panning of the camera along the Y axis.
  34917. */
  34918. inertialPanningY: number;
  34919. /**
  34920. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34921. * Basically if your fingers moves away from more than this distance you will be considered
  34922. * in pinch mode.
  34923. */
  34924. pinchToPanMaxDistance: number;
  34925. /**
  34926. * Defines the maximum distance the camera can pan.
  34927. * This could help keeping the cammera always in your scene.
  34928. */
  34929. panningDistanceLimit: Nullable<number>;
  34930. /**
  34931. * Defines the target of the camera before paning.
  34932. */
  34933. panningOriginTarget: Vector3;
  34934. /**
  34935. * Defines the value of the inertia used during panning.
  34936. * 0 would mean stop inertia and one would mean no decelleration at all.
  34937. */
  34938. panningInertia: number;
  34939. /**
  34940. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34941. */
  34942. angularSensibilityX: number;
  34943. /**
  34944. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34945. */
  34946. angularSensibilityY: number;
  34947. /**
  34948. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34949. */
  34950. pinchPrecision: number;
  34951. /**
  34952. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34953. * It will be used instead of pinchDeltaPrecision if different from 0.
  34954. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34955. */
  34956. pinchDeltaPercentage: number;
  34957. /**
  34958. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34959. */
  34960. panningSensibility: number;
  34961. /**
  34962. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34963. */
  34964. keysUp: number[];
  34965. /**
  34966. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34967. */
  34968. keysDown: number[];
  34969. /**
  34970. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34971. */
  34972. keysLeft: number[];
  34973. /**
  34974. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34975. */
  34976. keysRight: number[];
  34977. /**
  34978. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34979. */
  34980. wheelPrecision: number;
  34981. /**
  34982. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34983. * It will be used instead of pinchDeltaPrecision if different from 0.
  34984. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34985. */
  34986. wheelDeltaPercentage: number;
  34987. /**
  34988. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34989. */
  34990. zoomOnFactor: number;
  34991. /**
  34992. * Defines a screen offset for the camera position.
  34993. */
  34994. targetScreenOffset: Vector2;
  34995. /**
  34996. * Allows the camera to be completely reversed.
  34997. * If false the camera can not arrive upside down.
  34998. */
  34999. allowUpsideDown: boolean;
  35000. /**
  35001. * Define if double tap/click is used to restore the previously saved state of the camera.
  35002. */
  35003. useInputToRestoreState: boolean;
  35004. /** @hidden */
  35005. _viewMatrix: Matrix;
  35006. /** @hidden */
  35007. _useCtrlForPanning: boolean;
  35008. /** @hidden */
  35009. _panningMouseButton: number;
  35010. /**
  35011. * Defines the input associated to the camera.
  35012. */
  35013. inputs: ArcRotateCameraInputsManager;
  35014. /** @hidden */
  35015. _reset: () => void;
  35016. /**
  35017. * Defines the allowed panning axis.
  35018. */
  35019. panningAxis: Vector3;
  35020. protected _localDirection: Vector3;
  35021. protected _transformedDirection: Vector3;
  35022. private _bouncingBehavior;
  35023. /**
  35024. * Gets the bouncing behavior of the camera if it has been enabled.
  35025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35026. */
  35027. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35028. /**
  35029. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35030. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35031. */
  35032. useBouncingBehavior: boolean;
  35033. private _framingBehavior;
  35034. /**
  35035. * Gets the framing behavior of the camera if it has been enabled.
  35036. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35037. */
  35038. readonly framingBehavior: Nullable<FramingBehavior>;
  35039. /**
  35040. * Defines if the framing behavior of the camera is enabled on the camera.
  35041. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35042. */
  35043. useFramingBehavior: boolean;
  35044. private _autoRotationBehavior;
  35045. /**
  35046. * Gets the auto rotation behavior of the camera if it has been enabled.
  35047. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35048. */
  35049. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35050. /**
  35051. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35052. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35053. */
  35054. useAutoRotationBehavior: boolean;
  35055. /**
  35056. * Observable triggered when the mesh target has been changed on the camera.
  35057. */
  35058. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35059. /**
  35060. * Event raised when the camera is colliding with a mesh.
  35061. */
  35062. onCollide: (collidedMesh: AbstractMesh) => void;
  35063. /**
  35064. * Defines whether the camera should check collision with the objects oh the scene.
  35065. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35066. */
  35067. checkCollisions: boolean;
  35068. /**
  35069. * Defines the collision radius of the camera.
  35070. * This simulates a sphere around the camera.
  35071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35072. */
  35073. collisionRadius: Vector3;
  35074. protected _collider: Collider;
  35075. protected _previousPosition: Vector3;
  35076. protected _collisionVelocity: Vector3;
  35077. protected _newPosition: Vector3;
  35078. protected _previousAlpha: number;
  35079. protected _previousBeta: number;
  35080. protected _previousRadius: number;
  35081. protected _collisionTriggered: boolean;
  35082. protected _targetBoundingCenter: Nullable<Vector3>;
  35083. private _computationVector;
  35084. private _tempAxisVector;
  35085. private _tempAxisRotationMatrix;
  35086. /**
  35087. * Instantiates a new ArcRotateCamera in a given scene
  35088. * @param name Defines the name of the camera
  35089. * @param alpha Defines the camera rotation along the logitudinal axis
  35090. * @param beta Defines the camera rotation along the latitudinal axis
  35091. * @param radius Defines the camera distance from its target
  35092. * @param target Defines the camera target
  35093. * @param scene Defines the scene the camera belongs to
  35094. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35095. */
  35096. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35097. /** @hidden */
  35098. _initCache(): void;
  35099. /** @hidden */
  35100. _updateCache(ignoreParentClass?: boolean): void;
  35101. protected _getTargetPosition(): Vector3;
  35102. private _storedAlpha;
  35103. private _storedBeta;
  35104. private _storedRadius;
  35105. private _storedTarget;
  35106. /**
  35107. * Stores the current state of the camera (alpha, beta, radius and target)
  35108. * @returns the camera itself
  35109. */
  35110. storeState(): Camera;
  35111. /**
  35112. * @hidden
  35113. * Restored camera state. You must call storeState() first
  35114. */
  35115. _restoreStateValues(): boolean;
  35116. /** @hidden */
  35117. _isSynchronizedViewMatrix(): boolean;
  35118. /**
  35119. * Attached controls to the current camera.
  35120. * @param element Defines the element the controls should be listened from
  35121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35122. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35123. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35124. */
  35125. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35126. /**
  35127. * Detach the current controls from the camera.
  35128. * The camera will stop reacting to inputs.
  35129. * @param element Defines the element to stop listening the inputs from
  35130. */
  35131. detachControl(element: HTMLElement): void;
  35132. /** @hidden */
  35133. _checkInputs(): void;
  35134. protected _checkLimits(): void;
  35135. /**
  35136. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35137. */
  35138. rebuildAnglesAndRadius(): void;
  35139. /**
  35140. * Use a position to define the current camera related information like aplha, beta and radius
  35141. * @param position Defines the position to set the camera at
  35142. */
  35143. setPosition(position: Vector3): void;
  35144. /**
  35145. * Defines the target the camera should look at.
  35146. * This will automatically adapt alpha beta and radius to fit within the new target.
  35147. * @param target Defines the new target as a Vector or a mesh
  35148. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35149. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35150. */
  35151. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35152. /** @hidden */
  35153. _getViewMatrix(): Matrix;
  35154. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35155. /**
  35156. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35157. * @param meshes Defines the mesh to zoom on
  35158. * @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)
  35159. */
  35160. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35161. /**
  35162. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35163. * The target will be changed but the radius
  35164. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35165. * @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)
  35166. */
  35167. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35168. min: Vector3;
  35169. max: Vector3;
  35170. distance: number;
  35171. }, doNotUpdateMaxZ?: boolean): void;
  35172. /**
  35173. * @override
  35174. * Override Camera.createRigCamera
  35175. */
  35176. createRigCamera(name: string, cameraIndex: number): Camera;
  35177. /**
  35178. * @hidden
  35179. * @override
  35180. * Override Camera._updateRigCameras
  35181. */
  35182. _updateRigCameras(): void;
  35183. /**
  35184. * Destroy the camera and release the current resources hold by it.
  35185. */
  35186. dispose(): void;
  35187. /**
  35188. * Gets the current object class name.
  35189. * @return the class name
  35190. */
  35191. getClassName(): string;
  35192. }
  35193. }
  35194. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35195. import { Behavior } from "babylonjs/Behaviors/behavior";
  35196. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35197. /**
  35198. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35199. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35200. */
  35201. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35202. /**
  35203. * Gets the name of the behavior.
  35204. */
  35205. readonly name: string;
  35206. private _zoomStopsAnimation;
  35207. private _idleRotationSpeed;
  35208. private _idleRotationWaitTime;
  35209. private _idleRotationSpinupTime;
  35210. /**
  35211. * Sets the flag that indicates if user zooming should stop animation.
  35212. */
  35213. /**
  35214. * Gets the flag that indicates if user zooming should stop animation.
  35215. */
  35216. zoomStopsAnimation: boolean;
  35217. /**
  35218. * Sets the default speed at which the camera rotates around the model.
  35219. */
  35220. /**
  35221. * Gets the default speed at which the camera rotates around the model.
  35222. */
  35223. idleRotationSpeed: number;
  35224. /**
  35225. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35226. */
  35227. /**
  35228. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35229. */
  35230. idleRotationWaitTime: number;
  35231. /**
  35232. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35233. */
  35234. /**
  35235. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35236. */
  35237. idleRotationSpinupTime: number;
  35238. /**
  35239. * Gets a value indicating if the camera is currently rotating because of this behavior
  35240. */
  35241. readonly rotationInProgress: boolean;
  35242. private _onPrePointerObservableObserver;
  35243. private _onAfterCheckInputsObserver;
  35244. private _attachedCamera;
  35245. private _isPointerDown;
  35246. private _lastFrameTime;
  35247. private _lastInteractionTime;
  35248. private _cameraRotationSpeed;
  35249. /**
  35250. * Initializes the behavior.
  35251. */
  35252. init(): void;
  35253. /**
  35254. * Attaches the behavior to its arc rotate camera.
  35255. * @param camera Defines the camera to attach the behavior to
  35256. */
  35257. attach(camera: ArcRotateCamera): void;
  35258. /**
  35259. * Detaches the behavior from its current arc rotate camera.
  35260. */
  35261. detach(): void;
  35262. /**
  35263. * Returns true if user is scrolling.
  35264. * @return true if user is scrolling.
  35265. */
  35266. private _userIsZooming;
  35267. private _lastFrameRadius;
  35268. private _shouldAnimationStopForInteraction;
  35269. /**
  35270. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35271. */
  35272. private _applyUserInteraction;
  35273. private _userIsMoving;
  35274. }
  35275. }
  35276. declare module "babylonjs/Behaviors/Cameras/index" {
  35277. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35278. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35279. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35280. }
  35281. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35282. import { Mesh } from "babylonjs/Meshes/mesh";
  35283. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35284. import { Behavior } from "babylonjs/Behaviors/behavior";
  35285. /**
  35286. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35287. */
  35288. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35289. private ui;
  35290. /**
  35291. * The name of the behavior
  35292. */
  35293. name: string;
  35294. /**
  35295. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35296. */
  35297. distanceAwayFromFace: number;
  35298. /**
  35299. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35300. */
  35301. distanceAwayFromBottomOfFace: number;
  35302. private _faceVectors;
  35303. private _target;
  35304. private _scene;
  35305. private _onRenderObserver;
  35306. private _tmpMatrix;
  35307. private _tmpVector;
  35308. /**
  35309. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35310. * @param ui The transform node that should be attched to the mesh
  35311. */
  35312. constructor(ui: TransformNode);
  35313. /**
  35314. * Initializes the behavior
  35315. */
  35316. init(): void;
  35317. private _closestFace;
  35318. private _zeroVector;
  35319. private _lookAtTmpMatrix;
  35320. private _lookAtToRef;
  35321. /**
  35322. * Attaches the AttachToBoxBehavior to the passed in mesh
  35323. * @param target The mesh that the specified node will be attached to
  35324. */
  35325. attach(target: Mesh): void;
  35326. /**
  35327. * Detaches the behavior from the mesh
  35328. */
  35329. detach(): void;
  35330. }
  35331. }
  35332. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35333. import { Behavior } from "babylonjs/Behaviors/behavior";
  35334. import { Mesh } from "babylonjs/Meshes/mesh";
  35335. /**
  35336. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35337. */
  35338. export class FadeInOutBehavior implements Behavior<Mesh> {
  35339. /**
  35340. * Time in milliseconds to delay before fading in (Default: 0)
  35341. */
  35342. delay: number;
  35343. /**
  35344. * Time in milliseconds for the mesh to fade in (Default: 300)
  35345. */
  35346. fadeInTime: number;
  35347. private _millisecondsPerFrame;
  35348. private _hovered;
  35349. private _hoverValue;
  35350. private _ownerNode;
  35351. /**
  35352. * Instatiates the FadeInOutBehavior
  35353. */
  35354. constructor();
  35355. /**
  35356. * The name of the behavior
  35357. */
  35358. readonly name: string;
  35359. /**
  35360. * Initializes the behavior
  35361. */
  35362. init(): void;
  35363. /**
  35364. * Attaches the fade behavior on the passed in mesh
  35365. * @param ownerNode The mesh that will be faded in/out once attached
  35366. */
  35367. attach(ownerNode: Mesh): void;
  35368. /**
  35369. * Detaches the behavior from the mesh
  35370. */
  35371. detach(): void;
  35372. /**
  35373. * Triggers the mesh to begin fading in or out
  35374. * @param value if the object should fade in or out (true to fade in)
  35375. */
  35376. fadeIn(value: boolean): void;
  35377. private _update;
  35378. private _setAllVisibility;
  35379. }
  35380. }
  35381. declare module "babylonjs/Misc/pivotTools" {
  35382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35383. /**
  35384. * Class containing a set of static utilities functions for managing Pivots
  35385. * @hidden
  35386. */
  35387. export class PivotTools {
  35388. private static _PivotCached;
  35389. private static _OldPivotPoint;
  35390. private static _PivotTranslation;
  35391. private static _PivotTmpVector;
  35392. /** @hidden */
  35393. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35394. /** @hidden */
  35395. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35396. }
  35397. }
  35398. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35399. import { Scene } from "babylonjs/scene";
  35400. import { Vector4, Plane } from "babylonjs/Maths/math";
  35401. import { Mesh } from "babylonjs/Meshes/mesh";
  35402. /**
  35403. * Class containing static functions to help procedurally build meshes
  35404. */
  35405. export class PlaneBuilder {
  35406. /**
  35407. * Creates a plane mesh
  35408. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35409. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35410. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35414. * @param name defines the name of the mesh
  35415. * @param options defines the options used to create the mesh
  35416. * @param scene defines the hosting scene
  35417. * @returns the plane mesh
  35418. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35419. */
  35420. static CreatePlane(name: string, options: {
  35421. size?: number;
  35422. width?: number;
  35423. height?: number;
  35424. sideOrientation?: number;
  35425. frontUVs?: Vector4;
  35426. backUVs?: Vector4;
  35427. updatable?: boolean;
  35428. sourcePlane?: Plane;
  35429. }, scene: Scene): Mesh;
  35430. }
  35431. }
  35432. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35433. import { Behavior } from "babylonjs/Behaviors/behavior";
  35434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35435. import { Observable } from "babylonjs/Misc/observable";
  35436. import { Vector3 } from "babylonjs/Maths/math";
  35437. import { Ray } from "babylonjs/Culling/ray";
  35438. import "babylonjs/Meshes/Builders/planeBuilder";
  35439. /**
  35440. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35441. */
  35442. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35443. private static _AnyMouseID;
  35444. private _attachedNode;
  35445. private _dragPlane;
  35446. private _scene;
  35447. private _pointerObserver;
  35448. private _beforeRenderObserver;
  35449. private static _planeScene;
  35450. /**
  35451. * 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)
  35452. */
  35453. maxDragAngle: number;
  35454. /**
  35455. * @hidden
  35456. */
  35457. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35458. /**
  35459. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35460. */
  35461. currentDraggingPointerID: number;
  35462. /**
  35463. * The last position where the pointer hit the drag plane in world space
  35464. */
  35465. lastDragPosition: Vector3;
  35466. /**
  35467. * If the behavior is currently in a dragging state
  35468. */
  35469. dragging: boolean;
  35470. /**
  35471. * 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)
  35472. */
  35473. dragDeltaRatio: number;
  35474. /**
  35475. * If the drag plane orientation should be updated during the dragging (Default: true)
  35476. */
  35477. updateDragPlane: boolean;
  35478. private _debugMode;
  35479. private _moving;
  35480. /**
  35481. * Fires each time the attached mesh is dragged with the pointer
  35482. * * delta between last drag position and current drag position in world space
  35483. * * dragDistance along the drag axis
  35484. * * dragPlaneNormal normal of the current drag plane used during the drag
  35485. * * dragPlanePoint in world space where the drag intersects the drag plane
  35486. */
  35487. onDragObservable: Observable<{
  35488. delta: Vector3;
  35489. dragPlanePoint: Vector3;
  35490. dragPlaneNormal: Vector3;
  35491. dragDistance: number;
  35492. pointerId: number;
  35493. }>;
  35494. /**
  35495. * Fires each time a drag begins (eg. mouse down on mesh)
  35496. */
  35497. onDragStartObservable: Observable<{
  35498. dragPlanePoint: Vector3;
  35499. pointerId: number;
  35500. }>;
  35501. /**
  35502. * Fires each time a drag ends (eg. mouse release after drag)
  35503. */
  35504. onDragEndObservable: Observable<{
  35505. dragPlanePoint: Vector3;
  35506. pointerId: number;
  35507. }>;
  35508. /**
  35509. * If the attached mesh should be moved when dragged
  35510. */
  35511. moveAttached: boolean;
  35512. /**
  35513. * If the drag behavior will react to drag events (Default: true)
  35514. */
  35515. enabled: boolean;
  35516. /**
  35517. * If camera controls should be detached during the drag
  35518. */
  35519. detachCameraControls: boolean;
  35520. /**
  35521. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35522. */
  35523. useObjectOrienationForDragging: boolean;
  35524. private _options;
  35525. /**
  35526. * Creates a pointer drag behavior that can be attached to a mesh
  35527. * @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)
  35528. */
  35529. constructor(options?: {
  35530. dragAxis?: Vector3;
  35531. dragPlaneNormal?: Vector3;
  35532. });
  35533. /**
  35534. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35535. */
  35536. validateDrag: (targetPosition: Vector3) => boolean;
  35537. /**
  35538. * The name of the behavior
  35539. */
  35540. readonly name: string;
  35541. /**
  35542. * Initializes the behavior
  35543. */
  35544. init(): void;
  35545. private _tmpVector;
  35546. private _alternatePickedPoint;
  35547. private _worldDragAxis;
  35548. private _targetPosition;
  35549. private _attachedElement;
  35550. /**
  35551. * Attaches the drag behavior the passed in mesh
  35552. * @param ownerNode The mesh that will be dragged around once attached
  35553. */
  35554. attach(ownerNode: AbstractMesh): void;
  35555. /**
  35556. * Force relase the drag action by code.
  35557. */
  35558. releaseDrag(): void;
  35559. private _startDragRay;
  35560. private _lastPointerRay;
  35561. /**
  35562. * Simulates the start of a pointer drag event on the behavior
  35563. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35564. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35565. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35566. */
  35567. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35568. private _startDrag;
  35569. private _dragDelta;
  35570. private _moveDrag;
  35571. private _pickWithRayOnDragPlane;
  35572. private _pointA;
  35573. private _pointB;
  35574. private _pointC;
  35575. private _lineA;
  35576. private _lineB;
  35577. private _localAxis;
  35578. private _lookAt;
  35579. private _updateDragPlanePosition;
  35580. /**
  35581. * Detaches the behavior from the mesh
  35582. */
  35583. detach(): void;
  35584. }
  35585. }
  35586. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35587. import { Mesh } from "babylonjs/Meshes/mesh";
  35588. import { Behavior } from "babylonjs/Behaviors/behavior";
  35589. /**
  35590. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35591. */
  35592. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35593. private _dragBehaviorA;
  35594. private _dragBehaviorB;
  35595. private _startDistance;
  35596. private _initialScale;
  35597. private _targetScale;
  35598. private _ownerNode;
  35599. private _sceneRenderObserver;
  35600. /**
  35601. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35602. */
  35603. constructor();
  35604. /**
  35605. * The name of the behavior
  35606. */
  35607. readonly name: string;
  35608. /**
  35609. * Initializes the behavior
  35610. */
  35611. init(): void;
  35612. private _getCurrentDistance;
  35613. /**
  35614. * Attaches the scale behavior the passed in mesh
  35615. * @param ownerNode The mesh that will be scaled around once attached
  35616. */
  35617. attach(ownerNode: Mesh): void;
  35618. /**
  35619. * Detaches the behavior from the mesh
  35620. */
  35621. detach(): void;
  35622. }
  35623. }
  35624. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35625. import { Behavior } from "babylonjs/Behaviors/behavior";
  35626. import { Mesh } from "babylonjs/Meshes/mesh";
  35627. import { Observable } from "babylonjs/Misc/observable";
  35628. /**
  35629. * 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
  35630. */
  35631. export class SixDofDragBehavior implements Behavior<Mesh> {
  35632. private static _virtualScene;
  35633. private _ownerNode;
  35634. private _sceneRenderObserver;
  35635. private _scene;
  35636. private _targetPosition;
  35637. private _virtualOriginMesh;
  35638. private _virtualDragMesh;
  35639. private _pointerObserver;
  35640. private _moving;
  35641. private _startingOrientation;
  35642. /**
  35643. * 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)
  35644. */
  35645. private zDragFactor;
  35646. /**
  35647. * If the object should rotate to face the drag origin
  35648. */
  35649. rotateDraggedObject: boolean;
  35650. /**
  35651. * If the behavior is currently in a dragging state
  35652. */
  35653. dragging: boolean;
  35654. /**
  35655. * 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)
  35656. */
  35657. dragDeltaRatio: number;
  35658. /**
  35659. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35660. */
  35661. currentDraggingPointerID: number;
  35662. /**
  35663. * If camera controls should be detached during the drag
  35664. */
  35665. detachCameraControls: boolean;
  35666. /**
  35667. * Fires each time a drag starts
  35668. */
  35669. onDragStartObservable: Observable<{}>;
  35670. /**
  35671. * Fires each time a drag ends (eg. mouse release after drag)
  35672. */
  35673. onDragEndObservable: Observable<{}>;
  35674. /**
  35675. * 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
  35676. */
  35677. constructor();
  35678. /**
  35679. * The name of the behavior
  35680. */
  35681. readonly name: string;
  35682. /**
  35683. * Initializes the behavior
  35684. */
  35685. init(): void;
  35686. /**
  35687. * Attaches the scale behavior the passed in mesh
  35688. * @param ownerNode The mesh that will be scaled around once attached
  35689. */
  35690. attach(ownerNode: Mesh): void;
  35691. /**
  35692. * Detaches the behavior from the mesh
  35693. */
  35694. detach(): void;
  35695. }
  35696. }
  35697. declare module "babylonjs/Behaviors/Meshes/index" {
  35698. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35699. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35700. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35701. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35702. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35703. }
  35704. declare module "babylonjs/Behaviors/index" {
  35705. export * from "babylonjs/Behaviors/behavior";
  35706. export * from "babylonjs/Behaviors/Cameras/index";
  35707. export * from "babylonjs/Behaviors/Meshes/index";
  35708. }
  35709. declare module "babylonjs/Bones/boneIKController" {
  35710. import { Bone } from "babylonjs/Bones/bone";
  35711. import { Vector3 } from "babylonjs/Maths/math";
  35712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35713. import { Nullable } from "babylonjs/types";
  35714. /**
  35715. * Class used to apply inverse kinematics to bones
  35716. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35717. */
  35718. export class BoneIKController {
  35719. private static _tmpVecs;
  35720. private static _tmpQuat;
  35721. private static _tmpMats;
  35722. /**
  35723. * Gets or sets the target mesh
  35724. */
  35725. targetMesh: AbstractMesh;
  35726. /** Gets or sets the mesh used as pole */
  35727. poleTargetMesh: AbstractMesh;
  35728. /**
  35729. * Gets or sets the bone used as pole
  35730. */
  35731. poleTargetBone: Nullable<Bone>;
  35732. /**
  35733. * Gets or sets the target position
  35734. */
  35735. targetPosition: Vector3;
  35736. /**
  35737. * Gets or sets the pole target position
  35738. */
  35739. poleTargetPosition: Vector3;
  35740. /**
  35741. * Gets or sets the pole target local offset
  35742. */
  35743. poleTargetLocalOffset: Vector3;
  35744. /**
  35745. * Gets or sets the pole angle
  35746. */
  35747. poleAngle: number;
  35748. /**
  35749. * Gets or sets the mesh associated with the controller
  35750. */
  35751. mesh: AbstractMesh;
  35752. /**
  35753. * 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)
  35754. */
  35755. slerpAmount: number;
  35756. private _bone1Quat;
  35757. private _bone1Mat;
  35758. private _bone2Ang;
  35759. private _bone1;
  35760. private _bone2;
  35761. private _bone1Length;
  35762. private _bone2Length;
  35763. private _maxAngle;
  35764. private _maxReach;
  35765. private _rightHandedSystem;
  35766. private _bendAxis;
  35767. private _slerping;
  35768. private _adjustRoll;
  35769. /**
  35770. * Gets or sets maximum allowed angle
  35771. */
  35772. maxAngle: number;
  35773. /**
  35774. * Creates a new BoneIKController
  35775. * @param mesh defines the mesh to control
  35776. * @param bone defines the bone to control
  35777. * @param options defines options to set up the controller
  35778. */
  35779. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35780. targetMesh?: AbstractMesh;
  35781. poleTargetMesh?: AbstractMesh;
  35782. poleTargetBone?: Bone;
  35783. poleTargetLocalOffset?: Vector3;
  35784. poleAngle?: number;
  35785. bendAxis?: Vector3;
  35786. maxAngle?: number;
  35787. slerpAmount?: number;
  35788. });
  35789. private _setMaxAngle;
  35790. /**
  35791. * Force the controller to update the bones
  35792. */
  35793. update(): void;
  35794. }
  35795. }
  35796. declare module "babylonjs/Bones/boneLookController" {
  35797. import { Vector3, Space } from "babylonjs/Maths/math";
  35798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35799. import { Bone } from "babylonjs/Bones/bone";
  35800. /**
  35801. * Class used to make a bone look toward a point in space
  35802. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35803. */
  35804. export class BoneLookController {
  35805. private static _tmpVecs;
  35806. private static _tmpQuat;
  35807. private static _tmpMats;
  35808. /**
  35809. * The target Vector3 that the bone will look at
  35810. */
  35811. target: Vector3;
  35812. /**
  35813. * The mesh that the bone is attached to
  35814. */
  35815. mesh: AbstractMesh;
  35816. /**
  35817. * The bone that will be looking to the target
  35818. */
  35819. bone: Bone;
  35820. /**
  35821. * The up axis of the coordinate system that is used when the bone is rotated
  35822. */
  35823. upAxis: Vector3;
  35824. /**
  35825. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35826. */
  35827. upAxisSpace: Space;
  35828. /**
  35829. * Used to make an adjustment to the yaw of the bone
  35830. */
  35831. adjustYaw: number;
  35832. /**
  35833. * Used to make an adjustment to the pitch of the bone
  35834. */
  35835. adjustPitch: number;
  35836. /**
  35837. * Used to make an adjustment to the roll of the bone
  35838. */
  35839. adjustRoll: number;
  35840. /**
  35841. * 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)
  35842. */
  35843. slerpAmount: number;
  35844. private _minYaw;
  35845. private _maxYaw;
  35846. private _minPitch;
  35847. private _maxPitch;
  35848. private _minYawSin;
  35849. private _minYawCos;
  35850. private _maxYawSin;
  35851. private _maxYawCos;
  35852. private _midYawConstraint;
  35853. private _minPitchTan;
  35854. private _maxPitchTan;
  35855. private _boneQuat;
  35856. private _slerping;
  35857. private _transformYawPitch;
  35858. private _transformYawPitchInv;
  35859. private _firstFrameSkipped;
  35860. private _yawRange;
  35861. private _fowardAxis;
  35862. /**
  35863. * Gets or sets the minimum yaw angle that the bone can look to
  35864. */
  35865. minYaw: number;
  35866. /**
  35867. * Gets or sets the maximum yaw angle that the bone can look to
  35868. */
  35869. maxYaw: number;
  35870. /**
  35871. * Gets or sets the minimum pitch angle that the bone can look to
  35872. */
  35873. minPitch: number;
  35874. /**
  35875. * Gets or sets the maximum pitch angle that the bone can look to
  35876. */
  35877. maxPitch: number;
  35878. /**
  35879. * Create a BoneLookController
  35880. * @param mesh the mesh that the bone belongs to
  35881. * @param bone the bone that will be looking to the target
  35882. * @param target the target Vector3 to look at
  35883. * @param options optional settings:
  35884. * * maxYaw: the maximum angle the bone will yaw to
  35885. * * minYaw: the minimum angle the bone will yaw to
  35886. * * maxPitch: the maximum angle the bone will pitch to
  35887. * * minPitch: the minimum angle the bone will yaw to
  35888. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35889. * * upAxis: the up axis of the coordinate system
  35890. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35891. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35892. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35893. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35894. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35895. * * adjustRoll: used to make an adjustment to the roll of the bone
  35896. **/
  35897. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35898. maxYaw?: number;
  35899. minYaw?: number;
  35900. maxPitch?: number;
  35901. minPitch?: number;
  35902. slerpAmount?: number;
  35903. upAxis?: Vector3;
  35904. upAxisSpace?: Space;
  35905. yawAxis?: Vector3;
  35906. pitchAxis?: Vector3;
  35907. adjustYaw?: number;
  35908. adjustPitch?: number;
  35909. adjustRoll?: number;
  35910. });
  35911. /**
  35912. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35913. */
  35914. update(): void;
  35915. private _getAngleDiff;
  35916. private _getAngleBetween;
  35917. private _isAngleBetween;
  35918. }
  35919. }
  35920. declare module "babylonjs/Bones/index" {
  35921. export * from "babylonjs/Bones/bone";
  35922. export * from "babylonjs/Bones/boneIKController";
  35923. export * from "babylonjs/Bones/boneLookController";
  35924. export * from "babylonjs/Bones/skeleton";
  35925. }
  35926. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35927. import { Nullable } from "babylonjs/types";
  35928. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35929. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35930. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35931. /**
  35932. * Manage the gamepad inputs to control an arc rotate camera.
  35933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35934. */
  35935. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35936. /**
  35937. * Defines the camera the input is attached to.
  35938. */
  35939. camera: ArcRotateCamera;
  35940. /**
  35941. * Defines the gamepad the input is gathering event from.
  35942. */
  35943. gamepad: Nullable<Gamepad>;
  35944. /**
  35945. * Defines the gamepad rotation sensiblity.
  35946. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35947. */
  35948. gamepadRotationSensibility: number;
  35949. /**
  35950. * Defines the gamepad move sensiblity.
  35951. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35952. */
  35953. gamepadMoveSensibility: number;
  35954. private _onGamepadConnectedObserver;
  35955. private _onGamepadDisconnectedObserver;
  35956. /**
  35957. * Attach the input controls to a specific dom element to get the input from.
  35958. * @param element Defines the element the controls should be listened from
  35959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35960. */
  35961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35962. /**
  35963. * Detach the current controls from the specified dom element.
  35964. * @param element Defines the element to stop listening the inputs from
  35965. */
  35966. detachControl(element: Nullable<HTMLElement>): void;
  35967. /**
  35968. * Update the current camera state depending on the inputs that have been used this frame.
  35969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35970. */
  35971. checkInputs(): void;
  35972. /**
  35973. * Gets the class name of the current intput.
  35974. * @returns the class name
  35975. */
  35976. getClassName(): string;
  35977. /**
  35978. * Get the friendly name associated with the input class.
  35979. * @returns the input friendly name
  35980. */
  35981. getSimpleName(): string;
  35982. }
  35983. }
  35984. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  35985. import { Nullable } from "babylonjs/types";
  35986. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35987. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35988. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35989. interface ArcRotateCameraInputsManager {
  35990. /**
  35991. * Add orientation input support to the input manager.
  35992. * @returns the current input manager
  35993. */
  35994. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35995. }
  35996. }
  35997. /**
  35998. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36000. */
  36001. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36002. /**
  36003. * Defines the camera the input is attached to.
  36004. */
  36005. camera: ArcRotateCamera;
  36006. /**
  36007. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36008. */
  36009. alphaCorrection: number;
  36010. /**
  36011. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36012. */
  36013. gammaCorrection: number;
  36014. private _alpha;
  36015. private _gamma;
  36016. private _dirty;
  36017. private _deviceOrientationHandler;
  36018. /**
  36019. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36020. */
  36021. constructor();
  36022. /**
  36023. * Attach the input controls to a specific dom element to get the input from.
  36024. * @param element Defines the element the controls should be listened from
  36025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36026. */
  36027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36028. /** @hidden */
  36029. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36030. /**
  36031. * Update the current camera state depending on the inputs that have been used this frame.
  36032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36033. */
  36034. checkInputs(): void;
  36035. /**
  36036. * Detach the current controls from the specified dom element.
  36037. * @param element Defines the element to stop listening the inputs from
  36038. */
  36039. detachControl(element: Nullable<HTMLElement>): void;
  36040. /**
  36041. * Gets the class name of the current intput.
  36042. * @returns the class name
  36043. */
  36044. getClassName(): string;
  36045. /**
  36046. * Get the friendly name associated with the input class.
  36047. * @returns the input friendly name
  36048. */
  36049. getSimpleName(): string;
  36050. }
  36051. }
  36052. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36053. import { Nullable } from "babylonjs/types";
  36054. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36055. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36056. /**
  36057. * Listen to mouse events to control the camera.
  36058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36059. */
  36060. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36061. /**
  36062. * Defines the camera the input is attached to.
  36063. */
  36064. camera: FlyCamera;
  36065. /**
  36066. * Defines if touch is enabled. (Default is true.)
  36067. */
  36068. touchEnabled: boolean;
  36069. /**
  36070. * Defines the buttons associated with the input to handle camera rotation.
  36071. */
  36072. buttons: number[];
  36073. /**
  36074. * Assign buttons for Yaw control.
  36075. */
  36076. buttonsYaw: number[];
  36077. /**
  36078. * Assign buttons for Pitch control.
  36079. */
  36080. buttonsPitch: number[];
  36081. /**
  36082. * Assign buttons for Roll control.
  36083. */
  36084. buttonsRoll: number[];
  36085. /**
  36086. * Detect if any button is being pressed while mouse is moved.
  36087. * -1 = Mouse locked.
  36088. * 0 = Left button.
  36089. * 1 = Middle Button.
  36090. * 2 = Right Button.
  36091. */
  36092. activeButton: number;
  36093. /**
  36094. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36095. * Higher values reduce its sensitivity.
  36096. */
  36097. angularSensibility: number;
  36098. private _mousemoveCallback;
  36099. private _observer;
  36100. private _rollObserver;
  36101. private previousPosition;
  36102. private noPreventDefault;
  36103. private element;
  36104. /**
  36105. * Listen to mouse events to control the camera.
  36106. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36108. */
  36109. constructor(touchEnabled?: boolean);
  36110. /**
  36111. * Attach the mouse control to the HTML DOM element.
  36112. * @param element Defines the element that listens to the input events.
  36113. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36114. */
  36115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36116. /**
  36117. * Detach the current controls from the specified dom element.
  36118. * @param element Defines the element to stop listening the inputs from
  36119. */
  36120. detachControl(element: Nullable<HTMLElement>): void;
  36121. /**
  36122. * Gets the class name of the current input.
  36123. * @returns the class name.
  36124. */
  36125. getClassName(): string;
  36126. /**
  36127. * Get the friendly name associated with the input class.
  36128. * @returns the input's friendly name.
  36129. */
  36130. getSimpleName(): string;
  36131. private _pointerInput;
  36132. private _onMouseMove;
  36133. /**
  36134. * Rotate camera by mouse offset.
  36135. */
  36136. private rotateCamera;
  36137. }
  36138. }
  36139. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36140. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36141. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36142. /**
  36143. * Default Inputs manager for the FlyCamera.
  36144. * It groups all the default supported inputs for ease of use.
  36145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36146. */
  36147. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36148. /**
  36149. * Instantiates a new FlyCameraInputsManager.
  36150. * @param camera Defines the camera the inputs belong to.
  36151. */
  36152. constructor(camera: FlyCamera);
  36153. /**
  36154. * Add keyboard input support to the input manager.
  36155. * @returns the new FlyCameraKeyboardMoveInput().
  36156. */
  36157. addKeyboard(): FlyCameraInputsManager;
  36158. /**
  36159. * Add mouse input support to the input manager.
  36160. * @param touchEnabled Enable touch screen support.
  36161. * @returns the new FlyCameraMouseInput().
  36162. */
  36163. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36164. }
  36165. }
  36166. declare module "babylonjs/Cameras/flyCamera" {
  36167. import { Scene } from "babylonjs/scene";
  36168. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36170. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36171. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36172. /**
  36173. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36174. * such as in a 3D Space Shooter or a Flight Simulator.
  36175. */
  36176. export class FlyCamera extends TargetCamera {
  36177. /**
  36178. * Define the collision ellipsoid of the camera.
  36179. * This is helpful for simulating a camera body, like a player's body.
  36180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36181. */
  36182. ellipsoid: Vector3;
  36183. /**
  36184. * Define an offset for the position of the ellipsoid around the camera.
  36185. * This can be helpful if the camera is attached away from the player's body center,
  36186. * such as at its head.
  36187. */
  36188. ellipsoidOffset: Vector3;
  36189. /**
  36190. * Enable or disable collisions of the camera with the rest of the scene objects.
  36191. */
  36192. checkCollisions: boolean;
  36193. /**
  36194. * Enable or disable gravity on the camera.
  36195. */
  36196. applyGravity: boolean;
  36197. /**
  36198. * Define the current direction the camera is moving to.
  36199. */
  36200. cameraDirection: Vector3;
  36201. /**
  36202. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36203. * This overrides and empties cameraRotation.
  36204. */
  36205. rotationQuaternion: Quaternion;
  36206. /**
  36207. * Track Roll to maintain the wanted Rolling when looking around.
  36208. */
  36209. _trackRoll: number;
  36210. /**
  36211. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36212. */
  36213. rollCorrect: number;
  36214. /**
  36215. * Mimic a banked turn, Rolling the camera when Yawing.
  36216. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36217. */
  36218. bankedTurn: boolean;
  36219. /**
  36220. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36221. */
  36222. bankedTurnLimit: number;
  36223. /**
  36224. * Value of 0 disables the banked Roll.
  36225. * Value of 1 is equal to the Yaw angle in radians.
  36226. */
  36227. bankedTurnMultiplier: number;
  36228. /**
  36229. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36230. */
  36231. inputs: FlyCameraInputsManager;
  36232. /**
  36233. * Gets the input sensibility for mouse input.
  36234. * Higher values reduce sensitivity.
  36235. */
  36236. /**
  36237. * Sets the input sensibility for a mouse input.
  36238. * Higher values reduce sensitivity.
  36239. */
  36240. angularSensibility: number;
  36241. /**
  36242. * Get the keys for camera movement forward.
  36243. */
  36244. /**
  36245. * Set the keys for camera movement forward.
  36246. */
  36247. keysForward: number[];
  36248. /**
  36249. * Get the keys for camera movement backward.
  36250. */
  36251. keysBackward: number[];
  36252. /**
  36253. * Get the keys for camera movement up.
  36254. */
  36255. /**
  36256. * Set the keys for camera movement up.
  36257. */
  36258. keysUp: number[];
  36259. /**
  36260. * Get the keys for camera movement down.
  36261. */
  36262. /**
  36263. * Set the keys for camera movement down.
  36264. */
  36265. keysDown: number[];
  36266. /**
  36267. * Get the keys for camera movement left.
  36268. */
  36269. /**
  36270. * Set the keys for camera movement left.
  36271. */
  36272. keysLeft: number[];
  36273. /**
  36274. * Set the keys for camera movement right.
  36275. */
  36276. /**
  36277. * Set the keys for camera movement right.
  36278. */
  36279. keysRight: number[];
  36280. /**
  36281. * Event raised when the camera collides with a mesh in the scene.
  36282. */
  36283. onCollide: (collidedMesh: AbstractMesh) => void;
  36284. private _collider;
  36285. private _needMoveForGravity;
  36286. private _oldPosition;
  36287. private _diffPosition;
  36288. private _newPosition;
  36289. /** @hidden */
  36290. _localDirection: Vector3;
  36291. /** @hidden */
  36292. _transformedDirection: Vector3;
  36293. /**
  36294. * Instantiates a FlyCamera.
  36295. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36296. * such as in a 3D Space Shooter or a Flight Simulator.
  36297. * @param name Define the name of the camera in the scene.
  36298. * @param position Define the starting position of the camera in the scene.
  36299. * @param scene Define the scene the camera belongs to.
  36300. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36301. */
  36302. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36303. /**
  36304. * Attach a control to the HTML DOM element.
  36305. * @param element Defines the element that listens to the input events.
  36306. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36307. */
  36308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36309. /**
  36310. * Detach a control from the HTML DOM element.
  36311. * The camera will stop reacting to that input.
  36312. * @param element Defines the element that listens to the input events.
  36313. */
  36314. detachControl(element: HTMLElement): void;
  36315. private _collisionMask;
  36316. /**
  36317. * Get the mask that the camera ignores in collision events.
  36318. */
  36319. /**
  36320. * Set the mask that the camera ignores in collision events.
  36321. */
  36322. collisionMask: number;
  36323. /** @hidden */
  36324. _collideWithWorld(displacement: Vector3): void;
  36325. /** @hidden */
  36326. private _onCollisionPositionChange;
  36327. /** @hidden */
  36328. _checkInputs(): void;
  36329. /** @hidden */
  36330. _decideIfNeedsToMove(): boolean;
  36331. /** @hidden */
  36332. _updatePosition(): void;
  36333. /**
  36334. * Restore the Roll to its target value at the rate specified.
  36335. * @param rate - Higher means slower restoring.
  36336. * @hidden
  36337. */
  36338. restoreRoll(rate: number): void;
  36339. /**
  36340. * Destroy the camera and release the current resources held by it.
  36341. */
  36342. dispose(): void;
  36343. /**
  36344. * Get the current object class name.
  36345. * @returns the class name.
  36346. */
  36347. getClassName(): string;
  36348. }
  36349. }
  36350. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36351. import { Nullable } from "babylonjs/types";
  36352. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36353. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36354. /**
  36355. * Listen to keyboard events to control the camera.
  36356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36357. */
  36358. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36359. /**
  36360. * Defines the camera the input is attached to.
  36361. */
  36362. camera: FlyCamera;
  36363. /**
  36364. * The list of keyboard keys used to control the forward move of the camera.
  36365. */
  36366. keysForward: number[];
  36367. /**
  36368. * The list of keyboard keys used to control the backward move of the camera.
  36369. */
  36370. keysBackward: number[];
  36371. /**
  36372. * The list of keyboard keys used to control the forward move of the camera.
  36373. */
  36374. keysUp: number[];
  36375. /**
  36376. * The list of keyboard keys used to control the backward move of the camera.
  36377. */
  36378. keysDown: number[];
  36379. /**
  36380. * The list of keyboard keys used to control the right strafe move of the camera.
  36381. */
  36382. keysRight: number[];
  36383. /**
  36384. * The list of keyboard keys used to control the left strafe move of the camera.
  36385. */
  36386. keysLeft: number[];
  36387. private _keys;
  36388. private _onCanvasBlurObserver;
  36389. private _onKeyboardObserver;
  36390. private _engine;
  36391. private _scene;
  36392. /**
  36393. * Attach the input controls to a specific dom element to get the input from.
  36394. * @param element Defines the element the controls should be listened from
  36395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36396. */
  36397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36398. /**
  36399. * Detach the current controls from the specified dom element.
  36400. * @param element Defines the element to stop listening the inputs from
  36401. */
  36402. detachControl(element: Nullable<HTMLElement>): void;
  36403. /**
  36404. * Gets the class name of the current intput.
  36405. * @returns the class name
  36406. */
  36407. getClassName(): string;
  36408. /** @hidden */
  36409. _onLostFocus(e: FocusEvent): void;
  36410. /**
  36411. * Get the friendly name associated with the input class.
  36412. * @returns the input friendly name
  36413. */
  36414. getSimpleName(): string;
  36415. /**
  36416. * Update the current camera state depending on the inputs that have been used this frame.
  36417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36418. */
  36419. checkInputs(): void;
  36420. }
  36421. }
  36422. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36423. import { Nullable } from "babylonjs/types";
  36424. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36425. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36426. module "babylonjs/Cameras/freeCameraInputsManager" {
  36427. interface FreeCameraInputsManager {
  36428. /**
  36429. * Add orientation input support to the input manager.
  36430. * @returns the current input manager
  36431. */
  36432. addDeviceOrientation(): FreeCameraInputsManager;
  36433. }
  36434. }
  36435. /**
  36436. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36437. * Screen rotation is taken into account.
  36438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36439. */
  36440. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36441. private _camera;
  36442. private _screenOrientationAngle;
  36443. private _constantTranform;
  36444. private _screenQuaternion;
  36445. private _alpha;
  36446. private _beta;
  36447. private _gamma;
  36448. /**
  36449. * Instantiates a new input
  36450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36451. */
  36452. constructor();
  36453. /**
  36454. * Define the camera controlled by the input.
  36455. */
  36456. camera: FreeCamera;
  36457. /**
  36458. * Attach the input controls to a specific dom element to get the input from.
  36459. * @param element Defines the element the controls should be listened from
  36460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36461. */
  36462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36463. private _orientationChanged;
  36464. private _deviceOrientation;
  36465. /**
  36466. * Detach the current controls from the specified dom element.
  36467. * @param element Defines the element to stop listening the inputs from
  36468. */
  36469. detachControl(element: Nullable<HTMLElement>): void;
  36470. /**
  36471. * Update the current camera state depending on the inputs that have been used this frame.
  36472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36473. */
  36474. checkInputs(): void;
  36475. /**
  36476. * Gets the class name of the current intput.
  36477. * @returns the class name
  36478. */
  36479. getClassName(): string;
  36480. /**
  36481. * Get the friendly name associated with the input class.
  36482. * @returns the input friendly name
  36483. */
  36484. getSimpleName(): string;
  36485. }
  36486. }
  36487. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36488. import { Nullable } from "babylonjs/types";
  36489. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36490. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36491. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36492. /**
  36493. * Manage the gamepad inputs to control a free camera.
  36494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36495. */
  36496. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36497. /**
  36498. * Define the camera the input is attached to.
  36499. */
  36500. camera: FreeCamera;
  36501. /**
  36502. * Define the Gamepad controlling the input
  36503. */
  36504. gamepad: Nullable<Gamepad>;
  36505. /**
  36506. * Defines the gamepad rotation sensiblity.
  36507. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36508. */
  36509. gamepadAngularSensibility: number;
  36510. /**
  36511. * Defines the gamepad move sensiblity.
  36512. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36513. */
  36514. gamepadMoveSensibility: number;
  36515. private _onGamepadConnectedObserver;
  36516. private _onGamepadDisconnectedObserver;
  36517. private _cameraTransform;
  36518. private _deltaTransform;
  36519. private _vector3;
  36520. private _vector2;
  36521. /**
  36522. * Attach the input controls to a specific dom element to get the input from.
  36523. * @param element Defines the element the controls should be listened from
  36524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36525. */
  36526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36527. /**
  36528. * Detach the current controls from the specified dom element.
  36529. * @param element Defines the element to stop listening the inputs from
  36530. */
  36531. detachControl(element: Nullable<HTMLElement>): void;
  36532. /**
  36533. * Update the current camera state depending on the inputs that have been used this frame.
  36534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36535. */
  36536. checkInputs(): void;
  36537. /**
  36538. * Gets the class name of the current intput.
  36539. * @returns the class name
  36540. */
  36541. getClassName(): string;
  36542. /**
  36543. * Get the friendly name associated with the input class.
  36544. * @returns the input friendly name
  36545. */
  36546. getSimpleName(): string;
  36547. }
  36548. }
  36549. declare module "babylonjs/Misc/virtualJoystick" {
  36550. import { Nullable } from "babylonjs/types";
  36551. import { Vector3 } from "babylonjs/Maths/math";
  36552. /**
  36553. * Defines the potential axis of a Joystick
  36554. */
  36555. export enum JoystickAxis {
  36556. /** X axis */
  36557. X = 0,
  36558. /** Y axis */
  36559. Y = 1,
  36560. /** Z axis */
  36561. Z = 2
  36562. }
  36563. /**
  36564. * Class used to define virtual joystick (used in touch mode)
  36565. */
  36566. export class VirtualJoystick {
  36567. /**
  36568. * Gets or sets a boolean indicating that left and right values must be inverted
  36569. */
  36570. reverseLeftRight: boolean;
  36571. /**
  36572. * Gets or sets a boolean indicating that up and down values must be inverted
  36573. */
  36574. reverseUpDown: boolean;
  36575. /**
  36576. * Gets the offset value for the position (ie. the change of the position value)
  36577. */
  36578. deltaPosition: Vector3;
  36579. /**
  36580. * Gets a boolean indicating if the virtual joystick was pressed
  36581. */
  36582. pressed: boolean;
  36583. /**
  36584. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36585. */
  36586. static Canvas: Nullable<HTMLCanvasElement>;
  36587. private static _globalJoystickIndex;
  36588. private static vjCanvasContext;
  36589. private static vjCanvasWidth;
  36590. private static vjCanvasHeight;
  36591. private static halfWidth;
  36592. private _action;
  36593. private _axisTargetedByLeftAndRight;
  36594. private _axisTargetedByUpAndDown;
  36595. private _joystickSensibility;
  36596. private _inversedSensibility;
  36597. private _joystickPointerID;
  36598. private _joystickColor;
  36599. private _joystickPointerPos;
  36600. private _joystickPreviousPointerPos;
  36601. private _joystickPointerStartPos;
  36602. private _deltaJoystickVector;
  36603. private _leftJoystick;
  36604. private _touches;
  36605. private _onPointerDownHandlerRef;
  36606. private _onPointerMoveHandlerRef;
  36607. private _onPointerUpHandlerRef;
  36608. private _onResize;
  36609. /**
  36610. * Creates a new virtual joystick
  36611. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36612. */
  36613. constructor(leftJoystick?: boolean);
  36614. /**
  36615. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36616. * @param newJoystickSensibility defines the new sensibility
  36617. */
  36618. setJoystickSensibility(newJoystickSensibility: number): void;
  36619. private _onPointerDown;
  36620. private _onPointerMove;
  36621. private _onPointerUp;
  36622. /**
  36623. * Change the color of the virtual joystick
  36624. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36625. */
  36626. setJoystickColor(newColor: string): void;
  36627. /**
  36628. * Defines a callback to call when the joystick is touched
  36629. * @param action defines the callback
  36630. */
  36631. setActionOnTouch(action: () => any): void;
  36632. /**
  36633. * Defines which axis you'd like to control for left & right
  36634. * @param axis defines the axis to use
  36635. */
  36636. setAxisForLeftRight(axis: JoystickAxis): void;
  36637. /**
  36638. * Defines which axis you'd like to control for up & down
  36639. * @param axis defines the axis to use
  36640. */
  36641. setAxisForUpDown(axis: JoystickAxis): void;
  36642. private _drawVirtualJoystick;
  36643. /**
  36644. * Release internal HTML canvas
  36645. */
  36646. releaseCanvas(): void;
  36647. }
  36648. }
  36649. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36650. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36651. import { Nullable } from "babylonjs/types";
  36652. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36653. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36654. module "babylonjs/Cameras/freeCameraInputsManager" {
  36655. interface FreeCameraInputsManager {
  36656. /**
  36657. * Add virtual joystick input support to the input manager.
  36658. * @returns the current input manager
  36659. */
  36660. addVirtualJoystick(): FreeCameraInputsManager;
  36661. }
  36662. }
  36663. /**
  36664. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36666. */
  36667. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36668. /**
  36669. * Defines the camera the input is attached to.
  36670. */
  36671. camera: FreeCamera;
  36672. private _leftjoystick;
  36673. private _rightjoystick;
  36674. /**
  36675. * Gets the left stick of the virtual joystick.
  36676. * @returns The virtual Joystick
  36677. */
  36678. getLeftJoystick(): VirtualJoystick;
  36679. /**
  36680. * Gets the right stick of the virtual joystick.
  36681. * @returns The virtual Joystick
  36682. */
  36683. getRightJoystick(): VirtualJoystick;
  36684. /**
  36685. * Update the current camera state depending on the inputs that have been used this frame.
  36686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36687. */
  36688. checkInputs(): void;
  36689. /**
  36690. * Attach the input controls to a specific dom element to get the input from.
  36691. * @param element Defines the element the controls should be listened from
  36692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36693. */
  36694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36695. /**
  36696. * Detach the current controls from the specified dom element.
  36697. * @param element Defines the element to stop listening the inputs from
  36698. */
  36699. detachControl(element: Nullable<HTMLElement>): void;
  36700. /**
  36701. * Gets the class name of the current intput.
  36702. * @returns the class name
  36703. */
  36704. getClassName(): string;
  36705. /**
  36706. * Get the friendly name associated with the input class.
  36707. * @returns the input friendly name
  36708. */
  36709. getSimpleName(): string;
  36710. }
  36711. }
  36712. declare module "babylonjs/Cameras/Inputs/index" {
  36713. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36714. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36715. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36716. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36717. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36718. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36719. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36720. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36721. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36722. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36723. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36724. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36725. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36726. }
  36727. declare module "babylonjs/Cameras/touchCamera" {
  36728. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36729. import { Scene } from "babylonjs/scene";
  36730. import { Vector3 } from "babylonjs/Maths/math";
  36731. /**
  36732. * This represents a FPS type of camera controlled by touch.
  36733. * This is like a universal camera minus the Gamepad controls.
  36734. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36735. */
  36736. export class TouchCamera extends FreeCamera {
  36737. /**
  36738. * Defines the touch sensibility for rotation.
  36739. * The higher the faster.
  36740. */
  36741. touchAngularSensibility: number;
  36742. /**
  36743. * Defines the touch sensibility for move.
  36744. * The higher the faster.
  36745. */
  36746. touchMoveSensibility: number;
  36747. /**
  36748. * Instantiates a new touch camera.
  36749. * This represents a FPS type of camera controlled by touch.
  36750. * This is like a universal camera minus the Gamepad controls.
  36751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36752. * @param name Define the name of the camera in the scene
  36753. * @param position Define the start position of the camera in the scene
  36754. * @param scene Define the scene the camera belongs to
  36755. */
  36756. constructor(name: string, position: Vector3, scene: Scene);
  36757. /**
  36758. * Gets the current object class name.
  36759. * @return the class name
  36760. */
  36761. getClassName(): string;
  36762. /** @hidden */
  36763. _setupInputs(): void;
  36764. }
  36765. }
  36766. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36768. import { Scene } from "babylonjs/scene";
  36769. import { Vector3, Axis } from "babylonjs/Maths/math";
  36770. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36771. /**
  36772. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36773. * being tilted forward or back and left or right.
  36774. */
  36775. export class DeviceOrientationCamera extends FreeCamera {
  36776. private _initialQuaternion;
  36777. private _quaternionCache;
  36778. /**
  36779. * Creates a new device orientation camera
  36780. * @param name The name of the camera
  36781. * @param position The start position camera
  36782. * @param scene The scene the camera belongs to
  36783. */
  36784. constructor(name: string, position: Vector3, scene: Scene);
  36785. /**
  36786. * Gets the current instance class name ("DeviceOrientationCamera").
  36787. * This helps avoiding instanceof at run time.
  36788. * @returns the class name
  36789. */
  36790. getClassName(): string;
  36791. /**
  36792. * @hidden
  36793. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36794. */
  36795. _checkInputs(): void;
  36796. /**
  36797. * Reset the camera to its default orientation on the specified axis only.
  36798. * @param axis The axis to reset
  36799. */
  36800. resetToCurrentRotation(axis?: Axis): void;
  36801. }
  36802. }
  36803. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36804. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36805. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36806. import { Nullable } from "babylonjs/types";
  36807. /**
  36808. * Manage the keyboard inputs to control the movement of a follow camera.
  36809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36810. */
  36811. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36812. /**
  36813. * Defines the camera the input is attached to.
  36814. */
  36815. camera: FollowCamera;
  36816. /**
  36817. * Defines the list of key codes associated with the up action (increase heightOffset)
  36818. */
  36819. keysHeightOffsetIncr: number[];
  36820. /**
  36821. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36822. */
  36823. keysHeightOffsetDecr: number[];
  36824. /**
  36825. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36826. */
  36827. keysHeightOffsetModifierAlt: boolean;
  36828. /**
  36829. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36830. */
  36831. keysHeightOffsetModifierCtrl: boolean;
  36832. /**
  36833. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36834. */
  36835. keysHeightOffsetModifierShift: boolean;
  36836. /**
  36837. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36838. */
  36839. keysRotationOffsetIncr: number[];
  36840. /**
  36841. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36842. */
  36843. keysRotationOffsetDecr: number[];
  36844. /**
  36845. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36846. */
  36847. keysRotationOffsetModifierAlt: boolean;
  36848. /**
  36849. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36850. */
  36851. keysRotationOffsetModifierCtrl: boolean;
  36852. /**
  36853. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36854. */
  36855. keysRotationOffsetModifierShift: boolean;
  36856. /**
  36857. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36858. */
  36859. keysRadiusIncr: number[];
  36860. /**
  36861. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36862. */
  36863. keysRadiusDecr: number[];
  36864. /**
  36865. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36866. */
  36867. keysRadiusModifierAlt: boolean;
  36868. /**
  36869. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36870. */
  36871. keysRadiusModifierCtrl: boolean;
  36872. /**
  36873. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36874. */
  36875. keysRadiusModifierShift: boolean;
  36876. /**
  36877. * Defines the rate of change of heightOffset.
  36878. */
  36879. heightSensibility: number;
  36880. /**
  36881. * Defines the rate of change of rotationOffset.
  36882. */
  36883. rotationSensibility: number;
  36884. /**
  36885. * Defines the rate of change of radius.
  36886. */
  36887. radiusSensibility: number;
  36888. private _keys;
  36889. private _ctrlPressed;
  36890. private _altPressed;
  36891. private _shiftPressed;
  36892. private _onCanvasBlurObserver;
  36893. private _onKeyboardObserver;
  36894. private _engine;
  36895. private _scene;
  36896. /**
  36897. * Attach the input controls to a specific dom element to get the input from.
  36898. * @param element Defines the element the controls should be listened from
  36899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36900. */
  36901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36902. /**
  36903. * Detach the current controls from the specified dom element.
  36904. * @param element Defines the element to stop listening the inputs from
  36905. */
  36906. detachControl(element: Nullable<HTMLElement>): void;
  36907. /**
  36908. * Update the current camera state depending on the inputs that have been used this frame.
  36909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36910. */
  36911. checkInputs(): void;
  36912. /**
  36913. * Gets the class name of the current input.
  36914. * @returns the class name
  36915. */
  36916. getClassName(): string;
  36917. /**
  36918. * Get the friendly name associated with the input class.
  36919. * @returns the input friendly name
  36920. */
  36921. getSimpleName(): string;
  36922. /**
  36923. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36924. * allow modification of the heightOffset value.
  36925. */
  36926. private _modifierHeightOffset;
  36927. /**
  36928. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36929. * allow modification of the rotationOffset value.
  36930. */
  36931. private _modifierRotationOffset;
  36932. /**
  36933. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36934. * allow modification of the radius value.
  36935. */
  36936. private _modifierRadius;
  36937. }
  36938. }
  36939. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36940. import { Nullable } from "babylonjs/types";
  36941. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36942. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36943. /**
  36944. * Manage the mouse wheel inputs to control a follow camera.
  36945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36946. */
  36947. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36948. /**
  36949. * Defines the camera the input is attached to.
  36950. */
  36951. camera: FollowCamera;
  36952. /**
  36953. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36954. */
  36955. axisControlRadius: boolean;
  36956. /**
  36957. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36958. */
  36959. axisControlHeight: boolean;
  36960. /**
  36961. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36962. */
  36963. axisControlRotation: boolean;
  36964. /**
  36965. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36966. * relation to mouseWheel events.
  36967. */
  36968. wheelPrecision: number;
  36969. /**
  36970. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36971. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36972. */
  36973. wheelDeltaPercentage: number;
  36974. private _wheel;
  36975. private _observer;
  36976. /**
  36977. * Attach the input controls to a specific dom element to get the input from.
  36978. * @param element Defines the element the controls should be listened from
  36979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36980. */
  36981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36982. /**
  36983. * Detach the current controls from the specified dom element.
  36984. * @param element Defines the element to stop listening the inputs from
  36985. */
  36986. detachControl(element: Nullable<HTMLElement>): void;
  36987. /**
  36988. * Gets the class name of the current intput.
  36989. * @returns the class name
  36990. */
  36991. getClassName(): string;
  36992. /**
  36993. * Get the friendly name associated with the input class.
  36994. * @returns the input friendly name
  36995. */
  36996. getSimpleName(): string;
  36997. }
  36998. }
  36999. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37000. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37001. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37002. /**
  37003. * Default Inputs manager for the FollowCamera.
  37004. * It groups all the default supported inputs for ease of use.
  37005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37006. */
  37007. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37008. /**
  37009. * Instantiates a new FollowCameraInputsManager.
  37010. * @param camera Defines the camera the inputs belong to
  37011. */
  37012. constructor(camera: FollowCamera);
  37013. /**
  37014. * Add keyboard input support to the input manager.
  37015. * @returns the current input manager
  37016. */
  37017. addKeyboard(): FollowCameraInputsManager;
  37018. /**
  37019. * Add mouse wheel input support to the input manager.
  37020. * @returns the current input manager
  37021. */
  37022. addMouseWheel(): FollowCameraInputsManager;
  37023. /**
  37024. * Add pointers input support to the input manager.
  37025. * @returns the current input manager
  37026. */
  37027. addPointers(): FollowCameraInputsManager;
  37028. /**
  37029. * Add orientation input support to the input manager.
  37030. * @returns the current input manager
  37031. */
  37032. addVRDeviceOrientation(): FollowCameraInputsManager;
  37033. }
  37034. }
  37035. declare module "babylonjs/Cameras/followCamera" {
  37036. import { Nullable } from "babylonjs/types";
  37037. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37038. import { Scene } from "babylonjs/scene";
  37039. import { Vector3 } from "babylonjs/Maths/math";
  37040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37041. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37042. /**
  37043. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37044. * an arc rotate version arcFollowCamera are available.
  37045. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37046. */
  37047. export class FollowCamera extends TargetCamera {
  37048. /**
  37049. * Distance the follow camera should follow an object at
  37050. */
  37051. radius: number;
  37052. /**
  37053. * Minimum allowed distance of the camera to the axis of rotation
  37054. * (The camera can not get closer).
  37055. * This can help limiting how the Camera is able to move in the scene.
  37056. */
  37057. lowerRadiusLimit: Nullable<number>;
  37058. /**
  37059. * Maximum allowed distance of the camera to the axis of rotation
  37060. * (The camera can not get further).
  37061. * This can help limiting how the Camera is able to move in the scene.
  37062. */
  37063. upperRadiusLimit: Nullable<number>;
  37064. /**
  37065. * Define a rotation offset between the camera and the object it follows
  37066. */
  37067. rotationOffset: number;
  37068. /**
  37069. * Minimum allowed angle to camera position relative to target object.
  37070. * This can help limiting how the Camera is able to move in the scene.
  37071. */
  37072. lowerRotationOffsetLimit: Nullable<number>;
  37073. /**
  37074. * Maximum allowed angle to camera position relative to target object.
  37075. * This can help limiting how the Camera is able to move in the scene.
  37076. */
  37077. upperRotationOffsetLimit: Nullable<number>;
  37078. /**
  37079. * Define a height offset between the camera and the object it follows.
  37080. * It can help following an object from the top (like a car chaing a plane)
  37081. */
  37082. heightOffset: number;
  37083. /**
  37084. * Minimum allowed height of camera position relative to target object.
  37085. * This can help limiting how the Camera is able to move in the scene.
  37086. */
  37087. lowerHeightOffsetLimit: Nullable<number>;
  37088. /**
  37089. * Maximum allowed height of camera position relative to target object.
  37090. * This can help limiting how the Camera is able to move in the scene.
  37091. */
  37092. upperHeightOffsetLimit: Nullable<number>;
  37093. /**
  37094. * Define how fast the camera can accelerate to follow it s target.
  37095. */
  37096. cameraAcceleration: number;
  37097. /**
  37098. * Define the speed limit of the camera following an object.
  37099. */
  37100. maxCameraSpeed: number;
  37101. /**
  37102. * Define the target of the camera.
  37103. */
  37104. lockedTarget: Nullable<AbstractMesh>;
  37105. /**
  37106. * Defines the input associated with the camera.
  37107. */
  37108. inputs: FollowCameraInputsManager;
  37109. /**
  37110. * Instantiates the follow camera.
  37111. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37112. * @param name Define the name of the camera in the scene
  37113. * @param position Define the position of the camera
  37114. * @param scene Define the scene the camera belong to
  37115. * @param lockedTarget Define the target of the camera
  37116. */
  37117. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37118. private _follow;
  37119. /**
  37120. * Attached controls to the current camera.
  37121. * @param element Defines the element the controls should be listened from
  37122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37123. */
  37124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37125. /**
  37126. * Detach the current controls from the camera.
  37127. * The camera will stop reacting to inputs.
  37128. * @param element Defines the element to stop listening the inputs from
  37129. */
  37130. detachControl(element: HTMLElement): void;
  37131. /** @hidden */
  37132. _checkInputs(): void;
  37133. private _checkLimits;
  37134. /**
  37135. * Gets the camera class name.
  37136. * @returns the class name
  37137. */
  37138. getClassName(): string;
  37139. }
  37140. /**
  37141. * Arc Rotate version of the follow camera.
  37142. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37143. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37144. */
  37145. export class ArcFollowCamera extends TargetCamera {
  37146. /** The longitudinal angle of the camera */
  37147. alpha: number;
  37148. /** The latitudinal angle of the camera */
  37149. beta: number;
  37150. /** The radius of the camera from its target */
  37151. radius: number;
  37152. /** Define the camera target (the messh it should follow) */
  37153. target: Nullable<AbstractMesh>;
  37154. private _cartesianCoordinates;
  37155. /**
  37156. * Instantiates a new ArcFollowCamera
  37157. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37158. * @param name Define the name of the camera
  37159. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37160. * @param beta Define the rotation angle of the camera around the elevation axis
  37161. * @param radius Define the radius of the camera from its target point
  37162. * @param target Define the target of the camera
  37163. * @param scene Define the scene the camera belongs to
  37164. */
  37165. constructor(name: string,
  37166. /** The longitudinal angle of the camera */
  37167. alpha: number,
  37168. /** The latitudinal angle of the camera */
  37169. beta: number,
  37170. /** The radius of the camera from its target */
  37171. radius: number,
  37172. /** Define the camera target (the messh it should follow) */
  37173. target: Nullable<AbstractMesh>, scene: Scene);
  37174. private _follow;
  37175. /** @hidden */
  37176. _checkInputs(): void;
  37177. /**
  37178. * Returns the class name of the object.
  37179. * It is mostly used internally for serialization purposes.
  37180. */
  37181. getClassName(): string;
  37182. }
  37183. }
  37184. declare module "babylonjs/Cameras/universalCamera" {
  37185. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37186. import { Scene } from "babylonjs/scene";
  37187. import { Vector3 } from "babylonjs/Maths/math";
  37188. /**
  37189. * 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,
  37190. * which still works and will still be found in many Playgrounds.
  37191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37192. */
  37193. export class UniversalCamera extends TouchCamera {
  37194. /**
  37195. * Defines the gamepad rotation sensiblity.
  37196. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37197. */
  37198. gamepadAngularSensibility: number;
  37199. /**
  37200. * Defines the gamepad move sensiblity.
  37201. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37202. */
  37203. gamepadMoveSensibility: number;
  37204. /**
  37205. * 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,
  37206. * which still works and will still be found in many Playgrounds.
  37207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37208. * @param name Define the name of the camera in the scene
  37209. * @param position Define the start position of the camera in the scene
  37210. * @param scene Define the scene the camera belongs to
  37211. */
  37212. constructor(name: string, position: Vector3, scene: Scene);
  37213. /**
  37214. * Gets the current object class name.
  37215. * @return the class name
  37216. */
  37217. getClassName(): string;
  37218. }
  37219. }
  37220. declare module "babylonjs/Cameras/gamepadCamera" {
  37221. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37222. import { Scene } from "babylonjs/scene";
  37223. import { Vector3 } from "babylonjs/Maths/math";
  37224. /**
  37225. * This represents a FPS type of camera. This is only here for back compat purpose.
  37226. * Please use the UniversalCamera instead as both are identical.
  37227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37228. */
  37229. export class GamepadCamera extends UniversalCamera {
  37230. /**
  37231. * Instantiates a new Gamepad Camera
  37232. * This represents a FPS type of camera. This is only here for back compat purpose.
  37233. * Please use the UniversalCamera instead as both are identical.
  37234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37235. * @param name Define the name of the camera in the scene
  37236. * @param position Define the start position of the camera in the scene
  37237. * @param scene Define the scene the camera belongs to
  37238. */
  37239. constructor(name: string, position: Vector3, scene: Scene);
  37240. /**
  37241. * Gets the current object class name.
  37242. * @return the class name
  37243. */
  37244. getClassName(): string;
  37245. }
  37246. }
  37247. declare module "babylonjs/Shaders/pass.fragment" {
  37248. /** @hidden */
  37249. export var passPixelShader: {
  37250. name: string;
  37251. shader: string;
  37252. };
  37253. }
  37254. declare module "babylonjs/Shaders/passCube.fragment" {
  37255. /** @hidden */
  37256. export var passCubePixelShader: {
  37257. name: string;
  37258. shader: string;
  37259. };
  37260. }
  37261. declare module "babylonjs/PostProcesses/passPostProcess" {
  37262. import { Nullable } from "babylonjs/types";
  37263. import { Camera } from "babylonjs/Cameras/camera";
  37264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37265. import { Engine } from "babylonjs/Engines/engine";
  37266. import "babylonjs/Shaders/pass.fragment";
  37267. import "babylonjs/Shaders/passCube.fragment";
  37268. /**
  37269. * PassPostProcess which produces an output the same as it's input
  37270. */
  37271. export class PassPostProcess extends PostProcess {
  37272. /**
  37273. * Creates the PassPostProcess
  37274. * @param name The name of the effect.
  37275. * @param options The required width/height ratio to downsize to before computing the render pass.
  37276. * @param camera The camera to apply the render pass to.
  37277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37278. * @param engine The engine which the post process will be applied. (default: current engine)
  37279. * @param reusable If the post process can be reused on the same frame. (default: false)
  37280. * @param textureType The type of texture to be used when performing the post processing.
  37281. * @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)
  37282. */
  37283. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37284. }
  37285. /**
  37286. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37287. */
  37288. export class PassCubePostProcess extends PostProcess {
  37289. private _face;
  37290. /**
  37291. * Gets or sets the cube face to display.
  37292. * * 0 is +X
  37293. * * 1 is -X
  37294. * * 2 is +Y
  37295. * * 3 is -Y
  37296. * * 4 is +Z
  37297. * * 5 is -Z
  37298. */
  37299. face: number;
  37300. /**
  37301. * Creates the PassCubePostProcess
  37302. * @param name The name of the effect.
  37303. * @param options The required width/height ratio to downsize to before computing the render pass.
  37304. * @param camera The camera to apply the render pass to.
  37305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37306. * @param engine The engine which the post process will be applied. (default: current engine)
  37307. * @param reusable If the post process can be reused on the same frame. (default: false)
  37308. * @param textureType The type of texture to be used when performing the post processing.
  37309. * @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)
  37310. */
  37311. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37312. }
  37313. }
  37314. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37315. /** @hidden */
  37316. export var anaglyphPixelShader: {
  37317. name: string;
  37318. shader: string;
  37319. };
  37320. }
  37321. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37322. import { Engine } from "babylonjs/Engines/engine";
  37323. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37324. import { Camera } from "babylonjs/Cameras/camera";
  37325. import "babylonjs/Shaders/anaglyph.fragment";
  37326. /**
  37327. * Postprocess used to generate anaglyphic rendering
  37328. */
  37329. export class AnaglyphPostProcess extends PostProcess {
  37330. private _passedProcess;
  37331. /**
  37332. * Creates a new AnaglyphPostProcess
  37333. * @param name defines postprocess name
  37334. * @param options defines creation options or target ratio scale
  37335. * @param rigCameras defines cameras using this postprocess
  37336. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37337. * @param engine defines hosting engine
  37338. * @param reusable defines if the postprocess will be reused multiple times per frame
  37339. */
  37340. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37341. }
  37342. }
  37343. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37344. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37345. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37346. import { Scene } from "babylonjs/scene";
  37347. import { Vector3 } from "babylonjs/Maths/math";
  37348. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37349. /**
  37350. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37351. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37352. */
  37353. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37354. /**
  37355. * Creates a new AnaglyphArcRotateCamera
  37356. * @param name defines camera name
  37357. * @param alpha defines alpha angle (in radians)
  37358. * @param beta defines beta angle (in radians)
  37359. * @param radius defines radius
  37360. * @param target defines camera target
  37361. * @param interaxialDistance defines distance between each color axis
  37362. * @param scene defines the hosting scene
  37363. */
  37364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37365. /**
  37366. * Gets camera class name
  37367. * @returns AnaglyphArcRotateCamera
  37368. */
  37369. getClassName(): string;
  37370. }
  37371. }
  37372. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37373. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37374. import { Scene } from "babylonjs/scene";
  37375. import { Vector3 } from "babylonjs/Maths/math";
  37376. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37377. /**
  37378. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37380. */
  37381. export class AnaglyphFreeCamera extends FreeCamera {
  37382. /**
  37383. * Creates a new AnaglyphFreeCamera
  37384. * @param name defines camera name
  37385. * @param position defines initial position
  37386. * @param interaxialDistance defines distance between each color axis
  37387. * @param scene defines the hosting scene
  37388. */
  37389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37390. /**
  37391. * Gets camera class name
  37392. * @returns AnaglyphFreeCamera
  37393. */
  37394. getClassName(): string;
  37395. }
  37396. }
  37397. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37398. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37399. import { Scene } from "babylonjs/scene";
  37400. import { Vector3 } from "babylonjs/Maths/math";
  37401. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37402. /**
  37403. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37404. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37405. */
  37406. export class AnaglyphGamepadCamera extends GamepadCamera {
  37407. /**
  37408. * Creates a new AnaglyphGamepadCamera
  37409. * @param name defines camera name
  37410. * @param position defines initial position
  37411. * @param interaxialDistance defines distance between each color axis
  37412. * @param scene defines the hosting scene
  37413. */
  37414. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37415. /**
  37416. * Gets camera class name
  37417. * @returns AnaglyphGamepadCamera
  37418. */
  37419. getClassName(): string;
  37420. }
  37421. }
  37422. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37423. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37424. import { Scene } from "babylonjs/scene";
  37425. import { Vector3 } from "babylonjs/Maths/math";
  37426. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37427. /**
  37428. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37429. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37430. */
  37431. export class AnaglyphUniversalCamera extends UniversalCamera {
  37432. /**
  37433. * Creates a new AnaglyphUniversalCamera
  37434. * @param name defines camera name
  37435. * @param position defines initial position
  37436. * @param interaxialDistance defines distance between each color axis
  37437. * @param scene defines the hosting scene
  37438. */
  37439. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37440. /**
  37441. * Gets camera class name
  37442. * @returns AnaglyphUniversalCamera
  37443. */
  37444. getClassName(): string;
  37445. }
  37446. }
  37447. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37448. /** @hidden */
  37449. export var stereoscopicInterlacePixelShader: {
  37450. name: string;
  37451. shader: string;
  37452. };
  37453. }
  37454. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37455. import { Camera } from "babylonjs/Cameras/camera";
  37456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37457. import { Engine } from "babylonjs/Engines/engine";
  37458. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37459. /**
  37460. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37461. */
  37462. export class StereoscopicInterlacePostProcess extends PostProcess {
  37463. private _stepSize;
  37464. private _passedProcess;
  37465. /**
  37466. * Initializes a StereoscopicInterlacePostProcess
  37467. * @param name The name of the effect.
  37468. * @param rigCameras The rig cameras to be appled to the post process
  37469. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37471. * @param engine The engine which the post process will be applied. (default: current engine)
  37472. * @param reusable If the post process can be reused on the same frame. (default: false)
  37473. */
  37474. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37475. }
  37476. }
  37477. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37478. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37479. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37480. import { Scene } from "babylonjs/scene";
  37481. import { Vector3 } from "babylonjs/Maths/math";
  37482. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37483. /**
  37484. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37485. * @see http://doc.babylonjs.com/features/cameras
  37486. */
  37487. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37488. /**
  37489. * Creates a new StereoscopicArcRotateCamera
  37490. * @param name defines camera name
  37491. * @param alpha defines alpha angle (in radians)
  37492. * @param beta defines beta angle (in radians)
  37493. * @param radius defines radius
  37494. * @param target defines camera target
  37495. * @param interaxialDistance defines distance between each color axis
  37496. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37497. * @param scene defines the hosting scene
  37498. */
  37499. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37500. /**
  37501. * Gets camera class name
  37502. * @returns StereoscopicArcRotateCamera
  37503. */
  37504. getClassName(): string;
  37505. }
  37506. }
  37507. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37508. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37509. import { Scene } from "babylonjs/scene";
  37510. import { Vector3 } from "babylonjs/Maths/math";
  37511. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37512. /**
  37513. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37514. * @see http://doc.babylonjs.com/features/cameras
  37515. */
  37516. export class StereoscopicFreeCamera extends FreeCamera {
  37517. /**
  37518. * Creates a new StereoscopicFreeCamera
  37519. * @param name defines camera name
  37520. * @param position defines initial position
  37521. * @param interaxialDistance defines distance between each color axis
  37522. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37523. * @param scene defines the hosting scene
  37524. */
  37525. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37526. /**
  37527. * Gets camera class name
  37528. * @returns StereoscopicFreeCamera
  37529. */
  37530. getClassName(): string;
  37531. }
  37532. }
  37533. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37534. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37535. import { Scene } from "babylonjs/scene";
  37536. import { Vector3 } from "babylonjs/Maths/math";
  37537. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37538. /**
  37539. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37540. * @see http://doc.babylonjs.com/features/cameras
  37541. */
  37542. export class StereoscopicGamepadCamera extends GamepadCamera {
  37543. /**
  37544. * Creates a new StereoscopicGamepadCamera
  37545. * @param name defines camera name
  37546. * @param position defines initial position
  37547. * @param interaxialDistance defines distance between each color axis
  37548. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37549. * @param scene defines the hosting scene
  37550. */
  37551. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37552. /**
  37553. * Gets camera class name
  37554. * @returns StereoscopicGamepadCamera
  37555. */
  37556. getClassName(): string;
  37557. }
  37558. }
  37559. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37560. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37561. import { Scene } from "babylonjs/scene";
  37562. import { Vector3 } from "babylonjs/Maths/math";
  37563. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37564. /**
  37565. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37566. * @see http://doc.babylonjs.com/features/cameras
  37567. */
  37568. export class StereoscopicUniversalCamera extends UniversalCamera {
  37569. /**
  37570. * Creates a new StereoscopicUniversalCamera
  37571. * @param name defines camera name
  37572. * @param position defines initial position
  37573. * @param interaxialDistance defines distance between each color axis
  37574. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37575. * @param scene defines the hosting scene
  37576. */
  37577. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37578. /**
  37579. * Gets camera class name
  37580. * @returns StereoscopicUniversalCamera
  37581. */
  37582. getClassName(): string;
  37583. }
  37584. }
  37585. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37586. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37587. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37588. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37589. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37590. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37591. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37592. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37593. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37594. }
  37595. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37596. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37597. import { Scene } from "babylonjs/scene";
  37598. import { Vector3 } from "babylonjs/Maths/math";
  37599. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37600. /**
  37601. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37602. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37603. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37604. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37605. */
  37606. export class VirtualJoysticksCamera extends FreeCamera {
  37607. /**
  37608. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37609. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37610. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37611. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37612. * @param name Define the name of the camera in the scene
  37613. * @param position Define the start position of the camera in the scene
  37614. * @param scene Define the scene the camera belongs to
  37615. */
  37616. constructor(name: string, position: Vector3, scene: Scene);
  37617. /**
  37618. * Gets the current object class name.
  37619. * @return the class name
  37620. */
  37621. getClassName(): string;
  37622. }
  37623. }
  37624. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37625. import { Matrix } from "babylonjs/Maths/math";
  37626. /**
  37627. * This represents all the required metrics to create a VR camera.
  37628. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37629. */
  37630. export class VRCameraMetrics {
  37631. /**
  37632. * Define the horizontal resolution off the screen.
  37633. */
  37634. hResolution: number;
  37635. /**
  37636. * Define the vertical resolution off the screen.
  37637. */
  37638. vResolution: number;
  37639. /**
  37640. * Define the horizontal screen size.
  37641. */
  37642. hScreenSize: number;
  37643. /**
  37644. * Define the vertical screen size.
  37645. */
  37646. vScreenSize: number;
  37647. /**
  37648. * Define the vertical screen center position.
  37649. */
  37650. vScreenCenter: number;
  37651. /**
  37652. * Define the distance of the eyes to the screen.
  37653. */
  37654. eyeToScreenDistance: number;
  37655. /**
  37656. * Define the distance between both lenses
  37657. */
  37658. lensSeparationDistance: number;
  37659. /**
  37660. * Define the distance between both viewer's eyes.
  37661. */
  37662. interpupillaryDistance: number;
  37663. /**
  37664. * Define the distortion factor of the VR postprocess.
  37665. * Please, touch with care.
  37666. */
  37667. distortionK: number[];
  37668. /**
  37669. * Define the chromatic aberration correction factors for the VR post process.
  37670. */
  37671. chromaAbCorrection: number[];
  37672. /**
  37673. * Define the scale factor of the post process.
  37674. * The smaller the better but the slower.
  37675. */
  37676. postProcessScaleFactor: number;
  37677. /**
  37678. * Define an offset for the lens center.
  37679. */
  37680. lensCenterOffset: number;
  37681. /**
  37682. * Define if the current vr camera should compensate the distortion of the lense or not.
  37683. */
  37684. compensateDistortion: boolean;
  37685. /**
  37686. * Gets the rendering aspect ratio based on the provided resolutions.
  37687. */
  37688. readonly aspectRatio: number;
  37689. /**
  37690. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37691. */
  37692. readonly aspectRatioFov: number;
  37693. /**
  37694. * @hidden
  37695. */
  37696. readonly leftHMatrix: Matrix;
  37697. /**
  37698. * @hidden
  37699. */
  37700. readonly rightHMatrix: Matrix;
  37701. /**
  37702. * @hidden
  37703. */
  37704. readonly leftPreViewMatrix: Matrix;
  37705. /**
  37706. * @hidden
  37707. */
  37708. readonly rightPreViewMatrix: Matrix;
  37709. /**
  37710. * Get the default VRMetrics based on the most generic setup.
  37711. * @returns the default vr metrics
  37712. */
  37713. static GetDefault(): VRCameraMetrics;
  37714. }
  37715. }
  37716. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37717. /** @hidden */
  37718. export var vrDistortionCorrectionPixelShader: {
  37719. name: string;
  37720. shader: string;
  37721. };
  37722. }
  37723. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37724. import { Camera } from "babylonjs/Cameras/camera";
  37725. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37726. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37727. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37728. /**
  37729. * VRDistortionCorrectionPostProcess used for mobile VR
  37730. */
  37731. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37732. private _isRightEye;
  37733. private _distortionFactors;
  37734. private _postProcessScaleFactor;
  37735. private _lensCenterOffset;
  37736. private _scaleIn;
  37737. private _scaleFactor;
  37738. private _lensCenter;
  37739. /**
  37740. * Initializes the VRDistortionCorrectionPostProcess
  37741. * @param name The name of the effect.
  37742. * @param camera The camera to apply the render pass to.
  37743. * @param isRightEye If this is for the right eye distortion
  37744. * @param vrMetrics All the required metrics for the VR camera
  37745. */
  37746. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37747. }
  37748. }
  37749. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37750. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37751. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37752. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37753. import { Scene } from "babylonjs/scene";
  37754. import { Vector3 } from "babylonjs/Maths/math";
  37755. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37756. import "babylonjs/Cameras/RigModes/vrRigMode";
  37757. /**
  37758. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37759. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37760. */
  37761. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37762. /**
  37763. * Creates a new VRDeviceOrientationArcRotateCamera
  37764. * @param name defines camera name
  37765. * @param alpha defines the camera rotation along the logitudinal axis
  37766. * @param beta defines the camera rotation along the latitudinal axis
  37767. * @param radius defines the camera distance from its target
  37768. * @param target defines the camera target
  37769. * @param scene defines the scene the camera belongs to
  37770. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37771. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37772. */
  37773. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37774. /**
  37775. * Gets camera class name
  37776. * @returns VRDeviceOrientationArcRotateCamera
  37777. */
  37778. getClassName(): string;
  37779. }
  37780. }
  37781. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37782. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37783. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37784. import { Scene } from "babylonjs/scene";
  37785. import { Vector3 } from "babylonjs/Maths/math";
  37786. import "babylonjs/Cameras/RigModes/vrRigMode";
  37787. /**
  37788. * Camera used to simulate VR rendering (based on FreeCamera)
  37789. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37790. */
  37791. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37792. /**
  37793. * Creates a new VRDeviceOrientationFreeCamera
  37794. * @param name defines camera name
  37795. * @param position defines the start position of the camera
  37796. * @param scene defines the scene the camera belongs to
  37797. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37798. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37799. */
  37800. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37801. /**
  37802. * Gets camera class name
  37803. * @returns VRDeviceOrientationFreeCamera
  37804. */
  37805. getClassName(): string;
  37806. }
  37807. }
  37808. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37809. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37810. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37811. import { Scene } from "babylonjs/scene";
  37812. import { Vector3 } from "babylonjs/Maths/math";
  37813. /**
  37814. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37815. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37816. */
  37817. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37818. /**
  37819. * Creates a new VRDeviceOrientationGamepadCamera
  37820. * @param name defines camera name
  37821. * @param position defines the start position of the camera
  37822. * @param scene defines the scene the camera belongs to
  37823. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37824. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37825. */
  37826. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37827. /**
  37828. * Gets camera class name
  37829. * @returns VRDeviceOrientationGamepadCamera
  37830. */
  37831. getClassName(): string;
  37832. }
  37833. }
  37834. declare module "babylonjs/Gamepads/xboxGamepad" {
  37835. import { Observable } from "babylonjs/Misc/observable";
  37836. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37837. /**
  37838. * Defines supported buttons for XBox360 compatible gamepads
  37839. */
  37840. export enum Xbox360Button {
  37841. /** A */
  37842. A = 0,
  37843. /** B */
  37844. B = 1,
  37845. /** X */
  37846. X = 2,
  37847. /** Y */
  37848. Y = 3,
  37849. /** Start */
  37850. Start = 4,
  37851. /** Back */
  37852. Back = 5,
  37853. /** Left button */
  37854. LB = 6,
  37855. /** Right button */
  37856. RB = 7,
  37857. /** Left stick */
  37858. LeftStick = 8,
  37859. /** Right stick */
  37860. RightStick = 9
  37861. }
  37862. /** Defines values for XBox360 DPad */
  37863. export enum Xbox360Dpad {
  37864. /** Up */
  37865. Up = 0,
  37866. /** Down */
  37867. Down = 1,
  37868. /** Left */
  37869. Left = 2,
  37870. /** Right */
  37871. Right = 3
  37872. }
  37873. /**
  37874. * Defines a XBox360 gamepad
  37875. */
  37876. export class Xbox360Pad extends Gamepad {
  37877. private _leftTrigger;
  37878. private _rightTrigger;
  37879. private _onlefttriggerchanged;
  37880. private _onrighttriggerchanged;
  37881. private _onbuttondown;
  37882. private _onbuttonup;
  37883. private _ondpaddown;
  37884. private _ondpadup;
  37885. /** Observable raised when a button is pressed */
  37886. onButtonDownObservable: Observable<Xbox360Button>;
  37887. /** Observable raised when a button is released */
  37888. onButtonUpObservable: Observable<Xbox360Button>;
  37889. /** Observable raised when a pad is pressed */
  37890. onPadDownObservable: Observable<Xbox360Dpad>;
  37891. /** Observable raised when a pad is released */
  37892. onPadUpObservable: Observable<Xbox360Dpad>;
  37893. private _buttonA;
  37894. private _buttonB;
  37895. private _buttonX;
  37896. private _buttonY;
  37897. private _buttonBack;
  37898. private _buttonStart;
  37899. private _buttonLB;
  37900. private _buttonRB;
  37901. private _buttonLeftStick;
  37902. private _buttonRightStick;
  37903. private _dPadUp;
  37904. private _dPadDown;
  37905. private _dPadLeft;
  37906. private _dPadRight;
  37907. private _isXboxOnePad;
  37908. /**
  37909. * Creates a new XBox360 gamepad object
  37910. * @param id defines the id of this gamepad
  37911. * @param index defines its index
  37912. * @param gamepad defines the internal HTML gamepad object
  37913. * @param xboxOne defines if it is a XBox One gamepad
  37914. */
  37915. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37916. /**
  37917. * Defines the callback to call when left trigger is pressed
  37918. * @param callback defines the callback to use
  37919. */
  37920. onlefttriggerchanged(callback: (value: number) => void): void;
  37921. /**
  37922. * Defines the callback to call when right trigger is pressed
  37923. * @param callback defines the callback to use
  37924. */
  37925. onrighttriggerchanged(callback: (value: number) => void): void;
  37926. /**
  37927. * Gets the left trigger value
  37928. */
  37929. /**
  37930. * Sets the left trigger value
  37931. */
  37932. leftTrigger: number;
  37933. /**
  37934. * Gets the right trigger value
  37935. */
  37936. /**
  37937. * Sets the right trigger value
  37938. */
  37939. rightTrigger: number;
  37940. /**
  37941. * Defines the callback to call when a button is pressed
  37942. * @param callback defines the callback to use
  37943. */
  37944. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37945. /**
  37946. * Defines the callback to call when a button is released
  37947. * @param callback defines the callback to use
  37948. */
  37949. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37950. /**
  37951. * Defines the callback to call when a pad is pressed
  37952. * @param callback defines the callback to use
  37953. */
  37954. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37955. /**
  37956. * Defines the callback to call when a pad is released
  37957. * @param callback defines the callback to use
  37958. */
  37959. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37960. private _setButtonValue;
  37961. private _setDPadValue;
  37962. /**
  37963. * Gets the value of the `A` button
  37964. */
  37965. /**
  37966. * Sets the value of the `A` button
  37967. */
  37968. buttonA: number;
  37969. /**
  37970. * Gets the value of the `B` button
  37971. */
  37972. /**
  37973. * Sets the value of the `B` button
  37974. */
  37975. buttonB: number;
  37976. /**
  37977. * Gets the value of the `X` button
  37978. */
  37979. /**
  37980. * Sets the value of the `X` button
  37981. */
  37982. buttonX: number;
  37983. /**
  37984. * Gets the value of the `Y` button
  37985. */
  37986. /**
  37987. * Sets the value of the `Y` button
  37988. */
  37989. buttonY: number;
  37990. /**
  37991. * Gets the value of the `Start` button
  37992. */
  37993. /**
  37994. * Sets the value of the `Start` button
  37995. */
  37996. buttonStart: number;
  37997. /**
  37998. * Gets the value of the `Back` button
  37999. */
  38000. /**
  38001. * Sets the value of the `Back` button
  38002. */
  38003. buttonBack: number;
  38004. /**
  38005. * Gets the value of the `Left` button
  38006. */
  38007. /**
  38008. * Sets the value of the `Left` button
  38009. */
  38010. buttonLB: number;
  38011. /**
  38012. * Gets the value of the `Right` button
  38013. */
  38014. /**
  38015. * Sets the value of the `Right` button
  38016. */
  38017. buttonRB: number;
  38018. /**
  38019. * Gets the value of the Left joystick
  38020. */
  38021. /**
  38022. * Sets the value of the Left joystick
  38023. */
  38024. buttonLeftStick: number;
  38025. /**
  38026. * Gets the value of the Right joystick
  38027. */
  38028. /**
  38029. * Sets the value of the Right joystick
  38030. */
  38031. buttonRightStick: number;
  38032. /**
  38033. * Gets the value of D-pad up
  38034. */
  38035. /**
  38036. * Sets the value of D-pad up
  38037. */
  38038. dPadUp: number;
  38039. /**
  38040. * Gets the value of D-pad down
  38041. */
  38042. /**
  38043. * Sets the value of D-pad down
  38044. */
  38045. dPadDown: number;
  38046. /**
  38047. * Gets the value of D-pad left
  38048. */
  38049. /**
  38050. * Sets the value of D-pad left
  38051. */
  38052. dPadLeft: number;
  38053. /**
  38054. * Gets the value of D-pad right
  38055. */
  38056. /**
  38057. * Sets the value of D-pad right
  38058. */
  38059. dPadRight: number;
  38060. /**
  38061. * Force the gamepad to synchronize with device values
  38062. */
  38063. update(): void;
  38064. /**
  38065. * Disposes the gamepad
  38066. */
  38067. dispose(): void;
  38068. }
  38069. }
  38070. declare module "babylonjs/Materials/pushMaterial" {
  38071. import { Nullable } from "babylonjs/types";
  38072. import { Scene } from "babylonjs/scene";
  38073. import { Matrix } from "babylonjs/Maths/math";
  38074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38075. import { Mesh } from "babylonjs/Meshes/mesh";
  38076. import { Material } from "babylonjs/Materials/material";
  38077. import { Effect } from "babylonjs/Materials/effect";
  38078. /**
  38079. * Base class of materials working in push mode in babylon JS
  38080. * @hidden
  38081. */
  38082. export class PushMaterial extends Material {
  38083. protected _activeEffect: Effect;
  38084. protected _normalMatrix: Matrix;
  38085. /**
  38086. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38087. * This means that the material can keep using a previous shader while a new one is being compiled.
  38088. * This is mostly used when shader parallel compilation is supported (true by default)
  38089. */
  38090. allowShaderHotSwapping: boolean;
  38091. constructor(name: string, scene: Scene);
  38092. getEffect(): Effect;
  38093. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38094. /**
  38095. * Binds the given world matrix to the active effect
  38096. *
  38097. * @param world the matrix to bind
  38098. */
  38099. bindOnlyWorldMatrix(world: Matrix): void;
  38100. /**
  38101. * Binds the given normal matrix to the active effect
  38102. *
  38103. * @param normalMatrix the matrix to bind
  38104. */
  38105. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38106. bind(world: Matrix, mesh?: Mesh): void;
  38107. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38108. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38109. }
  38110. }
  38111. declare module "babylonjs/Materials/materialFlags" {
  38112. /**
  38113. * This groups all the flags used to control the materials channel.
  38114. */
  38115. export class MaterialFlags {
  38116. private static _DiffuseTextureEnabled;
  38117. /**
  38118. * Are diffuse textures enabled in the application.
  38119. */
  38120. static DiffuseTextureEnabled: boolean;
  38121. private static _AmbientTextureEnabled;
  38122. /**
  38123. * Are ambient textures enabled in the application.
  38124. */
  38125. static AmbientTextureEnabled: boolean;
  38126. private static _OpacityTextureEnabled;
  38127. /**
  38128. * Are opacity textures enabled in the application.
  38129. */
  38130. static OpacityTextureEnabled: boolean;
  38131. private static _ReflectionTextureEnabled;
  38132. /**
  38133. * Are reflection textures enabled in the application.
  38134. */
  38135. static ReflectionTextureEnabled: boolean;
  38136. private static _EmissiveTextureEnabled;
  38137. /**
  38138. * Are emissive textures enabled in the application.
  38139. */
  38140. static EmissiveTextureEnabled: boolean;
  38141. private static _SpecularTextureEnabled;
  38142. /**
  38143. * Are specular textures enabled in the application.
  38144. */
  38145. static SpecularTextureEnabled: boolean;
  38146. private static _BumpTextureEnabled;
  38147. /**
  38148. * Are bump textures enabled in the application.
  38149. */
  38150. static BumpTextureEnabled: boolean;
  38151. private static _LightmapTextureEnabled;
  38152. /**
  38153. * Are lightmap textures enabled in the application.
  38154. */
  38155. static LightmapTextureEnabled: boolean;
  38156. private static _RefractionTextureEnabled;
  38157. /**
  38158. * Are refraction textures enabled in the application.
  38159. */
  38160. static RefractionTextureEnabled: boolean;
  38161. private static _ColorGradingTextureEnabled;
  38162. /**
  38163. * Are color grading textures enabled in the application.
  38164. */
  38165. static ColorGradingTextureEnabled: boolean;
  38166. private static _FresnelEnabled;
  38167. /**
  38168. * Are fresnels enabled in the application.
  38169. */
  38170. static FresnelEnabled: boolean;
  38171. }
  38172. }
  38173. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38174. /** @hidden */
  38175. export var defaultFragmentDeclaration: {
  38176. name: string;
  38177. shader: string;
  38178. };
  38179. }
  38180. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38181. /** @hidden */
  38182. export var defaultUboDeclaration: {
  38183. name: string;
  38184. shader: string;
  38185. };
  38186. }
  38187. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38188. /** @hidden */
  38189. export var lightFragmentDeclaration: {
  38190. name: string;
  38191. shader: string;
  38192. };
  38193. }
  38194. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38195. /** @hidden */
  38196. export var lightUboDeclaration: {
  38197. name: string;
  38198. shader: string;
  38199. };
  38200. }
  38201. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38202. /** @hidden */
  38203. export var lightsFragmentFunctions: {
  38204. name: string;
  38205. shader: string;
  38206. };
  38207. }
  38208. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38209. /** @hidden */
  38210. export var shadowsFragmentFunctions: {
  38211. name: string;
  38212. shader: string;
  38213. };
  38214. }
  38215. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38216. /** @hidden */
  38217. export var fresnelFunction: {
  38218. name: string;
  38219. shader: string;
  38220. };
  38221. }
  38222. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38223. /** @hidden */
  38224. export var reflectionFunction: {
  38225. name: string;
  38226. shader: string;
  38227. };
  38228. }
  38229. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38230. /** @hidden */
  38231. export var bumpFragmentFunctions: {
  38232. name: string;
  38233. shader: string;
  38234. };
  38235. }
  38236. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38237. /** @hidden */
  38238. export var logDepthDeclaration: {
  38239. name: string;
  38240. shader: string;
  38241. };
  38242. }
  38243. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38244. /** @hidden */
  38245. export var bumpFragment: {
  38246. name: string;
  38247. shader: string;
  38248. };
  38249. }
  38250. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38251. /** @hidden */
  38252. export var depthPrePass: {
  38253. name: string;
  38254. shader: string;
  38255. };
  38256. }
  38257. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38258. /** @hidden */
  38259. export var lightFragment: {
  38260. name: string;
  38261. shader: string;
  38262. };
  38263. }
  38264. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38265. /** @hidden */
  38266. export var logDepthFragment: {
  38267. name: string;
  38268. shader: string;
  38269. };
  38270. }
  38271. declare module "babylonjs/Shaders/default.fragment" {
  38272. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38273. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38274. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38275. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38276. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38277. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38278. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38279. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38280. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38281. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38282. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38283. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38284. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38285. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38286. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38287. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38288. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38289. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38290. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38291. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38292. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38293. /** @hidden */
  38294. export var defaultPixelShader: {
  38295. name: string;
  38296. shader: string;
  38297. };
  38298. }
  38299. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38300. /** @hidden */
  38301. export var defaultVertexDeclaration: {
  38302. name: string;
  38303. shader: string;
  38304. };
  38305. }
  38306. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38307. /** @hidden */
  38308. export var bumpVertexDeclaration: {
  38309. name: string;
  38310. shader: string;
  38311. };
  38312. }
  38313. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38314. /** @hidden */
  38315. export var bumpVertex: {
  38316. name: string;
  38317. shader: string;
  38318. };
  38319. }
  38320. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38321. /** @hidden */
  38322. export var fogVertex: {
  38323. name: string;
  38324. shader: string;
  38325. };
  38326. }
  38327. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38328. /** @hidden */
  38329. export var shadowsVertex: {
  38330. name: string;
  38331. shader: string;
  38332. };
  38333. }
  38334. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38335. /** @hidden */
  38336. export var pointCloudVertex: {
  38337. name: string;
  38338. shader: string;
  38339. };
  38340. }
  38341. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38342. /** @hidden */
  38343. export var logDepthVertex: {
  38344. name: string;
  38345. shader: string;
  38346. };
  38347. }
  38348. declare module "babylonjs/Shaders/default.vertex" {
  38349. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38350. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38351. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38352. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38353. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38354. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38355. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38356. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38357. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38358. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38361. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38363. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38364. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38365. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38366. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38367. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38368. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38369. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38370. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38371. /** @hidden */
  38372. export var defaultVertexShader: {
  38373. name: string;
  38374. shader: string;
  38375. };
  38376. }
  38377. declare module "babylonjs/Materials/standardMaterial" {
  38378. import { SmartArray } from "babylonjs/Misc/smartArray";
  38379. import { IAnimatable } from "babylonjs/Misc/tools";
  38380. import { Nullable } from "babylonjs/types";
  38381. import { Scene } from "babylonjs/scene";
  38382. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38385. import { Mesh } from "babylonjs/Meshes/mesh";
  38386. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38387. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38388. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38389. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38390. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38393. import "babylonjs/Shaders/default.fragment";
  38394. import "babylonjs/Shaders/default.vertex";
  38395. /** @hidden */
  38396. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38397. MAINUV1: boolean;
  38398. MAINUV2: boolean;
  38399. DIFFUSE: boolean;
  38400. DIFFUSEDIRECTUV: number;
  38401. AMBIENT: boolean;
  38402. AMBIENTDIRECTUV: number;
  38403. OPACITY: boolean;
  38404. OPACITYDIRECTUV: number;
  38405. OPACITYRGB: boolean;
  38406. REFLECTION: boolean;
  38407. EMISSIVE: boolean;
  38408. EMISSIVEDIRECTUV: number;
  38409. SPECULAR: boolean;
  38410. SPECULARDIRECTUV: number;
  38411. BUMP: boolean;
  38412. BUMPDIRECTUV: number;
  38413. PARALLAX: boolean;
  38414. PARALLAXOCCLUSION: boolean;
  38415. SPECULAROVERALPHA: boolean;
  38416. CLIPPLANE: boolean;
  38417. CLIPPLANE2: boolean;
  38418. CLIPPLANE3: boolean;
  38419. CLIPPLANE4: boolean;
  38420. ALPHATEST: boolean;
  38421. DEPTHPREPASS: boolean;
  38422. ALPHAFROMDIFFUSE: boolean;
  38423. POINTSIZE: boolean;
  38424. FOG: boolean;
  38425. SPECULARTERM: boolean;
  38426. DIFFUSEFRESNEL: boolean;
  38427. OPACITYFRESNEL: boolean;
  38428. REFLECTIONFRESNEL: boolean;
  38429. REFRACTIONFRESNEL: boolean;
  38430. EMISSIVEFRESNEL: boolean;
  38431. FRESNEL: boolean;
  38432. NORMAL: boolean;
  38433. UV1: boolean;
  38434. UV2: boolean;
  38435. VERTEXCOLOR: boolean;
  38436. VERTEXALPHA: boolean;
  38437. NUM_BONE_INFLUENCERS: number;
  38438. BonesPerMesh: number;
  38439. BONETEXTURE: boolean;
  38440. INSTANCES: boolean;
  38441. GLOSSINESS: boolean;
  38442. ROUGHNESS: boolean;
  38443. EMISSIVEASILLUMINATION: boolean;
  38444. LINKEMISSIVEWITHDIFFUSE: boolean;
  38445. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38446. LIGHTMAP: boolean;
  38447. LIGHTMAPDIRECTUV: number;
  38448. OBJECTSPACE_NORMALMAP: boolean;
  38449. USELIGHTMAPASSHADOWMAP: boolean;
  38450. REFLECTIONMAP_3D: boolean;
  38451. REFLECTIONMAP_SPHERICAL: boolean;
  38452. REFLECTIONMAP_PLANAR: boolean;
  38453. REFLECTIONMAP_CUBIC: boolean;
  38454. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38455. REFLECTIONMAP_PROJECTION: boolean;
  38456. REFLECTIONMAP_SKYBOX: boolean;
  38457. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38458. REFLECTIONMAP_EXPLICIT: boolean;
  38459. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38460. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38461. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38462. INVERTCUBICMAP: boolean;
  38463. LOGARITHMICDEPTH: boolean;
  38464. REFRACTION: boolean;
  38465. REFRACTIONMAP_3D: boolean;
  38466. REFLECTIONOVERALPHA: boolean;
  38467. TWOSIDEDLIGHTING: boolean;
  38468. SHADOWFLOAT: boolean;
  38469. MORPHTARGETS: boolean;
  38470. MORPHTARGETS_NORMAL: boolean;
  38471. MORPHTARGETS_TANGENT: boolean;
  38472. NUM_MORPH_INFLUENCERS: number;
  38473. NONUNIFORMSCALING: boolean;
  38474. PREMULTIPLYALPHA: boolean;
  38475. IMAGEPROCESSING: boolean;
  38476. VIGNETTE: boolean;
  38477. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38478. VIGNETTEBLENDMODEOPAQUE: boolean;
  38479. TONEMAPPING: boolean;
  38480. TONEMAPPING_ACES: boolean;
  38481. CONTRAST: boolean;
  38482. COLORCURVES: boolean;
  38483. COLORGRADING: boolean;
  38484. COLORGRADING3D: boolean;
  38485. SAMPLER3DGREENDEPTH: boolean;
  38486. SAMPLER3DBGRMAP: boolean;
  38487. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38488. /**
  38489. * If the reflection texture on this material is in linear color space
  38490. * @hidden
  38491. */
  38492. IS_REFLECTION_LINEAR: boolean;
  38493. /**
  38494. * If the refraction texture on this material is in linear color space
  38495. * @hidden
  38496. */
  38497. IS_REFRACTION_LINEAR: boolean;
  38498. EXPOSURE: boolean;
  38499. constructor();
  38500. setReflectionMode(modeToEnable: string): void;
  38501. }
  38502. /**
  38503. * This is the default material used in Babylon. It is the best trade off between quality
  38504. * and performances.
  38505. * @see http://doc.babylonjs.com/babylon101/materials
  38506. */
  38507. export class StandardMaterial extends PushMaterial {
  38508. private _diffuseTexture;
  38509. /**
  38510. * The basic texture of the material as viewed under a light.
  38511. */
  38512. diffuseTexture: Nullable<BaseTexture>;
  38513. private _ambientTexture;
  38514. /**
  38515. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38516. */
  38517. ambientTexture: Nullable<BaseTexture>;
  38518. private _opacityTexture;
  38519. /**
  38520. * Define the transparency of the material from a texture.
  38521. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38522. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38523. */
  38524. opacityTexture: Nullable<BaseTexture>;
  38525. private _reflectionTexture;
  38526. /**
  38527. * Define the texture used to display the reflection.
  38528. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38529. */
  38530. reflectionTexture: Nullable<BaseTexture>;
  38531. private _emissiveTexture;
  38532. /**
  38533. * Define texture of the material as if self lit.
  38534. * This will be mixed in the final result even in the absence of light.
  38535. */
  38536. emissiveTexture: Nullable<BaseTexture>;
  38537. private _specularTexture;
  38538. /**
  38539. * Define how the color and intensity of the highlight given by the light in the material.
  38540. */
  38541. specularTexture: Nullable<BaseTexture>;
  38542. private _bumpTexture;
  38543. /**
  38544. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38545. * 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.
  38546. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38547. */
  38548. bumpTexture: Nullable<BaseTexture>;
  38549. private _lightmapTexture;
  38550. /**
  38551. * Complex lighting can be computationally expensive to compute at runtime.
  38552. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38553. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38554. */
  38555. lightmapTexture: Nullable<BaseTexture>;
  38556. private _refractionTexture;
  38557. /**
  38558. * Define the texture used to display the refraction.
  38559. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38560. */
  38561. refractionTexture: Nullable<BaseTexture>;
  38562. /**
  38563. * The color of the material lit by the environmental background lighting.
  38564. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38565. */
  38566. ambientColor: Color3;
  38567. /**
  38568. * The basic color of the material as viewed under a light.
  38569. */
  38570. diffuseColor: Color3;
  38571. /**
  38572. * Define how the color and intensity of the highlight given by the light in the material.
  38573. */
  38574. specularColor: Color3;
  38575. /**
  38576. * Define the color of the material as if self lit.
  38577. * This will be mixed in the final result even in the absence of light.
  38578. */
  38579. emissiveColor: Color3;
  38580. /**
  38581. * Defines how sharp are the highlights in the material.
  38582. * The bigger the value the sharper giving a more glossy feeling to the result.
  38583. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38584. */
  38585. specularPower: number;
  38586. private _useAlphaFromDiffuseTexture;
  38587. /**
  38588. * Does the transparency come from the diffuse texture alpha channel.
  38589. */
  38590. useAlphaFromDiffuseTexture: boolean;
  38591. private _useEmissiveAsIllumination;
  38592. /**
  38593. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38594. */
  38595. useEmissiveAsIllumination: boolean;
  38596. private _linkEmissiveWithDiffuse;
  38597. /**
  38598. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38599. * the emissive level when the final color is close to one.
  38600. */
  38601. linkEmissiveWithDiffuse: boolean;
  38602. private _useSpecularOverAlpha;
  38603. /**
  38604. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38605. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38606. */
  38607. useSpecularOverAlpha: boolean;
  38608. private _useReflectionOverAlpha;
  38609. /**
  38610. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38611. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38612. */
  38613. useReflectionOverAlpha: boolean;
  38614. private _disableLighting;
  38615. /**
  38616. * Does lights from the scene impacts this material.
  38617. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38618. */
  38619. disableLighting: boolean;
  38620. private _useObjectSpaceNormalMap;
  38621. /**
  38622. * Allows using an object space normal map (instead of tangent space).
  38623. */
  38624. useObjectSpaceNormalMap: boolean;
  38625. private _useParallax;
  38626. /**
  38627. * Is parallax enabled or not.
  38628. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38629. */
  38630. useParallax: boolean;
  38631. private _useParallaxOcclusion;
  38632. /**
  38633. * Is parallax occlusion enabled or not.
  38634. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38635. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38636. */
  38637. useParallaxOcclusion: boolean;
  38638. /**
  38639. * 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.
  38640. */
  38641. parallaxScaleBias: number;
  38642. private _roughness;
  38643. /**
  38644. * Helps to define how blurry the reflections should appears in the material.
  38645. */
  38646. roughness: number;
  38647. /**
  38648. * In case of refraction, define the value of the indice of refraction.
  38649. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38650. */
  38651. indexOfRefraction: number;
  38652. /**
  38653. * Invert the refraction texture alongside the y axis.
  38654. * It can be useful with procedural textures or probe for instance.
  38655. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38656. */
  38657. invertRefractionY: boolean;
  38658. /**
  38659. * Defines the alpha limits in alpha test mode.
  38660. */
  38661. alphaCutOff: number;
  38662. private _useLightmapAsShadowmap;
  38663. /**
  38664. * In case of light mapping, define whether the map contains light or shadow informations.
  38665. */
  38666. useLightmapAsShadowmap: boolean;
  38667. private _diffuseFresnelParameters;
  38668. /**
  38669. * Define the diffuse fresnel parameters of the material.
  38670. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38671. */
  38672. diffuseFresnelParameters: FresnelParameters;
  38673. private _opacityFresnelParameters;
  38674. /**
  38675. * Define the opacity fresnel parameters of the material.
  38676. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38677. */
  38678. opacityFresnelParameters: FresnelParameters;
  38679. private _reflectionFresnelParameters;
  38680. /**
  38681. * Define the reflection fresnel parameters of the material.
  38682. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38683. */
  38684. reflectionFresnelParameters: FresnelParameters;
  38685. private _refractionFresnelParameters;
  38686. /**
  38687. * Define the refraction fresnel parameters of the material.
  38688. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38689. */
  38690. refractionFresnelParameters: FresnelParameters;
  38691. private _emissiveFresnelParameters;
  38692. /**
  38693. * Define the emissive fresnel parameters of the material.
  38694. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38695. */
  38696. emissiveFresnelParameters: FresnelParameters;
  38697. private _useReflectionFresnelFromSpecular;
  38698. /**
  38699. * If true automatically deducts the fresnels values from the material specularity.
  38700. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38701. */
  38702. useReflectionFresnelFromSpecular: boolean;
  38703. private _useGlossinessFromSpecularMapAlpha;
  38704. /**
  38705. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38706. */
  38707. useGlossinessFromSpecularMapAlpha: boolean;
  38708. private _maxSimultaneousLights;
  38709. /**
  38710. * Defines the maximum number of lights that can be used in the material
  38711. */
  38712. maxSimultaneousLights: number;
  38713. private _invertNormalMapX;
  38714. /**
  38715. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38716. */
  38717. invertNormalMapX: boolean;
  38718. private _invertNormalMapY;
  38719. /**
  38720. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38721. */
  38722. invertNormalMapY: boolean;
  38723. private _twoSidedLighting;
  38724. /**
  38725. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38726. */
  38727. twoSidedLighting: boolean;
  38728. /**
  38729. * Default configuration related to image processing available in the standard Material.
  38730. */
  38731. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38732. /**
  38733. * Gets the image processing configuration used either in this material.
  38734. */
  38735. /**
  38736. * Sets the Default image processing configuration used either in the this material.
  38737. *
  38738. * If sets to null, the scene one is in use.
  38739. */
  38740. imageProcessingConfiguration: ImageProcessingConfiguration;
  38741. /**
  38742. * Keep track of the image processing observer to allow dispose and replace.
  38743. */
  38744. private _imageProcessingObserver;
  38745. /**
  38746. * Attaches a new image processing configuration to the Standard Material.
  38747. * @param configuration
  38748. */
  38749. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38750. /**
  38751. * Gets wether the color curves effect is enabled.
  38752. */
  38753. /**
  38754. * Sets wether the color curves effect is enabled.
  38755. */
  38756. cameraColorCurvesEnabled: boolean;
  38757. /**
  38758. * Gets wether the color grading effect is enabled.
  38759. */
  38760. /**
  38761. * Gets wether the color grading effect is enabled.
  38762. */
  38763. cameraColorGradingEnabled: boolean;
  38764. /**
  38765. * Gets wether tonemapping is enabled or not.
  38766. */
  38767. /**
  38768. * Sets wether tonemapping is enabled or not
  38769. */
  38770. cameraToneMappingEnabled: boolean;
  38771. /**
  38772. * The camera exposure used on this material.
  38773. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38774. * This corresponds to a photographic exposure.
  38775. */
  38776. /**
  38777. * The camera exposure used on this material.
  38778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38779. * This corresponds to a photographic exposure.
  38780. */
  38781. cameraExposure: number;
  38782. /**
  38783. * Gets The camera contrast used on this material.
  38784. */
  38785. /**
  38786. * Sets The camera contrast used on this material.
  38787. */
  38788. cameraContrast: number;
  38789. /**
  38790. * Gets the Color Grading 2D Lookup Texture.
  38791. */
  38792. /**
  38793. * Sets the Color Grading 2D Lookup Texture.
  38794. */
  38795. cameraColorGradingTexture: Nullable<BaseTexture>;
  38796. /**
  38797. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38798. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38799. * 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;
  38800. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38801. */
  38802. /**
  38803. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38804. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38805. * 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;
  38806. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38807. */
  38808. cameraColorCurves: Nullable<ColorCurves>;
  38809. /**
  38810. * Custom callback helping to override the default shader used in the material.
  38811. */
  38812. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38813. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38814. protected _worldViewProjectionMatrix: Matrix;
  38815. protected _globalAmbientColor: Color3;
  38816. protected _useLogarithmicDepth: boolean;
  38817. /**
  38818. * Instantiates a new standard material.
  38819. * This is the default material used in Babylon. It is the best trade off between quality
  38820. * and performances.
  38821. * @see http://doc.babylonjs.com/babylon101/materials
  38822. * @param name Define the name of the material in the scene
  38823. * @param scene Define the scene the material belong to
  38824. */
  38825. constructor(name: string, scene: Scene);
  38826. /**
  38827. * Gets a boolean indicating that current material needs to register RTT
  38828. */
  38829. readonly hasRenderTargetTextures: boolean;
  38830. /**
  38831. * Gets the current class name of the material e.g. "StandardMaterial"
  38832. * Mainly use in serialization.
  38833. * @returns the class name
  38834. */
  38835. getClassName(): string;
  38836. /**
  38837. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38838. * You can try switching to logarithmic depth.
  38839. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38840. */
  38841. useLogarithmicDepth: boolean;
  38842. /**
  38843. * Specifies if the material will require alpha blending
  38844. * @returns a boolean specifying if alpha blending is needed
  38845. */
  38846. needAlphaBlending(): boolean;
  38847. /**
  38848. * Specifies if this material should be rendered in alpha test mode
  38849. * @returns a boolean specifying if an alpha test is needed.
  38850. */
  38851. needAlphaTesting(): boolean;
  38852. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38853. /**
  38854. * Get the texture used for alpha test purpose.
  38855. * @returns the diffuse texture in case of the standard material.
  38856. */
  38857. getAlphaTestTexture(): Nullable<BaseTexture>;
  38858. /**
  38859. * Get if the submesh is ready to be used and all its information available.
  38860. * Child classes can use it to update shaders
  38861. * @param mesh defines the mesh to check
  38862. * @param subMesh defines which submesh to check
  38863. * @param useInstances specifies that instances should be used
  38864. * @returns a boolean indicating that the submesh is ready or not
  38865. */
  38866. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38867. /**
  38868. * Builds the material UBO layouts.
  38869. * Used internally during the effect preparation.
  38870. */
  38871. buildUniformLayout(): void;
  38872. /**
  38873. * Unbinds the material from the mesh
  38874. */
  38875. unbind(): void;
  38876. /**
  38877. * Binds the submesh to this material by preparing the effect and shader to draw
  38878. * @param world defines the world transformation matrix
  38879. * @param mesh defines the mesh containing the submesh
  38880. * @param subMesh defines the submesh to bind the material to
  38881. */
  38882. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38883. /**
  38884. * Get the list of animatables in the material.
  38885. * @returns the list of animatables object used in the material
  38886. */
  38887. getAnimatables(): IAnimatable[];
  38888. /**
  38889. * Gets the active textures from the material
  38890. * @returns an array of textures
  38891. */
  38892. getActiveTextures(): BaseTexture[];
  38893. /**
  38894. * Specifies if the material uses a texture
  38895. * @param texture defines the texture to check against the material
  38896. * @returns a boolean specifying if the material uses the texture
  38897. */
  38898. hasTexture(texture: BaseTexture): boolean;
  38899. /**
  38900. * Disposes the material
  38901. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38902. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38903. */
  38904. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38905. /**
  38906. * Makes a duplicate of the material, and gives it a new name
  38907. * @param name defines the new name for the duplicated material
  38908. * @returns the cloned material
  38909. */
  38910. clone(name: string): StandardMaterial;
  38911. /**
  38912. * Serializes this material in a JSON representation
  38913. * @returns the serialized material object
  38914. */
  38915. serialize(): any;
  38916. /**
  38917. * Creates a standard material from parsed material data
  38918. * @param source defines the JSON representation of the material
  38919. * @param scene defines the hosting scene
  38920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38921. * @returns a new standard material
  38922. */
  38923. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38924. /**
  38925. * Are diffuse textures enabled in the application.
  38926. */
  38927. static DiffuseTextureEnabled: boolean;
  38928. /**
  38929. * Are ambient textures enabled in the application.
  38930. */
  38931. static AmbientTextureEnabled: boolean;
  38932. /**
  38933. * Are opacity textures enabled in the application.
  38934. */
  38935. static OpacityTextureEnabled: boolean;
  38936. /**
  38937. * Are reflection textures enabled in the application.
  38938. */
  38939. static ReflectionTextureEnabled: boolean;
  38940. /**
  38941. * Are emissive textures enabled in the application.
  38942. */
  38943. static EmissiveTextureEnabled: boolean;
  38944. /**
  38945. * Are specular textures enabled in the application.
  38946. */
  38947. static SpecularTextureEnabled: boolean;
  38948. /**
  38949. * Are bump textures enabled in the application.
  38950. */
  38951. static BumpTextureEnabled: boolean;
  38952. /**
  38953. * Are lightmap textures enabled in the application.
  38954. */
  38955. static LightmapTextureEnabled: boolean;
  38956. /**
  38957. * Are refraction textures enabled in the application.
  38958. */
  38959. static RefractionTextureEnabled: boolean;
  38960. /**
  38961. * Are color grading textures enabled in the application.
  38962. */
  38963. static ColorGradingTextureEnabled: boolean;
  38964. /**
  38965. * Are fresnels enabled in the application.
  38966. */
  38967. static FresnelEnabled: boolean;
  38968. }
  38969. }
  38970. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  38971. import { Scene } from "babylonjs/scene";
  38972. import { Texture } from "babylonjs/Materials/Textures/texture";
  38973. /**
  38974. * A class extending Texture allowing drawing on a texture
  38975. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38976. */
  38977. export class DynamicTexture extends Texture {
  38978. private _generateMipMaps;
  38979. private _canvas;
  38980. private _context;
  38981. private _engine;
  38982. /**
  38983. * Creates a DynamicTexture
  38984. * @param name defines the name of the texture
  38985. * @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
  38986. * @param scene defines the scene where you want the texture
  38987. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38988. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38989. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38990. */
  38991. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38992. /**
  38993. * Get the current class name of the texture useful for serialization or dynamic coding.
  38994. * @returns "DynamicTexture"
  38995. */
  38996. getClassName(): string;
  38997. /**
  38998. * Gets the current state of canRescale
  38999. */
  39000. readonly canRescale: boolean;
  39001. private _recreate;
  39002. /**
  39003. * Scales the texture
  39004. * @param ratio the scale factor to apply to both width and height
  39005. */
  39006. scale(ratio: number): void;
  39007. /**
  39008. * Resizes the texture
  39009. * @param width the new width
  39010. * @param height the new height
  39011. */
  39012. scaleTo(width: number, height: number): void;
  39013. /**
  39014. * Gets the context of the canvas used by the texture
  39015. * @returns the canvas context of the dynamic texture
  39016. */
  39017. getContext(): CanvasRenderingContext2D;
  39018. /**
  39019. * Clears the texture
  39020. */
  39021. clear(): void;
  39022. /**
  39023. * Updates the texture
  39024. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39025. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39026. */
  39027. update(invertY?: boolean, premulAlpha?: boolean): void;
  39028. /**
  39029. * Draws text onto the texture
  39030. * @param text defines the text to be drawn
  39031. * @param x defines the placement of the text from the left
  39032. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39033. * @param font defines the font to be used with font-style, font-size, font-name
  39034. * @param color defines the color used for the text
  39035. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39036. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39037. * @param update defines whether texture is immediately update (default is true)
  39038. */
  39039. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39040. /**
  39041. * Clones the texture
  39042. * @returns the clone of the texture.
  39043. */
  39044. clone(): DynamicTexture;
  39045. /**
  39046. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39047. * @returns a serialized dynamic texture object
  39048. */
  39049. serialize(): any;
  39050. /** @hidden */
  39051. _rebuild(): void;
  39052. }
  39053. }
  39054. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39055. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39056. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39057. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39058. /** @hidden */
  39059. export var imageProcessingPixelShader: {
  39060. name: string;
  39061. shader: string;
  39062. };
  39063. }
  39064. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39065. import { Nullable } from "babylonjs/types";
  39066. import { Color4 } from "babylonjs/Maths/math";
  39067. import { Camera } from "babylonjs/Cameras/camera";
  39068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39069. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39070. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39072. import { Engine } from "babylonjs/Engines/engine";
  39073. import "babylonjs/Shaders/imageProcessing.fragment";
  39074. import "babylonjs/Shaders/postprocess.vertex";
  39075. /**
  39076. * ImageProcessingPostProcess
  39077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39078. */
  39079. export class ImageProcessingPostProcess extends PostProcess {
  39080. /**
  39081. * Default configuration related to image processing available in the PBR Material.
  39082. */
  39083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39084. /**
  39085. * Gets the image processing configuration used either in this material.
  39086. */
  39087. /**
  39088. * Sets the Default image processing configuration used either in the this material.
  39089. *
  39090. * If sets to null, the scene one is in use.
  39091. */
  39092. imageProcessingConfiguration: ImageProcessingConfiguration;
  39093. /**
  39094. * Keep track of the image processing observer to allow dispose and replace.
  39095. */
  39096. private _imageProcessingObserver;
  39097. /**
  39098. * Attaches a new image processing configuration to the PBR Material.
  39099. * @param configuration
  39100. */
  39101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39102. /**
  39103. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39104. */
  39105. /**
  39106. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39107. */
  39108. colorCurves: Nullable<ColorCurves>;
  39109. /**
  39110. * Gets wether the color curves effect is enabled.
  39111. */
  39112. /**
  39113. * Sets wether the color curves effect is enabled.
  39114. */
  39115. colorCurvesEnabled: boolean;
  39116. /**
  39117. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39118. */
  39119. /**
  39120. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39121. */
  39122. colorGradingTexture: Nullable<BaseTexture>;
  39123. /**
  39124. * Gets wether the color grading effect is enabled.
  39125. */
  39126. /**
  39127. * Gets wether the color grading effect is enabled.
  39128. */
  39129. colorGradingEnabled: boolean;
  39130. /**
  39131. * Gets exposure used in the effect.
  39132. */
  39133. /**
  39134. * Sets exposure used in the effect.
  39135. */
  39136. exposure: number;
  39137. /**
  39138. * Gets wether tonemapping is enabled or not.
  39139. */
  39140. /**
  39141. * Sets wether tonemapping is enabled or not
  39142. */
  39143. toneMappingEnabled: boolean;
  39144. /**
  39145. * Gets contrast used in the effect.
  39146. */
  39147. /**
  39148. * Sets contrast used in the effect.
  39149. */
  39150. contrast: number;
  39151. /**
  39152. * Gets Vignette stretch size.
  39153. */
  39154. /**
  39155. * Sets Vignette stretch size.
  39156. */
  39157. vignetteStretch: number;
  39158. /**
  39159. * Gets Vignette centre X Offset.
  39160. */
  39161. /**
  39162. * Sets Vignette centre X Offset.
  39163. */
  39164. vignetteCentreX: number;
  39165. /**
  39166. * Gets Vignette centre Y Offset.
  39167. */
  39168. /**
  39169. * Sets Vignette centre Y Offset.
  39170. */
  39171. vignetteCentreY: number;
  39172. /**
  39173. * Gets Vignette weight or intensity of the vignette effect.
  39174. */
  39175. /**
  39176. * Sets Vignette weight or intensity of the vignette effect.
  39177. */
  39178. vignetteWeight: number;
  39179. /**
  39180. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39181. * if vignetteEnabled is set to true.
  39182. */
  39183. /**
  39184. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39185. * if vignetteEnabled is set to true.
  39186. */
  39187. vignetteColor: Color4;
  39188. /**
  39189. * Gets Camera field of view used by the Vignette effect.
  39190. */
  39191. /**
  39192. * Sets Camera field of view used by the Vignette effect.
  39193. */
  39194. vignetteCameraFov: number;
  39195. /**
  39196. * Gets the vignette blend mode allowing different kind of effect.
  39197. */
  39198. /**
  39199. * Sets the vignette blend mode allowing different kind of effect.
  39200. */
  39201. vignetteBlendMode: number;
  39202. /**
  39203. * Gets wether the vignette effect is enabled.
  39204. */
  39205. /**
  39206. * Sets wether the vignette effect is enabled.
  39207. */
  39208. vignetteEnabled: boolean;
  39209. private _fromLinearSpace;
  39210. /**
  39211. * Gets wether the input of the processing is in Gamma or Linear Space.
  39212. */
  39213. /**
  39214. * Sets wether the input of the processing is in Gamma or Linear Space.
  39215. */
  39216. fromLinearSpace: boolean;
  39217. /**
  39218. * Defines cache preventing GC.
  39219. */
  39220. private _defines;
  39221. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39222. /**
  39223. * "ImageProcessingPostProcess"
  39224. * @returns "ImageProcessingPostProcess"
  39225. */
  39226. getClassName(): string;
  39227. protected _updateParameters(): void;
  39228. dispose(camera?: Camera): void;
  39229. }
  39230. }
  39231. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39232. import { Scene } from "babylonjs/scene";
  39233. import { Color3 } from "babylonjs/Maths/math";
  39234. import { Mesh } from "babylonjs/Meshes/mesh";
  39235. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39236. /**
  39237. * Class containing static functions to help procedurally build meshes
  39238. */
  39239. export class GroundBuilder {
  39240. /**
  39241. * Creates a ground mesh
  39242. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39243. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39245. * @param name defines the name of the mesh
  39246. * @param options defines the options used to create the mesh
  39247. * @param scene defines the hosting scene
  39248. * @returns the ground mesh
  39249. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39250. */
  39251. static CreateGround(name: string, options: {
  39252. width?: number;
  39253. height?: number;
  39254. subdivisions?: number;
  39255. subdivisionsX?: number;
  39256. subdivisionsY?: number;
  39257. updatable?: boolean;
  39258. }, scene: any): Mesh;
  39259. /**
  39260. * Creates a tiled ground mesh
  39261. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39262. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39263. * * 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
  39264. * * 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
  39265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39266. * @param name defines the name of the mesh
  39267. * @param options defines the options used to create the mesh
  39268. * @param scene defines the hosting scene
  39269. * @returns the tiled ground mesh
  39270. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39271. */
  39272. static CreateTiledGround(name: string, options: {
  39273. xmin: number;
  39274. zmin: number;
  39275. xmax: number;
  39276. zmax: number;
  39277. subdivisions?: {
  39278. w: number;
  39279. h: number;
  39280. };
  39281. precision?: {
  39282. w: number;
  39283. h: number;
  39284. };
  39285. updatable?: boolean;
  39286. }, scene: Scene): Mesh;
  39287. /**
  39288. * Creates a ground mesh from a height map
  39289. * * The parameter `url` sets the URL of the height map image resource.
  39290. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39291. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39292. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39293. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39294. * * 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.
  39295. * * 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).
  39296. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39298. * @param name defines the name of the mesh
  39299. * @param url defines the url to the height map
  39300. * @param options defines the options used to create the mesh
  39301. * @param scene defines the hosting scene
  39302. * @returns the ground mesh
  39303. * @see https://doc.babylonjs.com/babylon101/height_map
  39304. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39305. */
  39306. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39307. width?: number;
  39308. height?: number;
  39309. subdivisions?: number;
  39310. minHeight?: number;
  39311. maxHeight?: number;
  39312. colorFilter?: Color3;
  39313. alphaFilter?: number;
  39314. updatable?: boolean;
  39315. onReady?: (mesh: GroundMesh) => void;
  39316. }, scene: Scene): GroundMesh;
  39317. }
  39318. }
  39319. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39320. import { Vector4 } from "babylonjs/Maths/math";
  39321. import { Mesh } from "babylonjs/Meshes/mesh";
  39322. /**
  39323. * Class containing static functions to help procedurally build meshes
  39324. */
  39325. export class TorusBuilder {
  39326. /**
  39327. * Creates a torus mesh
  39328. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39329. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39330. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39334. * @param name defines the name of the mesh
  39335. * @param options defines the options used to create the mesh
  39336. * @param scene defines the hosting scene
  39337. * @returns the torus mesh
  39338. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39339. */
  39340. static CreateTorus(name: string, options: {
  39341. diameter?: number;
  39342. thickness?: number;
  39343. tessellation?: number;
  39344. updatable?: boolean;
  39345. sideOrientation?: number;
  39346. frontUVs?: Vector4;
  39347. backUVs?: Vector4;
  39348. }, scene: any): Mesh;
  39349. }
  39350. }
  39351. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39352. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39353. import { Mesh } from "babylonjs/Meshes/mesh";
  39354. /**
  39355. * Class containing static functions to help procedurally build meshes
  39356. */
  39357. export class CylinderBuilder {
  39358. /**
  39359. * Creates a cylinder or a cone mesh
  39360. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39361. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39362. * * 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.
  39363. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39364. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39365. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39366. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39367. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39368. * * 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).
  39369. * * 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
  39370. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39371. * * 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
  39372. * * 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.
  39373. * * If `enclose` is false, a ring surface is one element.
  39374. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39375. * * 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
  39376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39379. * @param name defines the name of the mesh
  39380. * @param options defines the options used to create the mesh
  39381. * @param scene defines the hosting scene
  39382. * @returns the cylinder mesh
  39383. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39384. */
  39385. static CreateCylinder(name: string, options: {
  39386. height?: number;
  39387. diameterTop?: number;
  39388. diameterBottom?: number;
  39389. diameter?: number;
  39390. tessellation?: number;
  39391. subdivisions?: number;
  39392. arc?: number;
  39393. faceColors?: Color4[];
  39394. faceUV?: Vector4[];
  39395. updatable?: boolean;
  39396. hasRings?: boolean;
  39397. enclose?: boolean;
  39398. sideOrientation?: number;
  39399. frontUVs?: Vector4;
  39400. backUVs?: Vector4;
  39401. }, scene: any): Mesh;
  39402. }
  39403. }
  39404. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39405. import { Observable } from "babylonjs/Misc/observable";
  39406. import { Nullable } from "babylonjs/types";
  39407. import { Camera } from "babylonjs/Cameras/camera";
  39408. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39409. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39410. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39411. import { Scene } from "babylonjs/scene";
  39412. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39413. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39415. import { Mesh } from "babylonjs/Meshes/mesh";
  39416. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39417. import "babylonjs/Meshes/Builders/groundBuilder";
  39418. import "babylonjs/Meshes/Builders/torusBuilder";
  39419. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39420. /**
  39421. * Options to modify the vr teleportation behavior.
  39422. */
  39423. export interface VRTeleportationOptions {
  39424. /**
  39425. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39426. */
  39427. floorMeshName?: string;
  39428. /**
  39429. * A list of meshes to be used as the teleportation floor. (default: empty)
  39430. */
  39431. floorMeshes?: Mesh[];
  39432. }
  39433. /**
  39434. * Options to modify the vr experience helper's behavior.
  39435. */
  39436. export interface VRExperienceHelperOptions extends WebVROptions {
  39437. /**
  39438. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39439. */
  39440. createDeviceOrientationCamera?: boolean;
  39441. /**
  39442. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39443. */
  39444. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39445. /**
  39446. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39447. */
  39448. laserToggle?: boolean;
  39449. /**
  39450. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39451. */
  39452. floorMeshes?: Mesh[];
  39453. }
  39454. /**
  39455. * Helps to quickly add VR support to an existing scene.
  39456. * See http://doc.babylonjs.com/how_to/webvr_helper
  39457. */
  39458. export class VRExperienceHelper {
  39459. /** Options to modify the vr experience helper's behavior. */
  39460. webVROptions: VRExperienceHelperOptions;
  39461. private _scene;
  39462. private _position;
  39463. private _btnVR;
  39464. private _btnVRDisplayed;
  39465. private _webVRsupported;
  39466. private _webVRready;
  39467. private _webVRrequesting;
  39468. private _webVRpresenting;
  39469. private _hasEnteredVR;
  39470. private _fullscreenVRpresenting;
  39471. private _canvas;
  39472. private _webVRCamera;
  39473. private _vrDeviceOrientationCamera;
  39474. private _deviceOrientationCamera;
  39475. private _existingCamera;
  39476. private _onKeyDown;
  39477. private _onVrDisplayPresentChange;
  39478. private _onVRDisplayChanged;
  39479. private _onVRRequestPresentStart;
  39480. private _onVRRequestPresentComplete;
  39481. /**
  39482. * Observable raised when entering VR.
  39483. */
  39484. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39485. /**
  39486. * Observable raised when exiting VR.
  39487. */
  39488. onExitingVRObservable: Observable<VRExperienceHelper>;
  39489. /**
  39490. * Observable raised when controller mesh is loaded.
  39491. */
  39492. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39493. /** Return this.onEnteringVRObservable
  39494. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39495. */
  39496. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39497. /** Return this.onExitingVRObservable
  39498. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39499. */
  39500. readonly onExitingVR: Observable<VRExperienceHelper>;
  39501. /** Return this.onControllerMeshLoadedObservable
  39502. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39503. */
  39504. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39505. private _rayLength;
  39506. private _useCustomVRButton;
  39507. private _teleportationRequested;
  39508. private _teleportActive;
  39509. private _floorMeshName;
  39510. private _floorMeshesCollection;
  39511. private _rotationAllowed;
  39512. private _teleportBackwardsVector;
  39513. private _teleportationTarget;
  39514. private _isDefaultTeleportationTarget;
  39515. private _postProcessMove;
  39516. private _teleportationFillColor;
  39517. private _teleportationBorderColor;
  39518. private _rotationAngle;
  39519. private _haloCenter;
  39520. private _cameraGazer;
  39521. private _padSensibilityUp;
  39522. private _padSensibilityDown;
  39523. private _leftController;
  39524. private _rightController;
  39525. /**
  39526. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39527. */
  39528. onNewMeshSelected: Observable<AbstractMesh>;
  39529. /**
  39530. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39531. */
  39532. onNewMeshPicked: Observable<PickingInfo>;
  39533. private _circleEase;
  39534. /**
  39535. * Observable raised before camera teleportation
  39536. */
  39537. onBeforeCameraTeleport: Observable<Vector3>;
  39538. /**
  39539. * Observable raised after camera teleportation
  39540. */
  39541. onAfterCameraTeleport: Observable<Vector3>;
  39542. /**
  39543. * Observable raised when current selected mesh gets unselected
  39544. */
  39545. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39546. private _raySelectionPredicate;
  39547. /**
  39548. * To be optionaly changed by user to define custom ray selection
  39549. */
  39550. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39551. /**
  39552. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39553. */
  39554. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39555. /**
  39556. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39557. */
  39558. teleportationEnabled: boolean;
  39559. private _defaultHeight;
  39560. private _teleportationInitialized;
  39561. private _interactionsEnabled;
  39562. private _interactionsRequested;
  39563. private _displayGaze;
  39564. private _displayLaserPointer;
  39565. /**
  39566. * The mesh used to display where the user is going to teleport.
  39567. */
  39568. /**
  39569. * Sets the mesh to be used to display where the user is going to teleport.
  39570. */
  39571. teleportationTarget: Mesh;
  39572. /**
  39573. * 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
  39574. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39575. * See http://doc.babylonjs.com/resources/baking_transformations
  39576. */
  39577. gazeTrackerMesh: Mesh;
  39578. /**
  39579. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39580. */
  39581. updateGazeTrackerScale: boolean;
  39582. /**
  39583. * If the gaze trackers color should be updated when selecting meshes
  39584. */
  39585. updateGazeTrackerColor: boolean;
  39586. /**
  39587. * The gaze tracking mesh corresponding to the left controller
  39588. */
  39589. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39590. /**
  39591. * The gaze tracking mesh corresponding to the right controller
  39592. */
  39593. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39594. /**
  39595. * If the ray of the gaze should be displayed.
  39596. */
  39597. /**
  39598. * Sets if the ray of the gaze should be displayed.
  39599. */
  39600. displayGaze: boolean;
  39601. /**
  39602. * If the ray of the LaserPointer should be displayed.
  39603. */
  39604. /**
  39605. * Sets if the ray of the LaserPointer should be displayed.
  39606. */
  39607. displayLaserPointer: boolean;
  39608. /**
  39609. * The deviceOrientationCamera used as the camera when not in VR.
  39610. */
  39611. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39612. /**
  39613. * Based on the current WebVR support, returns the current VR camera used.
  39614. */
  39615. readonly currentVRCamera: Nullable<Camera>;
  39616. /**
  39617. * The webVRCamera which is used when in VR.
  39618. */
  39619. readonly webVRCamera: WebVRFreeCamera;
  39620. /**
  39621. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39622. */
  39623. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39624. private readonly _teleportationRequestInitiated;
  39625. /**
  39626. * Instantiates a VRExperienceHelper.
  39627. * Helps to quickly add VR support to an existing scene.
  39628. * @param scene The scene the VRExperienceHelper belongs to.
  39629. * @param webVROptions Options to modify the vr experience helper's behavior.
  39630. */
  39631. constructor(scene: Scene,
  39632. /** Options to modify the vr experience helper's behavior. */
  39633. webVROptions?: VRExperienceHelperOptions);
  39634. private _onDefaultMeshLoaded;
  39635. private _onResize;
  39636. private _onFullscreenChange;
  39637. /**
  39638. * Gets a value indicating if we are currently in VR mode.
  39639. */
  39640. readonly isInVRMode: boolean;
  39641. private onVrDisplayPresentChange;
  39642. private onVRDisplayChanged;
  39643. private moveButtonToBottomRight;
  39644. private displayVRButton;
  39645. private updateButtonVisibility;
  39646. private _cachedAngularSensibility;
  39647. /**
  39648. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39649. * Otherwise, will use the fullscreen API.
  39650. */
  39651. enterVR(): void;
  39652. /**
  39653. * Attempt to exit VR, or fullscreen.
  39654. */
  39655. exitVR(): void;
  39656. /**
  39657. * The position of the vr experience helper.
  39658. */
  39659. /**
  39660. * Sets the position of the vr experience helper.
  39661. */
  39662. position: Vector3;
  39663. /**
  39664. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39665. */
  39666. enableInteractions(): void;
  39667. private readonly _noControllerIsActive;
  39668. private beforeRender;
  39669. private _isTeleportationFloor;
  39670. /**
  39671. * Adds a floor mesh to be used for teleportation.
  39672. * @param floorMesh the mesh to be used for teleportation.
  39673. */
  39674. addFloorMesh(floorMesh: Mesh): void;
  39675. /**
  39676. * Removes a floor mesh from being used for teleportation.
  39677. * @param floorMesh the mesh to be removed.
  39678. */
  39679. removeFloorMesh(floorMesh: Mesh): void;
  39680. /**
  39681. * Enables interactions and teleportation using the VR controllers and gaze.
  39682. * @param vrTeleportationOptions options to modify teleportation behavior.
  39683. */
  39684. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39685. private _onNewGamepadConnected;
  39686. private _tryEnableInteractionOnController;
  39687. private _onNewGamepadDisconnected;
  39688. private _enableInteractionOnController;
  39689. private _checkTeleportWithRay;
  39690. private _checkRotate;
  39691. private _checkTeleportBackwards;
  39692. private _enableTeleportationOnController;
  39693. private _createTeleportationCircles;
  39694. private _displayTeleportationTarget;
  39695. private _hideTeleportationTarget;
  39696. private _rotateCamera;
  39697. private _moveTeleportationSelectorTo;
  39698. private _workingVector;
  39699. private _workingQuaternion;
  39700. private _workingMatrix;
  39701. /**
  39702. * Teleports the users feet to the desired location
  39703. * @param location The location where the user's feet should be placed
  39704. */
  39705. teleportCamera(location: Vector3): void;
  39706. private _convertNormalToDirectionOfRay;
  39707. private _castRayAndSelectObject;
  39708. private _notifySelectedMeshUnselected;
  39709. /**
  39710. * Sets the color of the laser ray from the vr controllers.
  39711. * @param color new color for the ray.
  39712. */
  39713. changeLaserColor(color: Color3): void;
  39714. /**
  39715. * Sets the color of the ray from the vr headsets gaze.
  39716. * @param color new color for the ray.
  39717. */
  39718. changeGazeColor(color: Color3): void;
  39719. /**
  39720. * Exits VR and disposes of the vr experience helper
  39721. */
  39722. dispose(): void;
  39723. /**
  39724. * Gets the name of the VRExperienceHelper class
  39725. * @returns "VRExperienceHelper"
  39726. */
  39727. getClassName(): string;
  39728. }
  39729. }
  39730. declare module "babylonjs/Cameras/VR/index" {
  39731. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39732. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39733. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39734. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39735. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39736. export * from "babylonjs/Cameras/VR/webVRCamera";
  39737. }
  39738. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39739. import { Observable } from "babylonjs/Misc/observable";
  39740. import { Nullable } from "babylonjs/types";
  39741. import { IDisposable, Scene } from "babylonjs/scene";
  39742. import { Vector3 } from "babylonjs/Maths/math";
  39743. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39744. import { Ray } from "babylonjs/Culling/ray";
  39745. /**
  39746. * Manages an XRSession
  39747. * @see https://doc.babylonjs.com/how_to/webxr
  39748. */
  39749. export class WebXRSessionManager implements IDisposable {
  39750. private scene;
  39751. /**
  39752. * Fires every time a new xrFrame arrives which can be used to update the camera
  39753. */
  39754. onXRFrameObservable: Observable<any>;
  39755. /**
  39756. * Fires when the xr session is ended either by the device or manually done
  39757. */
  39758. onXRSessionEnded: Observable<any>;
  39759. /** @hidden */
  39760. _xrSession: XRSession;
  39761. /** @hidden */
  39762. _frameOfReference: XRFrameOfReference;
  39763. /** @hidden */
  39764. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39765. /** @hidden */
  39766. _currentXRFrame: Nullable<XRFrame>;
  39767. private _xrNavigator;
  39768. private _xrDevice;
  39769. private _tmpMatrix;
  39770. /**
  39771. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39772. * @param scene The scene which the session should be created for
  39773. */
  39774. constructor(scene: Scene);
  39775. /**
  39776. * Initializes the manager
  39777. * After initialization enterXR can be called to start an XR session
  39778. * @returns Promise which resolves after it is initialized
  39779. */
  39780. initializeAsync(): Promise<void>;
  39781. /**
  39782. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39783. * @param sessionCreationOptions xr options to create the session with
  39784. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39785. * @returns Promise which resolves after it enters XR
  39786. */
  39787. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39788. /**
  39789. * Stops the xrSession and restores the renderloop
  39790. * @returns Promise which resolves after it exits XR
  39791. */
  39792. exitXRAsync(): Promise<void>;
  39793. /**
  39794. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39795. * @param ray ray to cast into the environment
  39796. * @returns Promise which resolves with a collision point in the environment if it exists
  39797. */
  39798. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39799. /**
  39800. * Checks if a session would be supported for the creation options specified
  39801. * @param options creation options to check if they are supported
  39802. * @returns true if supported
  39803. */
  39804. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39805. /**
  39806. * @hidden
  39807. * Converts the render layer of xrSession to a render target
  39808. * @param session session to create render target for
  39809. * @param scene scene the new render target should be created for
  39810. */
  39811. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39812. /**
  39813. * Disposes of the session manager
  39814. */
  39815. dispose(): void;
  39816. }
  39817. }
  39818. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39819. import { Scene } from "babylonjs/scene";
  39820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39821. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39822. /**
  39823. * WebXR Camera which holds the views for the xrSession
  39824. * @see https://doc.babylonjs.com/how_to/webxr
  39825. */
  39826. export class WebXRCamera extends FreeCamera {
  39827. private static _TmpMatrix;
  39828. /**
  39829. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39830. * @param name the name of the camera
  39831. * @param scene the scene to add the camera to
  39832. */
  39833. constructor(name: string, scene: Scene);
  39834. private _updateNumberOfRigCameras;
  39835. /** @hidden */
  39836. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39837. /**
  39838. * Updates the cameras position from the current pose information of the XR session
  39839. * @param xrSessionManager the session containing pose information
  39840. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39841. */
  39842. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39843. }
  39844. }
  39845. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  39846. import { Nullable } from "babylonjs/types";
  39847. import { Observable } from "babylonjs/Misc/observable";
  39848. import { IDisposable, Scene } from "babylonjs/scene";
  39849. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  39850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39851. import { Ray } from "babylonjs/Culling/ray";
  39852. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39853. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  39854. /**
  39855. * States of the webXR experience
  39856. */
  39857. export enum WebXRState {
  39858. /**
  39859. * Transitioning to being in XR mode
  39860. */
  39861. ENTERING_XR = 0,
  39862. /**
  39863. * Transitioning to non XR mode
  39864. */
  39865. EXITING_XR = 1,
  39866. /**
  39867. * In XR mode and presenting
  39868. */
  39869. IN_XR = 2,
  39870. /**
  39871. * Not entered XR mode
  39872. */
  39873. NOT_IN_XR = 3
  39874. }
  39875. /**
  39876. * Helper class used to enable XR
  39877. * @see https://doc.babylonjs.com/how_to/webxr
  39878. */
  39879. export class WebXRExperienceHelper implements IDisposable {
  39880. private scene;
  39881. /**
  39882. * 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
  39883. */
  39884. container: AbstractMesh;
  39885. /**
  39886. * Camera used to render xr content
  39887. */
  39888. camera: WebXRCamera;
  39889. /**
  39890. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39891. */
  39892. state: WebXRState;
  39893. private _setState;
  39894. private static _TmpVector;
  39895. /**
  39896. * Fires when the state of the experience helper has changed
  39897. */
  39898. onStateChangedObservable: Observable<WebXRState>;
  39899. /** @hidden */
  39900. _sessionManager: WebXRSessionManager;
  39901. private _nonVRCamera;
  39902. private _originalSceneAutoClear;
  39903. private _supported;
  39904. /**
  39905. * Creates the experience helper
  39906. * @param scene the scene to attach the experience helper to
  39907. * @returns a promise for the experience helper
  39908. */
  39909. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39910. /**
  39911. * Creates a WebXRExperienceHelper
  39912. * @param scene The scene the helper should be created in
  39913. */
  39914. private constructor();
  39915. /**
  39916. * Exits XR mode and returns the scene to its original state
  39917. * @returns promise that resolves after xr mode has exited
  39918. */
  39919. exitXRAsync(): Promise<void>;
  39920. /**
  39921. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39922. * @param sessionCreationOptions options for the XR session
  39923. * @param frameOfReference frame of reference of the XR session
  39924. * @returns promise that resolves after xr mode has entered
  39925. */
  39926. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39927. /**
  39928. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39929. * @param ray ray to cast into the environment
  39930. * @returns Promise which resolves with a collision point in the environment if it exists
  39931. */
  39932. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39933. /**
  39934. * Updates the global position of the camera by moving the camera's container
  39935. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39936. * @param position The desired global position of the camera
  39937. */
  39938. setPositionOfCameraUsingContainer(position: Vector3): void;
  39939. /**
  39940. * Rotates the xr camera by rotating the camera's container around the camera's position
  39941. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39942. * @param rotation the desired quaternion rotation to apply to the camera
  39943. */
  39944. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39945. /**
  39946. * Checks if the creation options are supported by the xr session
  39947. * @param options creation options
  39948. * @returns true if supported
  39949. */
  39950. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39951. /**
  39952. * Disposes of the experience helper
  39953. */
  39954. dispose(): void;
  39955. }
  39956. }
  39957. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  39958. import { Nullable } from "babylonjs/types";
  39959. import { Observable } from "babylonjs/Misc/observable";
  39960. import { IDisposable, Scene } from "babylonjs/scene";
  39961. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  39962. /**
  39963. * Button which can be used to enter a different mode of XR
  39964. */
  39965. export class WebXREnterExitUIButton {
  39966. /** button element */
  39967. element: HTMLElement;
  39968. /** XR initialization options for the button */
  39969. initializationOptions: XRSessionCreationOptions;
  39970. /**
  39971. * Creates a WebXREnterExitUIButton
  39972. * @param element button element
  39973. * @param initializationOptions XR initialization options for the button
  39974. */
  39975. constructor(
  39976. /** button element */
  39977. element: HTMLElement,
  39978. /** XR initialization options for the button */
  39979. initializationOptions: XRSessionCreationOptions);
  39980. /**
  39981. * Overwritable function which can be used to update the button's visuals when the state changes
  39982. * @param activeButton the current active button in the UI
  39983. */
  39984. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39985. }
  39986. /**
  39987. * Options to create the webXR UI
  39988. */
  39989. export class WebXREnterExitUIOptions {
  39990. /**
  39991. * Context to enter xr with
  39992. */
  39993. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39994. /**
  39995. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39996. */
  39997. customButtons?: Array<WebXREnterExitUIButton>;
  39998. }
  39999. /**
  40000. * UI to allow the user to enter/exit XR mode
  40001. */
  40002. export class WebXREnterExitUI implements IDisposable {
  40003. private scene;
  40004. private _overlay;
  40005. private _buttons;
  40006. private _activeButton;
  40007. /**
  40008. * Fired every time the active button is changed.
  40009. *
  40010. * When xr is entered via a button that launches xr that button will be the callback parameter
  40011. *
  40012. * When exiting xr the callback parameter will be null)
  40013. */
  40014. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40015. /**
  40016. * Creates UI to allow the user to enter/exit XR mode
  40017. * @param scene the scene to add the ui to
  40018. * @param helper the xr experience helper to enter/exit xr with
  40019. * @param options options to configure the UI
  40020. * @returns the created ui
  40021. */
  40022. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40023. private constructor();
  40024. private _updateButtons;
  40025. /**
  40026. * Disposes of the object
  40027. */
  40028. dispose(): void;
  40029. }
  40030. }
  40031. declare module "babylonjs/Cameras/XR/webXRInput" {
  40032. import { IDisposable, Scene } from "babylonjs/scene";
  40033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40034. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40035. /**
  40036. * Represents an XR input
  40037. */
  40038. export class WebXRController {
  40039. /**
  40040. * 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
  40041. */
  40042. grip?: AbstractMesh;
  40043. /**
  40044. * Pointer which can be used to select objects or attach a visible laser to
  40045. */
  40046. pointer: AbstractMesh;
  40047. /**
  40048. * Creates the controller
  40049. * @see https://doc.babylonjs.com/how_to/webxr
  40050. * @param scene the scene which the controller should be associated to
  40051. */
  40052. constructor(scene: Scene);
  40053. /**
  40054. * Disposes of the object
  40055. */
  40056. dispose(): void;
  40057. }
  40058. /**
  40059. * XR input used to track XR inputs such as controllers/rays
  40060. */
  40061. export class WebXRInput implements IDisposable {
  40062. private helper;
  40063. /**
  40064. * XR controllers being tracked
  40065. */
  40066. controllers: Array<WebXRController>;
  40067. private _tmpMatrix;
  40068. private _frameObserver;
  40069. /**
  40070. * Initializes the WebXRInput
  40071. * @param helper experience helper which the input should be created for
  40072. */
  40073. constructor(helper: WebXRExperienceHelper);
  40074. /**
  40075. * Disposes of the object
  40076. */
  40077. dispose(): void;
  40078. }
  40079. }
  40080. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40081. import { Nullable } from "babylonjs/types";
  40082. import { IDisposable } from "babylonjs/scene";
  40083. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40084. /**
  40085. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40086. */
  40087. export class WebXRManagedOutputCanvas implements IDisposable {
  40088. private _canvas;
  40089. /**
  40090. * xrpresent context of the canvas which can be used to display/mirror xr content
  40091. */
  40092. canvasContext: Nullable<WebGLRenderingContext>;
  40093. /**
  40094. * Initializes the canvas to be added/removed upon entering/exiting xr
  40095. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40096. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40097. */
  40098. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40099. /**
  40100. * Disposes of the object
  40101. */
  40102. dispose(): void;
  40103. private _setManagedOutputCanvas;
  40104. private _addCanvas;
  40105. private _removeCanvas;
  40106. }
  40107. }
  40108. declare module "babylonjs/Cameras/XR/index" {
  40109. export * from "babylonjs/Cameras/XR/webXRCamera";
  40110. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40111. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40112. export * from "babylonjs/Cameras/XR/webXRInput";
  40113. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40114. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40115. }
  40116. declare module "babylonjs/Cameras/RigModes/index" {
  40117. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40118. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40119. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40120. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40121. }
  40122. declare module "babylonjs/Cameras/index" {
  40123. export * from "babylonjs/Cameras/Inputs/index";
  40124. export * from "babylonjs/Cameras/cameraInputsManager";
  40125. export * from "babylonjs/Cameras/camera";
  40126. export * from "babylonjs/Cameras/targetCamera";
  40127. export * from "babylonjs/Cameras/freeCamera";
  40128. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40129. export * from "babylonjs/Cameras/touchCamera";
  40130. export * from "babylonjs/Cameras/arcRotateCamera";
  40131. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40132. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40133. export * from "babylonjs/Cameras/flyCamera";
  40134. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40135. export * from "babylonjs/Cameras/followCamera";
  40136. export * from "babylonjs/Cameras/gamepadCamera";
  40137. export * from "babylonjs/Cameras/Stereoscopic/index";
  40138. export * from "babylonjs/Cameras/universalCamera";
  40139. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40140. export * from "babylonjs/Cameras/VR/index";
  40141. export * from "babylonjs/Cameras/XR/index";
  40142. export * from "babylonjs/Cameras/RigModes/index";
  40143. }
  40144. declare module "babylonjs/Collisions/index" {
  40145. export * from "babylonjs/Collisions/collider";
  40146. export * from "babylonjs/Collisions/collisionCoordinator";
  40147. export * from "babylonjs/Collisions/pickingInfo";
  40148. export * from "babylonjs/Collisions/intersectionInfo";
  40149. }
  40150. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40151. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40152. import { Vector3, Plane } from "babylonjs/Maths/math";
  40153. import { Ray } from "babylonjs/Culling/ray";
  40154. /**
  40155. * Contains an array of blocks representing the octree
  40156. */
  40157. export interface IOctreeContainer<T> {
  40158. /**
  40159. * Blocks within the octree
  40160. */
  40161. blocks: Array<OctreeBlock<T>>;
  40162. }
  40163. /**
  40164. * Class used to store a cell in an octree
  40165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40166. */
  40167. export class OctreeBlock<T> {
  40168. /**
  40169. * Gets the content of the current block
  40170. */
  40171. entries: T[];
  40172. /**
  40173. * Gets the list of block children
  40174. */
  40175. blocks: Array<OctreeBlock<T>>;
  40176. private _depth;
  40177. private _maxDepth;
  40178. private _capacity;
  40179. private _minPoint;
  40180. private _maxPoint;
  40181. private _boundingVectors;
  40182. private _creationFunc;
  40183. /**
  40184. * Creates a new block
  40185. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40186. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40187. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40188. * @param depth defines the current depth of this block in the octree
  40189. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40190. * @param creationFunc defines a callback to call when an element is added to the block
  40191. */
  40192. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40193. /**
  40194. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40195. */
  40196. readonly capacity: number;
  40197. /**
  40198. * Gets the minimum vector (in world space) of the block's bounding box
  40199. */
  40200. readonly minPoint: Vector3;
  40201. /**
  40202. * Gets the maximum vector (in world space) of the block's bounding box
  40203. */
  40204. readonly maxPoint: Vector3;
  40205. /**
  40206. * Add a new element to this block
  40207. * @param entry defines the element to add
  40208. */
  40209. addEntry(entry: T): void;
  40210. /**
  40211. * Remove an element from this block
  40212. * @param entry defines the element to remove
  40213. */
  40214. removeEntry(entry: T): void;
  40215. /**
  40216. * Add an array of elements to this block
  40217. * @param entries defines the array of elements to add
  40218. */
  40219. addEntries(entries: T[]): void;
  40220. /**
  40221. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40222. * @param frustumPlanes defines the frustum planes to test
  40223. * @param selection defines the array to store current content if selection is positive
  40224. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40225. */
  40226. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40227. /**
  40228. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40229. * @param sphereCenter defines the bounding sphere center
  40230. * @param sphereRadius defines the bounding sphere radius
  40231. * @param selection defines the array to store current content if selection is positive
  40232. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40233. */
  40234. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40235. /**
  40236. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40237. * @param ray defines the ray to test with
  40238. * @param selection defines the array to store current content if selection is positive
  40239. */
  40240. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40241. /**
  40242. * Subdivide the content into child blocks (this block will then be empty)
  40243. */
  40244. createInnerBlocks(): void;
  40245. /**
  40246. * @hidden
  40247. */
  40248. 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;
  40249. }
  40250. }
  40251. declare module "babylonjs/Culling/Octrees/octree" {
  40252. import { SmartArray } from "babylonjs/Misc/smartArray";
  40253. import { Vector3, Plane } from "babylonjs/Maths/math";
  40254. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40256. import { Ray } from "babylonjs/Culling/ray";
  40257. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40258. /**
  40259. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40260. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40261. */
  40262. export class Octree<T> {
  40263. /** 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.) */
  40264. maxDepth: number;
  40265. /**
  40266. * Blocks within the octree containing objects
  40267. */
  40268. blocks: Array<OctreeBlock<T>>;
  40269. /**
  40270. * Content stored in the octree
  40271. */
  40272. dynamicContent: T[];
  40273. private _maxBlockCapacity;
  40274. private _selectionContent;
  40275. private _creationFunc;
  40276. /**
  40277. * Creates a octree
  40278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40279. * @param creationFunc function to be used to instatiate the octree
  40280. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40281. * @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.)
  40282. */
  40283. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40284. /** 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.) */
  40285. maxDepth?: number);
  40286. /**
  40287. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40288. * @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);
  40289. * @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);
  40290. * @param entries meshes to be added to the octree blocks
  40291. */
  40292. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40293. /**
  40294. * Adds a mesh to the octree
  40295. * @param entry Mesh to add to the octree
  40296. */
  40297. addMesh(entry: T): void;
  40298. /**
  40299. * Remove an element from the octree
  40300. * @param entry defines the element to remove
  40301. */
  40302. removeMesh(entry: T): void;
  40303. /**
  40304. * Selects an array of meshes within the frustum
  40305. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40306. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40307. * @returns array of meshes within the frustum
  40308. */
  40309. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40310. /**
  40311. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40312. * @param sphereCenter defines the bounding sphere center
  40313. * @param sphereRadius defines the bounding sphere radius
  40314. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40315. * @returns an array of objects that intersect the sphere
  40316. */
  40317. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40318. /**
  40319. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40320. * @param ray defines the ray to test with
  40321. * @returns array of intersected objects
  40322. */
  40323. intersectsRay(ray: Ray): SmartArray<T>;
  40324. /**
  40325. * Adds a mesh into the octree block if it intersects the block
  40326. */
  40327. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40328. /**
  40329. * Adds a submesh into the octree block if it intersects the block
  40330. */
  40331. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40332. }
  40333. }
  40334. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40335. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40336. import { Scene } from "babylonjs/scene";
  40337. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40339. import { Ray } from "babylonjs/Culling/ray";
  40340. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40341. import { Collider } from "babylonjs/Collisions/collider";
  40342. module "babylonjs/scene" {
  40343. interface Scene {
  40344. /**
  40345. * @hidden
  40346. * Backing Filed
  40347. */
  40348. _selectionOctree: Octree<AbstractMesh>;
  40349. /**
  40350. * Gets the octree used to boost mesh selection (picking)
  40351. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40352. */
  40353. selectionOctree: Octree<AbstractMesh>;
  40354. /**
  40355. * Creates or updates the octree used to boost selection (picking)
  40356. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40357. * @param maxCapacity defines the maximum capacity per leaf
  40358. * @param maxDepth defines the maximum depth of the octree
  40359. * @returns an octree of AbstractMesh
  40360. */
  40361. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40362. }
  40363. }
  40364. module "babylonjs/Meshes/abstractMesh" {
  40365. interface AbstractMesh {
  40366. /**
  40367. * @hidden
  40368. * Backing Field
  40369. */
  40370. _submeshesOctree: Octree<SubMesh>;
  40371. /**
  40372. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40373. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40374. * @param maxCapacity defines the maximum size of each block (64 by default)
  40375. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40376. * @returns the new octree
  40377. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40379. */
  40380. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40381. }
  40382. }
  40383. /**
  40384. * Defines the octree scene component responsible to manage any octrees
  40385. * in a given scene.
  40386. */
  40387. export class OctreeSceneComponent {
  40388. /**
  40389. * The component name helpfull to identify the component in the list of scene components.
  40390. */
  40391. readonly name: string;
  40392. /**
  40393. * The scene the component belongs to.
  40394. */
  40395. scene: Scene;
  40396. /**
  40397. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40398. */
  40399. readonly checksIsEnabled: boolean;
  40400. /**
  40401. * Creates a new instance of the component for the given scene
  40402. * @param scene Defines the scene to register the component in
  40403. */
  40404. constructor(scene: Scene);
  40405. /**
  40406. * Registers the component in a given scene
  40407. */
  40408. register(): void;
  40409. /**
  40410. * Return the list of active meshes
  40411. * @returns the list of active meshes
  40412. */
  40413. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40414. /**
  40415. * Return the list of active sub meshes
  40416. * @param mesh The mesh to get the candidates sub meshes from
  40417. * @returns the list of active sub meshes
  40418. */
  40419. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40420. private _tempRay;
  40421. /**
  40422. * Return the list of sub meshes intersecting with a given local ray
  40423. * @param mesh defines the mesh to find the submesh for
  40424. * @param localRay defines the ray in local space
  40425. * @returns the list of intersecting sub meshes
  40426. */
  40427. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40428. /**
  40429. * Return the list of sub meshes colliding with a collider
  40430. * @param mesh defines the mesh to find the submesh for
  40431. * @param collider defines the collider to evaluate the collision against
  40432. * @returns the list of colliding sub meshes
  40433. */
  40434. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40435. /**
  40436. * Rebuilds the elements related to this component in case of
  40437. * context lost for instance.
  40438. */
  40439. rebuild(): void;
  40440. /**
  40441. * Disposes the component and the associated ressources.
  40442. */
  40443. dispose(): void;
  40444. }
  40445. }
  40446. declare module "babylonjs/Culling/Octrees/index" {
  40447. export * from "babylonjs/Culling/Octrees/octree";
  40448. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40449. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40450. }
  40451. declare module "babylonjs/Culling/index" {
  40452. export * from "babylonjs/Culling/boundingBox";
  40453. export * from "babylonjs/Culling/boundingInfo";
  40454. export * from "babylonjs/Culling/boundingSphere";
  40455. export * from "babylonjs/Culling/Octrees/index";
  40456. export * from "babylonjs/Culling/ray";
  40457. }
  40458. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40459. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40460. import { Nullable } from "babylonjs/types";
  40461. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40462. import { Scene } from "babylonjs/scene";
  40463. /**
  40464. * Class containing static functions to help procedurally build meshes
  40465. */
  40466. export class LinesBuilder {
  40467. /**
  40468. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40469. * * 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
  40470. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40471. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40472. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40473. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40474. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40475. * * 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
  40476. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40479. * @param name defines the name of the new line system
  40480. * @param options defines the options used to create the line system
  40481. * @param scene defines the hosting scene
  40482. * @returns a new line system mesh
  40483. */
  40484. static CreateLineSystem(name: string, options: {
  40485. lines: Vector3[][];
  40486. updatable?: boolean;
  40487. instance?: Nullable<LinesMesh>;
  40488. colors?: Nullable<Color4[][]>;
  40489. useVertexAlpha?: boolean;
  40490. }, scene: Nullable<Scene>): LinesMesh;
  40491. /**
  40492. * Creates a line mesh
  40493. * 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
  40494. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40495. * * The parameter `points` is an array successive Vector3
  40496. * * 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
  40497. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40498. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40499. * * When updating an instance, remember that only point positions can change, not the number of points
  40500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40502. * @param name defines the name of the new line system
  40503. * @param options defines the options used to create the line system
  40504. * @param scene defines the hosting scene
  40505. * @returns a new line mesh
  40506. */
  40507. static CreateLines(name: string, options: {
  40508. points: Vector3[];
  40509. updatable?: boolean;
  40510. instance?: Nullable<LinesMesh>;
  40511. colors?: Color4[];
  40512. useVertexAlpha?: boolean;
  40513. }, scene?: Nullable<Scene>): LinesMesh;
  40514. /**
  40515. * Creates a dashed line mesh
  40516. * * 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
  40517. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40518. * * The parameter `points` is an array successive Vector3
  40519. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40520. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40521. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40522. * * 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
  40523. * * When updating an instance, remember that only point positions can change, not the number of points
  40524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40525. * @param name defines the name of the mesh
  40526. * @param options defines the options used to create the mesh
  40527. * @param scene defines the hosting scene
  40528. * @returns the dashed line mesh
  40529. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40530. */
  40531. static CreateDashedLines(name: string, options: {
  40532. points: Vector3[];
  40533. dashSize?: number;
  40534. gapSize?: number;
  40535. dashNb?: number;
  40536. updatable?: boolean;
  40537. instance?: LinesMesh;
  40538. }, scene?: Nullable<Scene>): LinesMesh;
  40539. }
  40540. }
  40541. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40542. import { IDisposable, Scene } from "babylonjs/scene";
  40543. import { Nullable } from "babylonjs/types";
  40544. import { Observable } from "babylonjs/Misc/observable";
  40545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40546. /**
  40547. * Renders a layer on top of an existing scene
  40548. */
  40549. export class UtilityLayerRenderer implements IDisposable {
  40550. /** the original scene that will be rendered on top of */
  40551. originalScene: Scene;
  40552. private _pointerCaptures;
  40553. private _lastPointerEvents;
  40554. private static _DefaultUtilityLayer;
  40555. private static _DefaultKeepDepthUtilityLayer;
  40556. /**
  40557. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40558. */
  40559. pickUtilitySceneFirst: boolean;
  40560. /**
  40561. * 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)
  40562. */
  40563. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40564. /**
  40565. * 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)
  40566. */
  40567. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40568. /**
  40569. * The scene that is rendered on top of the original scene
  40570. */
  40571. utilityLayerScene: Scene;
  40572. /**
  40573. * If the utility layer should automatically be rendered on top of existing scene
  40574. */
  40575. shouldRender: boolean;
  40576. /**
  40577. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40578. */
  40579. onlyCheckPointerDownEvents: boolean;
  40580. /**
  40581. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40582. */
  40583. processAllEvents: boolean;
  40584. /**
  40585. * Observable raised when the pointer move from the utility layer scene to the main scene
  40586. */
  40587. onPointerOutObservable: Observable<number>;
  40588. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40589. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40590. private _afterRenderObserver;
  40591. private _sceneDisposeObserver;
  40592. private _originalPointerObserver;
  40593. /**
  40594. * Instantiates a UtilityLayerRenderer
  40595. * @param originalScene the original scene that will be rendered on top of
  40596. * @param handleEvents boolean indicating if the utility layer should handle events
  40597. */
  40598. constructor(
  40599. /** the original scene that will be rendered on top of */
  40600. originalScene: Scene, handleEvents?: boolean);
  40601. private _notifyObservers;
  40602. /**
  40603. * Renders the utility layers scene on top of the original scene
  40604. */
  40605. render(): void;
  40606. /**
  40607. * Disposes of the renderer
  40608. */
  40609. dispose(): void;
  40610. private _updateCamera;
  40611. }
  40612. }
  40613. declare module "babylonjs/Gizmos/gizmo" {
  40614. import { Nullable } from "babylonjs/types";
  40615. import { IDisposable } from "babylonjs/scene";
  40616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40617. import { Mesh } from "babylonjs/Meshes/mesh";
  40618. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40619. /**
  40620. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40621. */
  40622. export class Gizmo implements IDisposable {
  40623. /** The utility layer the gizmo will be added to */
  40624. gizmoLayer: UtilityLayerRenderer;
  40625. /**
  40626. * The root mesh of the gizmo
  40627. */
  40628. protected _rootMesh: Mesh;
  40629. private _attachedMesh;
  40630. /**
  40631. * Ratio for the scale of the gizmo (Default: 1)
  40632. */
  40633. scaleRatio: number;
  40634. private _tmpMatrix;
  40635. /**
  40636. * If a custom mesh has been set (Default: false)
  40637. */
  40638. protected _customMeshSet: boolean;
  40639. /**
  40640. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40641. * * When set, interactions will be enabled
  40642. */
  40643. attachedMesh: Nullable<AbstractMesh>;
  40644. /**
  40645. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40646. * @param mesh The mesh to replace the default mesh of the gizmo
  40647. */
  40648. setCustomMesh(mesh: Mesh): void;
  40649. /**
  40650. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40651. */
  40652. updateGizmoRotationToMatchAttachedMesh: boolean;
  40653. /**
  40654. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40655. */
  40656. updateGizmoPositionToMatchAttachedMesh: boolean;
  40657. /**
  40658. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40659. */
  40660. protected _updateScale: boolean;
  40661. protected _interactionsEnabled: boolean;
  40662. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40663. private _beforeRenderObserver;
  40664. /**
  40665. * Creates a gizmo
  40666. * @param gizmoLayer The utility layer the gizmo will be added to
  40667. */
  40668. constructor(
  40669. /** The utility layer the gizmo will be added to */
  40670. gizmoLayer?: UtilityLayerRenderer);
  40671. private _tempVector;
  40672. /**
  40673. * @hidden
  40674. * Updates the gizmo to match the attached mesh's position/rotation
  40675. */
  40676. protected _update(): void;
  40677. /**
  40678. * Disposes of the gizmo
  40679. */
  40680. dispose(): void;
  40681. }
  40682. }
  40683. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40684. import { Observable } from "babylonjs/Misc/observable";
  40685. import { Nullable } from "babylonjs/types";
  40686. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40687. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40689. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40690. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40691. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40692. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40693. import { Scene } from "babylonjs/scene";
  40694. /**
  40695. * Single axis drag gizmo
  40696. */
  40697. export class AxisDragGizmo extends Gizmo {
  40698. /**
  40699. * Drag behavior responsible for the gizmos dragging interactions
  40700. */
  40701. dragBehavior: PointerDragBehavior;
  40702. private _pointerObserver;
  40703. /**
  40704. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40705. */
  40706. snapDistance: number;
  40707. /**
  40708. * Event that fires each time the gizmo snaps to a new location.
  40709. * * snapDistance is the the change in distance
  40710. */
  40711. onSnapObservable: Observable<{
  40712. snapDistance: number;
  40713. }>;
  40714. /** @hidden */
  40715. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40716. /** @hidden */
  40717. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40718. /**
  40719. * Creates an AxisDragGizmo
  40720. * @param gizmoLayer The utility layer the gizmo will be added to
  40721. * @param dragAxis The axis which the gizmo will be able to drag on
  40722. * @param color The color of the gizmo
  40723. */
  40724. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40726. /**
  40727. * Disposes of the gizmo
  40728. */
  40729. dispose(): void;
  40730. }
  40731. }
  40732. declare module "babylonjs/Debug/axesViewer" {
  40733. import { Vector3 } from "babylonjs/Maths/math";
  40734. import { Nullable } from "babylonjs/types";
  40735. import { Scene } from "babylonjs/scene";
  40736. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40737. /**
  40738. * The Axes viewer will show 3 axes in a specific point in space
  40739. */
  40740. export class AxesViewer {
  40741. private _xAxis;
  40742. private _yAxis;
  40743. private _zAxis;
  40744. private _scaleLinesFactor;
  40745. private _instanced;
  40746. /**
  40747. * Gets the hosting scene
  40748. */
  40749. scene: Scene;
  40750. /**
  40751. * Gets or sets a number used to scale line length
  40752. */
  40753. scaleLines: number;
  40754. /** Gets the node hierarchy used to render x-axis */
  40755. readonly xAxis: TransformNode;
  40756. /** Gets the node hierarchy used to render y-axis */
  40757. readonly yAxis: TransformNode;
  40758. /** Gets the node hierarchy used to render z-axis */
  40759. readonly zAxis: TransformNode;
  40760. /**
  40761. * Creates a new AxesViewer
  40762. * @param scene defines the hosting scene
  40763. * @param scaleLines defines a number used to scale line length (1 by default)
  40764. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40765. * @param xAxis defines the node hierarchy used to render the x-axis
  40766. * @param yAxis defines the node hierarchy used to render the y-axis
  40767. * @param zAxis defines the node hierarchy used to render the z-axis
  40768. */
  40769. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40770. /**
  40771. * Force the viewer to update
  40772. * @param position defines the position of the viewer
  40773. * @param xaxis defines the x axis of the viewer
  40774. * @param yaxis defines the y axis of the viewer
  40775. * @param zaxis defines the z axis of the viewer
  40776. */
  40777. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40778. /**
  40779. * Creates an instance of this axes viewer.
  40780. * @returns a new axes viewer with instanced meshes
  40781. */
  40782. createInstance(): AxesViewer;
  40783. /** Releases resources */
  40784. dispose(): void;
  40785. private static _SetRenderingGroupId;
  40786. }
  40787. }
  40788. declare module "babylonjs/Debug/boneAxesViewer" {
  40789. import { Nullable } from "babylonjs/types";
  40790. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40791. import { Vector3 } from "babylonjs/Maths/math";
  40792. import { Mesh } from "babylonjs/Meshes/mesh";
  40793. import { Bone } from "babylonjs/Bones/bone";
  40794. import { Scene } from "babylonjs/scene";
  40795. /**
  40796. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40797. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40798. */
  40799. export class BoneAxesViewer extends AxesViewer {
  40800. /**
  40801. * Gets or sets the target mesh where to display the axes viewer
  40802. */
  40803. mesh: Nullable<Mesh>;
  40804. /**
  40805. * Gets or sets the target bone where to display the axes viewer
  40806. */
  40807. bone: Nullable<Bone>;
  40808. /** Gets current position */
  40809. pos: Vector3;
  40810. /** Gets direction of X axis */
  40811. xaxis: Vector3;
  40812. /** Gets direction of Y axis */
  40813. yaxis: Vector3;
  40814. /** Gets direction of Z axis */
  40815. zaxis: Vector3;
  40816. /**
  40817. * Creates a new BoneAxesViewer
  40818. * @param scene defines the hosting scene
  40819. * @param bone defines the target bone
  40820. * @param mesh defines the target mesh
  40821. * @param scaleLines defines a scaling factor for line length (1 by default)
  40822. */
  40823. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40824. /**
  40825. * Force the viewer to update
  40826. */
  40827. update(): void;
  40828. /** Releases resources */
  40829. dispose(): void;
  40830. }
  40831. }
  40832. declare module "babylonjs/Debug/debugLayer" {
  40833. import { Observable } from "babylonjs/Misc/observable";
  40834. import { Scene } from "babylonjs/scene";
  40835. /**
  40836. * Interface used to define scene explorer extensibility option
  40837. */
  40838. export interface IExplorerExtensibilityOption {
  40839. /**
  40840. * Define the option label
  40841. */
  40842. label: string;
  40843. /**
  40844. * Defines the action to execute on click
  40845. */
  40846. action: (entity: any) => void;
  40847. }
  40848. /**
  40849. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40850. */
  40851. export interface IExplorerExtensibilityGroup {
  40852. /**
  40853. * Defines a predicate to test if a given type mut be extended
  40854. */
  40855. predicate: (entity: any) => boolean;
  40856. /**
  40857. * Gets the list of options added to a type
  40858. */
  40859. entries: IExplorerExtensibilityOption[];
  40860. }
  40861. /**
  40862. * Interface used to define the options to use to create the Inspector
  40863. */
  40864. export interface IInspectorOptions {
  40865. /**
  40866. * Display in overlay mode (default: false)
  40867. */
  40868. overlay?: boolean;
  40869. /**
  40870. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40871. */
  40872. globalRoot?: HTMLElement;
  40873. /**
  40874. * Display the Scene explorer
  40875. */
  40876. showExplorer?: boolean;
  40877. /**
  40878. * Display the property inspector
  40879. */
  40880. showInspector?: boolean;
  40881. /**
  40882. * Display in embed mode (both panes on the right)
  40883. */
  40884. embedMode?: boolean;
  40885. /**
  40886. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40887. */
  40888. handleResize?: boolean;
  40889. /**
  40890. * Allow the panes to popup (default: true)
  40891. */
  40892. enablePopup?: boolean;
  40893. /**
  40894. * Allow the panes to be closed by users (default: true)
  40895. */
  40896. enableClose?: boolean;
  40897. /**
  40898. * Optional list of extensibility entries
  40899. */
  40900. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40901. }
  40902. module "babylonjs/scene" {
  40903. interface Scene {
  40904. /**
  40905. * @hidden
  40906. * Backing field
  40907. */
  40908. _debugLayer: DebugLayer;
  40909. /**
  40910. * Gets the debug layer (aka Inspector) associated with the scene
  40911. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40912. */
  40913. debugLayer: DebugLayer;
  40914. }
  40915. }
  40916. /**
  40917. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40918. * what is happening in your scene
  40919. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40920. */
  40921. export class DebugLayer {
  40922. /**
  40923. * Define the url to get the inspector script from.
  40924. * By default it uses the babylonjs CDN.
  40925. * @ignoreNaming
  40926. */
  40927. static InspectorURL: string;
  40928. private _scene;
  40929. private BJSINSPECTOR;
  40930. /**
  40931. * Observable triggered when a property is changed through the inspector.
  40932. */
  40933. onPropertyChangedObservable: Observable<{
  40934. object: any;
  40935. property: string;
  40936. value: any;
  40937. initialValue: any;
  40938. }>;
  40939. /**
  40940. * Instantiates a new debug layer.
  40941. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40942. * what is happening in your scene
  40943. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40944. * @param scene Defines the scene to inspect
  40945. */
  40946. constructor(scene: Scene);
  40947. /** Creates the inspector window. */
  40948. private _createInspector;
  40949. /** Get the inspector from bundle or global */
  40950. private _getGlobalInspector;
  40951. /**
  40952. * Get if the inspector is visible or not.
  40953. * @returns true if visible otherwise, false
  40954. */
  40955. isVisible(): boolean;
  40956. /**
  40957. * Hide the inspector and close its window.
  40958. */
  40959. hide(): void;
  40960. /**
  40961. * Launch the debugLayer.
  40962. * @param config Define the configuration of the inspector
  40963. */
  40964. show(config?: IInspectorOptions): void;
  40965. }
  40966. }
  40967. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  40968. import { Nullable } from "babylonjs/types";
  40969. import { Scene } from "babylonjs/scene";
  40970. import { Vector4, Color4 } from "babylonjs/Maths/math";
  40971. import { Mesh } from "babylonjs/Meshes/mesh";
  40972. /**
  40973. * Class containing static functions to help procedurally build meshes
  40974. */
  40975. export class BoxBuilder {
  40976. /**
  40977. * Creates a box mesh
  40978. * * The parameter `size` sets the size (float) of each box side (default 1)
  40979. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40980. * * 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)
  40981. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40985. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40986. * @param name defines the name of the mesh
  40987. * @param options defines the options used to create the mesh
  40988. * @param scene defines the hosting scene
  40989. * @returns the box mesh
  40990. */
  40991. static CreateBox(name: string, options: {
  40992. size?: number;
  40993. width?: number;
  40994. height?: number;
  40995. depth?: number;
  40996. faceUV?: Vector4[];
  40997. faceColors?: Color4[];
  40998. sideOrientation?: number;
  40999. frontUVs?: Vector4;
  41000. backUVs?: Vector4;
  41001. updatable?: boolean;
  41002. }, scene?: Nullable<Scene>): Mesh;
  41003. }
  41004. }
  41005. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41006. import { Vector4 } from "babylonjs/Maths/math";
  41007. import { Mesh } from "babylonjs/Meshes/mesh";
  41008. /**
  41009. * Class containing static functions to help procedurally build meshes
  41010. */
  41011. export class SphereBuilder {
  41012. /**
  41013. * Creates a sphere mesh
  41014. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41015. * * 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`)
  41016. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41017. * * 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
  41018. * * 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)
  41019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41022. * @param name defines the name of the mesh
  41023. * @param options defines the options used to create the mesh
  41024. * @param scene defines the hosting scene
  41025. * @returns the sphere mesh
  41026. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41027. */
  41028. static CreateSphere(name: string, options: {
  41029. segments?: number;
  41030. diameter?: number;
  41031. diameterX?: number;
  41032. diameterY?: number;
  41033. diameterZ?: number;
  41034. arc?: number;
  41035. slice?: number;
  41036. sideOrientation?: number;
  41037. frontUVs?: Vector4;
  41038. backUVs?: Vector4;
  41039. updatable?: boolean;
  41040. }, scene: any): Mesh;
  41041. }
  41042. }
  41043. declare module "babylonjs/Debug/physicsViewer" {
  41044. import { Nullable } from "babylonjs/types";
  41045. import { Scene } from "babylonjs/scene";
  41046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41047. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41048. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41049. /**
  41050. * Used to show the physics impostor around the specific mesh
  41051. */
  41052. export class PhysicsViewer {
  41053. /** @hidden */
  41054. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41055. /** @hidden */
  41056. protected _meshes: Array<Nullable<AbstractMesh>>;
  41057. /** @hidden */
  41058. protected _scene: Nullable<Scene>;
  41059. /** @hidden */
  41060. protected _numMeshes: number;
  41061. /** @hidden */
  41062. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41063. private _renderFunction;
  41064. private _utilityLayer;
  41065. private _debugBoxMesh;
  41066. private _debugSphereMesh;
  41067. private _debugMaterial;
  41068. /**
  41069. * Creates a new PhysicsViewer
  41070. * @param scene defines the hosting scene
  41071. */
  41072. constructor(scene: Scene);
  41073. /** @hidden */
  41074. protected _updateDebugMeshes(): void;
  41075. /**
  41076. * Renders a specified physic impostor
  41077. * @param impostor defines the impostor to render
  41078. * @returns the new debug mesh used to render the impostor
  41079. */
  41080. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41081. /**
  41082. * Hides a specified physic impostor
  41083. * @param impostor defines the impostor to hide
  41084. */
  41085. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41086. private _getDebugMaterial;
  41087. private _getDebugBoxMesh;
  41088. private _getDebugSphereMesh;
  41089. private _getDebugMesh;
  41090. /** Releases all resources */
  41091. dispose(): void;
  41092. }
  41093. }
  41094. declare module "babylonjs/Debug/rayHelper" {
  41095. import { Nullable } from "babylonjs/types";
  41096. import { Ray } from "babylonjs/Culling/ray";
  41097. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41098. import { Scene } from "babylonjs/scene";
  41099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41100. import "babylonjs/Meshes/Builders/linesBuilder";
  41101. /**
  41102. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41103. * in order to better appreciate the issue one might have.
  41104. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41105. */
  41106. export class RayHelper {
  41107. /**
  41108. * Defines the ray we are currently tryin to visualize.
  41109. */
  41110. ray: Nullable<Ray>;
  41111. private _renderPoints;
  41112. private _renderLine;
  41113. private _renderFunction;
  41114. private _scene;
  41115. private _updateToMeshFunction;
  41116. private _attachedToMesh;
  41117. private _meshSpaceDirection;
  41118. private _meshSpaceOrigin;
  41119. /**
  41120. * Helper function to create a colored helper in a scene in one line.
  41121. * @param ray Defines the ray we are currently tryin to visualize
  41122. * @param scene Defines the scene the ray is used in
  41123. * @param color Defines the color we want to see the ray in
  41124. * @returns The newly created ray helper.
  41125. */
  41126. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41127. /**
  41128. * Instantiate a new ray helper.
  41129. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41130. * in order to better appreciate the issue one might have.
  41131. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41132. * @param ray Defines the ray we are currently tryin to visualize
  41133. */
  41134. constructor(ray: Ray);
  41135. /**
  41136. * Shows the ray we are willing to debug.
  41137. * @param scene Defines the scene the ray needs to be rendered in
  41138. * @param color Defines the color the ray needs to be rendered in
  41139. */
  41140. show(scene: Scene, color?: Color3): void;
  41141. /**
  41142. * Hides the ray we are debugging.
  41143. */
  41144. hide(): void;
  41145. private _render;
  41146. /**
  41147. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41148. * @param mesh Defines the mesh we want the helper attached to
  41149. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41150. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41151. * @param length Defines the length of the ray
  41152. */
  41153. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41154. /**
  41155. * Detach the ray helper from the mesh it has previously been attached to.
  41156. */
  41157. detachFromMesh(): void;
  41158. private _updateToMesh;
  41159. /**
  41160. * Dispose the helper and release its associated resources.
  41161. */
  41162. dispose(): void;
  41163. }
  41164. }
  41165. declare module "babylonjs/Debug/skeletonViewer" {
  41166. import { Color3 } from "babylonjs/Maths/math";
  41167. import { Scene } from "babylonjs/scene";
  41168. import { Nullable } from "babylonjs/types";
  41169. import { Skeleton } from "babylonjs/Bones/skeleton";
  41170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41171. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41172. /**
  41173. * Class used to render a debug view of a given skeleton
  41174. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41175. */
  41176. export class SkeletonViewer {
  41177. /** defines the skeleton to render */
  41178. skeleton: Skeleton;
  41179. /** defines the mesh attached to the skeleton */
  41180. mesh: AbstractMesh;
  41181. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41182. autoUpdateBonesMatrices: boolean;
  41183. /** defines the rendering group id to use with the viewer */
  41184. renderingGroupId: number;
  41185. /** Gets or sets the color used to render the skeleton */
  41186. color: Color3;
  41187. private _scene;
  41188. private _debugLines;
  41189. private _debugMesh;
  41190. private _isEnabled;
  41191. private _renderFunction;
  41192. private _utilityLayer;
  41193. /**
  41194. * Returns the mesh used to render the bones
  41195. */
  41196. readonly debugMesh: Nullable<LinesMesh>;
  41197. /**
  41198. * Creates a new SkeletonViewer
  41199. * @param skeleton defines the skeleton to render
  41200. * @param mesh defines the mesh attached to the skeleton
  41201. * @param scene defines the hosting scene
  41202. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41203. * @param renderingGroupId defines the rendering group id to use with the viewer
  41204. */
  41205. constructor(
  41206. /** defines the skeleton to render */
  41207. skeleton: Skeleton,
  41208. /** defines the mesh attached to the skeleton */
  41209. mesh: AbstractMesh, scene: Scene,
  41210. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41211. autoUpdateBonesMatrices?: boolean,
  41212. /** defines the rendering group id to use with the viewer */
  41213. renderingGroupId?: number);
  41214. /** Gets or sets a boolean indicating if the viewer is enabled */
  41215. isEnabled: boolean;
  41216. private _getBonePosition;
  41217. private _getLinesForBonesWithLength;
  41218. private _getLinesForBonesNoLength;
  41219. /** Update the viewer to sync with current skeleton state */
  41220. update(): void;
  41221. /** Release associated resources */
  41222. dispose(): void;
  41223. }
  41224. }
  41225. declare module "babylonjs/Debug/index" {
  41226. export * from "babylonjs/Debug/axesViewer";
  41227. export * from "babylonjs/Debug/boneAxesViewer";
  41228. export * from "babylonjs/Debug/debugLayer";
  41229. export * from "babylonjs/Debug/physicsViewer";
  41230. export * from "babylonjs/Debug/rayHelper";
  41231. export * from "babylonjs/Debug/skeletonViewer";
  41232. }
  41233. declare module "babylonjs/Engines/nullEngine" {
  41234. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41235. import { Scene } from "babylonjs/scene";
  41236. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41237. import { Engine } from "babylonjs/Engines/engine";
  41238. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41239. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41240. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41241. import { Effect } from "babylonjs/Materials/effect";
  41242. /**
  41243. * Options to create the null engine
  41244. */
  41245. export class NullEngineOptions {
  41246. /**
  41247. * Render width (Default: 512)
  41248. */
  41249. renderWidth: number;
  41250. /**
  41251. * Render height (Default: 256)
  41252. */
  41253. renderHeight: number;
  41254. /**
  41255. * Texture size (Default: 512)
  41256. */
  41257. textureSize: number;
  41258. /**
  41259. * If delta time between frames should be constant
  41260. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41261. */
  41262. deterministicLockstep: boolean;
  41263. /**
  41264. * Maximum about of steps between frames (Default: 4)
  41265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41266. */
  41267. lockstepMaxSteps: number;
  41268. }
  41269. /**
  41270. * The null engine class provides support for headless version of babylon.js.
  41271. * This can be used in server side scenario or for testing purposes
  41272. */
  41273. export class NullEngine extends Engine {
  41274. private _options;
  41275. /**
  41276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41277. */
  41278. isDeterministicLockStep(): boolean;
  41279. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41280. getLockstepMaxSteps(): number;
  41281. /**
  41282. * Sets hardware scaling, used to save performance if needed
  41283. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41284. */
  41285. getHardwareScalingLevel(): number;
  41286. constructor(options?: NullEngineOptions);
  41287. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41288. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41289. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41290. getRenderWidth(useScreen?: boolean): number;
  41291. getRenderHeight(useScreen?: boolean): number;
  41292. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41293. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41294. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41295. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41296. bindSamplers(effect: Effect): void;
  41297. enableEffect(effect: Effect): void;
  41298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41299. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41300. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41301. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41302. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41303. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41304. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41305. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41306. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41307. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41308. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41309. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41310. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41311. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41312. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41313. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41314. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41315. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41316. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41317. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41318. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41319. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41320. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41321. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41322. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41323. bindBuffers(vertexBuffers: {
  41324. [key: string]: VertexBuffer;
  41325. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41326. wipeCaches(bruteForce?: boolean): void;
  41327. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41328. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41329. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41330. /** @hidden */
  41331. _createTexture(): WebGLTexture;
  41332. /** @hidden */
  41333. _releaseTexture(texture: InternalTexture): void;
  41334. 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;
  41335. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41336. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41337. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41338. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41339. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41340. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41341. areAllEffectsReady(): boolean;
  41342. /**
  41343. * @hidden
  41344. * Get the current error code of the webGL context
  41345. * @returns the error code
  41346. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41347. */
  41348. getError(): number;
  41349. /** @hidden */
  41350. _getUnpackAlignement(): number;
  41351. /** @hidden */
  41352. _unpackFlipY(value: boolean): void;
  41353. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41354. /**
  41355. * Updates a dynamic vertex buffer.
  41356. * @param vertexBuffer the vertex buffer to update
  41357. * @param data the data used to update the vertex buffer
  41358. * @param byteOffset the byte offset of the data (optional)
  41359. * @param byteLength the byte length of the data (optional)
  41360. */
  41361. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41362. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41363. /** @hidden */
  41364. _bindTexture(channel: number, texture: InternalTexture): void;
  41365. /** @hidden */
  41366. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41367. releaseEffects(): void;
  41368. displayLoadingUI(): void;
  41369. hideLoadingUI(): void;
  41370. /** @hidden */
  41371. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41372. /** @hidden */
  41373. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41374. /** @hidden */
  41375. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41376. /** @hidden */
  41377. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41378. }
  41379. }
  41380. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41381. import { Nullable, int } from "babylonjs/types";
  41382. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41383. /** @hidden */
  41384. export class _OcclusionDataStorage {
  41385. /** @hidden */
  41386. occlusionInternalRetryCounter: number;
  41387. /** @hidden */
  41388. isOcclusionQueryInProgress: boolean;
  41389. /** @hidden */
  41390. isOccluded: boolean;
  41391. /** @hidden */
  41392. occlusionRetryCount: number;
  41393. /** @hidden */
  41394. occlusionType: number;
  41395. /** @hidden */
  41396. occlusionQueryAlgorithmType: number;
  41397. }
  41398. module "babylonjs/Engines/engine" {
  41399. interface Engine {
  41400. /**
  41401. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41402. * @return the new query
  41403. */
  41404. createQuery(): WebGLQuery;
  41405. /**
  41406. * Delete and release a webGL query
  41407. * @param query defines the query to delete
  41408. * @return the current engine
  41409. */
  41410. deleteQuery(query: WebGLQuery): Engine;
  41411. /**
  41412. * Check if a given query has resolved and got its value
  41413. * @param query defines the query to check
  41414. * @returns true if the query got its value
  41415. */
  41416. isQueryResultAvailable(query: WebGLQuery): boolean;
  41417. /**
  41418. * Gets the value of a given query
  41419. * @param query defines the query to check
  41420. * @returns the value of the query
  41421. */
  41422. getQueryResult(query: WebGLQuery): number;
  41423. /**
  41424. * Initiates an occlusion query
  41425. * @param algorithmType defines the algorithm to use
  41426. * @param query defines the query to use
  41427. * @returns the current engine
  41428. * @see http://doc.babylonjs.com/features/occlusionquery
  41429. */
  41430. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41431. /**
  41432. * Ends an occlusion query
  41433. * @see http://doc.babylonjs.com/features/occlusionquery
  41434. * @param algorithmType defines the algorithm to use
  41435. * @returns the current engine
  41436. */
  41437. endOcclusionQuery(algorithmType: number): Engine;
  41438. /**
  41439. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41440. * Please note that only one query can be issued at a time
  41441. * @returns a time token used to track the time span
  41442. */
  41443. startTimeQuery(): Nullable<_TimeToken>;
  41444. /**
  41445. * Ends a time query
  41446. * @param token defines the token used to measure the time span
  41447. * @returns the time spent (in ns)
  41448. */
  41449. endTimeQuery(token: _TimeToken): int;
  41450. /** @hidden */
  41451. _currentNonTimestampToken: Nullable<_TimeToken>;
  41452. /** @hidden */
  41453. _createTimeQuery(): WebGLQuery;
  41454. /** @hidden */
  41455. _deleteTimeQuery(query: WebGLQuery): void;
  41456. /** @hidden */
  41457. _getGlAlgorithmType(algorithmType: number): number;
  41458. /** @hidden */
  41459. _getTimeQueryResult(query: WebGLQuery): any;
  41460. /** @hidden */
  41461. _getTimeQueryAvailability(query: WebGLQuery): any;
  41462. }
  41463. }
  41464. module "babylonjs/Meshes/abstractMesh" {
  41465. interface AbstractMesh {
  41466. /**
  41467. * Backing filed
  41468. * @hidden
  41469. */
  41470. __occlusionDataStorage: _OcclusionDataStorage;
  41471. /**
  41472. * Access property
  41473. * @hidden
  41474. */
  41475. _occlusionDataStorage: _OcclusionDataStorage;
  41476. /**
  41477. * 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.
  41478. * The default value is -1 which means don't break the query and wait till the result
  41479. * @see http://doc.babylonjs.com/features/occlusionquery
  41480. */
  41481. occlusionRetryCount: number;
  41482. /**
  41483. * 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:
  41484. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41485. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41486. * * 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.
  41487. * @see http://doc.babylonjs.com/features/occlusionquery
  41488. */
  41489. occlusionType: number;
  41490. /**
  41491. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41492. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41493. * * 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.
  41494. * @see http://doc.babylonjs.com/features/occlusionquery
  41495. */
  41496. occlusionQueryAlgorithmType: number;
  41497. /**
  41498. * 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
  41499. * @see http://doc.babylonjs.com/features/occlusionquery
  41500. */
  41501. isOccluded: boolean;
  41502. /**
  41503. * Flag to check the progress status of the query
  41504. * @see http://doc.babylonjs.com/features/occlusionquery
  41505. */
  41506. isOcclusionQueryInProgress: boolean;
  41507. }
  41508. }
  41509. }
  41510. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41511. import { Nullable } from "babylonjs/types";
  41512. /** @hidden */
  41513. export var _forceTransformFeedbackToBundle: boolean;
  41514. module "babylonjs/Engines/engine" {
  41515. interface Engine {
  41516. /**
  41517. * Creates a webGL transform feedback object
  41518. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41519. * @returns the webGL transform feedback object
  41520. */
  41521. createTransformFeedback(): WebGLTransformFeedback;
  41522. /**
  41523. * Delete a webGL transform feedback object
  41524. * @param value defines the webGL transform feedback object to delete
  41525. */
  41526. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41527. /**
  41528. * Bind a webGL transform feedback object to the webgl context
  41529. * @param value defines the webGL transform feedback object to bind
  41530. */
  41531. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41532. /**
  41533. * Begins a transform feedback operation
  41534. * @param usePoints defines if points or triangles must be used
  41535. */
  41536. beginTransformFeedback(usePoints: boolean): void;
  41537. /**
  41538. * Ends a transform feedback operation
  41539. */
  41540. endTransformFeedback(): void;
  41541. /**
  41542. * Specify the varyings to use with transform feedback
  41543. * @param program defines the associated webGL program
  41544. * @param value defines the list of strings representing the varying names
  41545. */
  41546. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41547. /**
  41548. * Bind a webGL buffer for a transform feedback operation
  41549. * @param value defines the webGL buffer to bind
  41550. */
  41551. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41552. }
  41553. }
  41554. }
  41555. declare module "babylonjs/Engines/Extensions/index" {
  41556. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41557. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41558. }
  41559. declare module "babylonjs/Engines/index" {
  41560. export * from "babylonjs/Engines/constants";
  41561. export * from "babylonjs/Engines/engine";
  41562. export * from "babylonjs/Engines/engineStore";
  41563. export * from "babylonjs/Engines/nullEngine";
  41564. export * from "babylonjs/Engines/Extensions/index";
  41565. }
  41566. declare module "babylonjs/Events/clipboardEvents" {
  41567. /**
  41568. * Gather the list of clipboard event types as constants.
  41569. */
  41570. export class ClipboardEventTypes {
  41571. /**
  41572. * The clipboard event is fired when a copy command is active (pressed).
  41573. */
  41574. static readonly COPY: number;
  41575. /**
  41576. * The clipboard event is fired when a cut command is active (pressed).
  41577. */
  41578. static readonly CUT: number;
  41579. /**
  41580. * The clipboard event is fired when a paste command is active (pressed).
  41581. */
  41582. static readonly PASTE: number;
  41583. }
  41584. /**
  41585. * This class is used to store clipboard related info for the onClipboardObservable event.
  41586. */
  41587. export class ClipboardInfo {
  41588. /**
  41589. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41590. */
  41591. type: number;
  41592. /**
  41593. * Defines the related dom event
  41594. */
  41595. event: ClipboardEvent;
  41596. /**
  41597. *Creates an instance of ClipboardInfo.
  41598. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41599. * @param event Defines the related dom event
  41600. */
  41601. constructor(
  41602. /**
  41603. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41604. */
  41605. type: number,
  41606. /**
  41607. * Defines the related dom event
  41608. */
  41609. event: ClipboardEvent);
  41610. /**
  41611. * Get the clipboard event's type from the keycode.
  41612. * @param keyCode Defines the keyCode for the current keyboard event.
  41613. * @return {number}
  41614. */
  41615. static GetTypeFromCharacter(keyCode: number): number;
  41616. }
  41617. }
  41618. declare module "babylonjs/Events/index" {
  41619. export * from "babylonjs/Events/keyboardEvents";
  41620. export * from "babylonjs/Events/pointerEvents";
  41621. export * from "babylonjs/Events/clipboardEvents";
  41622. }
  41623. declare module "babylonjs/Loading/sceneLoader" {
  41624. import { Observable } from "babylonjs/Misc/observable";
  41625. import { Nullable } from "babylonjs/types";
  41626. import { Scene } from "babylonjs/scene";
  41627. import { Engine } from "babylonjs/Engines/engine";
  41628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41629. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41630. import { AssetContainer } from "babylonjs/assetContainer";
  41631. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41632. import { Skeleton } from "babylonjs/Bones/skeleton";
  41633. /**
  41634. * Class used to represent data loading progression
  41635. */
  41636. export class SceneLoaderProgressEvent {
  41637. /** defines if data length to load can be evaluated */
  41638. readonly lengthComputable: boolean;
  41639. /** defines the loaded data length */
  41640. readonly loaded: number;
  41641. /** defines the data length to load */
  41642. readonly total: number;
  41643. /**
  41644. * Create a new progress event
  41645. * @param lengthComputable defines if data length to load can be evaluated
  41646. * @param loaded defines the loaded data length
  41647. * @param total defines the data length to load
  41648. */
  41649. constructor(
  41650. /** defines if data length to load can be evaluated */
  41651. lengthComputable: boolean,
  41652. /** defines the loaded data length */
  41653. loaded: number,
  41654. /** defines the data length to load */
  41655. total: number);
  41656. /**
  41657. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41658. * @param event defines the source event
  41659. * @returns a new SceneLoaderProgressEvent
  41660. */
  41661. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41662. }
  41663. /**
  41664. * Interface used by SceneLoader plugins to define supported file extensions
  41665. */
  41666. export interface ISceneLoaderPluginExtensions {
  41667. /**
  41668. * Defines the list of supported extensions
  41669. */
  41670. [extension: string]: {
  41671. isBinary: boolean;
  41672. };
  41673. }
  41674. /**
  41675. * Interface used by SceneLoader plugin factory
  41676. */
  41677. export interface ISceneLoaderPluginFactory {
  41678. /**
  41679. * Defines the name of the factory
  41680. */
  41681. name: string;
  41682. /**
  41683. * Function called to create a new plugin
  41684. * @return the new plugin
  41685. */
  41686. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41687. /**
  41688. * Boolean indicating if the plugin can direct load specific data
  41689. */
  41690. canDirectLoad?: (data: string) => boolean;
  41691. }
  41692. /**
  41693. * Interface used to define a SceneLoader plugin
  41694. */
  41695. export interface ISceneLoaderPlugin {
  41696. /**
  41697. * The friendly name of this plugin.
  41698. */
  41699. name: string;
  41700. /**
  41701. * The file extensions supported by this plugin.
  41702. */
  41703. extensions: string | ISceneLoaderPluginExtensions;
  41704. /**
  41705. * Import meshes into a scene.
  41706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41707. * @param scene The scene to import into
  41708. * @param data The data to import
  41709. * @param rootUrl The root url for scene and resources
  41710. * @param meshes The meshes array to import into
  41711. * @param particleSystems The particle systems array to import into
  41712. * @param skeletons The skeletons array to import into
  41713. * @param onError The callback when import fails
  41714. * @returns True if successful or false otherwise
  41715. */
  41716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41717. /**
  41718. * Load into a scene.
  41719. * @param scene The scene to load into
  41720. * @param data The data to import
  41721. * @param rootUrl The root url for scene and resources
  41722. * @param onError The callback when import fails
  41723. * @returns true if successful or false otherwise
  41724. */
  41725. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41726. /**
  41727. * The callback that returns true if the data can be directly loaded.
  41728. */
  41729. canDirectLoad?: (data: string) => boolean;
  41730. /**
  41731. * The callback that allows custom handling of the root url based on the response url.
  41732. */
  41733. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41734. /**
  41735. * Load into an asset container.
  41736. * @param scene The scene to load into
  41737. * @param data The data to import
  41738. * @param rootUrl The root url for scene and resources
  41739. * @param onError The callback when import fails
  41740. * @returns The loaded asset container
  41741. */
  41742. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41743. }
  41744. /**
  41745. * Interface used to define an async SceneLoader plugin
  41746. */
  41747. export interface ISceneLoaderPluginAsync {
  41748. /**
  41749. * The friendly name of this plugin.
  41750. */
  41751. name: string;
  41752. /**
  41753. * The file extensions supported by this plugin.
  41754. */
  41755. extensions: string | ISceneLoaderPluginExtensions;
  41756. /**
  41757. * Import meshes into a scene.
  41758. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41759. * @param scene The scene to import into
  41760. * @param data The data to import
  41761. * @param rootUrl The root url for scene and resources
  41762. * @param onProgress The callback when the load progresses
  41763. * @param fileName Defines the name of the file to load
  41764. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41765. */
  41766. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41767. meshes: AbstractMesh[];
  41768. particleSystems: IParticleSystem[];
  41769. skeletons: Skeleton[];
  41770. animationGroups: AnimationGroup[];
  41771. }>;
  41772. /**
  41773. * Load into a scene.
  41774. * @param scene The scene to load into
  41775. * @param data The data to import
  41776. * @param rootUrl The root url for scene and resources
  41777. * @param onProgress The callback when the load progresses
  41778. * @param fileName Defines the name of the file to load
  41779. * @returns Nothing
  41780. */
  41781. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41782. /**
  41783. * The callback that returns true if the data can be directly loaded.
  41784. */
  41785. canDirectLoad?: (data: string) => boolean;
  41786. /**
  41787. * The callback that allows custom handling of the root url based on the response url.
  41788. */
  41789. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41790. /**
  41791. * Load into an asset container.
  41792. * @param scene The scene to load into
  41793. * @param data The data to import
  41794. * @param rootUrl The root url for scene and resources
  41795. * @param onProgress The callback when the load progresses
  41796. * @param fileName Defines the name of the file to load
  41797. * @returns The loaded asset container
  41798. */
  41799. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41800. }
  41801. /**
  41802. * Class used to load scene from various file formats using registered plugins
  41803. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41804. */
  41805. export class SceneLoader {
  41806. /**
  41807. * No logging while loading
  41808. */
  41809. static readonly NO_LOGGING: number;
  41810. /**
  41811. * Minimal logging while loading
  41812. */
  41813. static readonly MINIMAL_LOGGING: number;
  41814. /**
  41815. * Summary logging while loading
  41816. */
  41817. static readonly SUMMARY_LOGGING: number;
  41818. /**
  41819. * Detailled logging while loading
  41820. */
  41821. static readonly DETAILED_LOGGING: number;
  41822. /**
  41823. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41824. */
  41825. static ForceFullSceneLoadingForIncremental: boolean;
  41826. /**
  41827. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41828. */
  41829. static ShowLoadingScreen: boolean;
  41830. /**
  41831. * Defines the current logging level (while loading the scene)
  41832. * @ignorenaming
  41833. */
  41834. static loggingLevel: number;
  41835. /**
  41836. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41837. */
  41838. static CleanBoneMatrixWeights: boolean;
  41839. /**
  41840. * Event raised when a plugin is used to load a scene
  41841. */
  41842. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41843. private static _registeredPlugins;
  41844. private static _getDefaultPlugin;
  41845. private static _getPluginForExtension;
  41846. private static _getPluginForDirectLoad;
  41847. private static _getPluginForFilename;
  41848. private static _getDirectLoad;
  41849. private static _loadData;
  41850. private static _getFileInfo;
  41851. /**
  41852. * Gets a plugin that can load the given extension
  41853. * @param extension defines the extension to load
  41854. * @returns a plugin or null if none works
  41855. */
  41856. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41857. /**
  41858. * Gets a boolean indicating that the given extension can be loaded
  41859. * @param extension defines the extension to load
  41860. * @returns true if the extension is supported
  41861. */
  41862. static IsPluginForExtensionAvailable(extension: string): boolean;
  41863. /**
  41864. * Adds a new plugin to the list of registered plugins
  41865. * @param plugin defines the plugin to add
  41866. */
  41867. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41868. /**
  41869. * Import meshes into a scene
  41870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41871. * @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)
  41872. * @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)
  41873. * @param scene the instance of BABYLON.Scene to append to
  41874. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41875. * @param onProgress a callback with a progress event for each file being loaded
  41876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41877. * @param pluginExtension the extension used to determine the plugin
  41878. * @returns The loaded plugin
  41879. */
  41880. 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>;
  41881. /**
  41882. * Import meshes into a scene
  41883. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41884. * @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)
  41885. * @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)
  41886. * @param scene the instance of BABYLON.Scene to append to
  41887. * @param onProgress a callback with a progress event for each file being loaded
  41888. * @param pluginExtension the extension used to determine the plugin
  41889. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41890. */
  41891. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41892. meshes: AbstractMesh[];
  41893. particleSystems: IParticleSystem[];
  41894. skeletons: Skeleton[];
  41895. animationGroups: AnimationGroup[];
  41896. }>;
  41897. /**
  41898. * Load a scene
  41899. * @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)
  41900. * @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)
  41901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41902. * @param onSuccess a callback with the scene when import succeeds
  41903. * @param onProgress a callback with a progress event for each file being loaded
  41904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41905. * @param pluginExtension the extension used to determine the plugin
  41906. * @returns The loaded plugin
  41907. */
  41908. 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>;
  41909. /**
  41910. * Load a scene
  41911. * @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)
  41912. * @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)
  41913. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41914. * @param onProgress a callback with a progress event for each file being loaded
  41915. * @param pluginExtension the extension used to determine the plugin
  41916. * @returns The loaded scene
  41917. */
  41918. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41919. /**
  41920. * Append a scene
  41921. * @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)
  41922. * @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)
  41923. * @param scene is the instance of BABYLON.Scene to append to
  41924. * @param onSuccess a callback with the scene when import succeeds
  41925. * @param onProgress a callback with a progress event for each file being loaded
  41926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41927. * @param pluginExtension the extension used to determine the plugin
  41928. * @returns The loaded plugin
  41929. */
  41930. 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>;
  41931. /**
  41932. * Append a scene
  41933. * @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)
  41934. * @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)
  41935. * @param scene is the instance of BABYLON.Scene to append to
  41936. * @param onProgress a callback with a progress event for each file being loaded
  41937. * @param pluginExtension the extension used to determine the plugin
  41938. * @returns The given scene
  41939. */
  41940. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41941. /**
  41942. * Load a scene into an asset container
  41943. * @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)
  41944. * @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)
  41945. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41946. * @param onSuccess a callback with the scene when import succeeds
  41947. * @param onProgress a callback with a progress event for each file being loaded
  41948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41949. * @param pluginExtension the extension used to determine the plugin
  41950. * @returns The loaded plugin
  41951. */
  41952. 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>;
  41953. /**
  41954. * Load a scene into an asset container
  41955. * @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)
  41956. * @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)
  41957. * @param scene is the instance of Scene to append to
  41958. * @param onProgress a callback with a progress event for each file being loaded
  41959. * @param pluginExtension the extension used to determine the plugin
  41960. * @returns The loaded asset container
  41961. */
  41962. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41963. }
  41964. }
  41965. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  41966. import { Scene } from "babylonjs/scene";
  41967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41968. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  41969. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41970. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  41971. /**
  41972. * Google Daydream controller
  41973. */
  41974. export class DaydreamController extends WebVRController {
  41975. /**
  41976. * Base Url for the controller model.
  41977. */
  41978. static MODEL_BASE_URL: string;
  41979. /**
  41980. * File name for the controller model.
  41981. */
  41982. static MODEL_FILENAME: string;
  41983. /**
  41984. * Gamepad Id prefix used to identify Daydream Controller.
  41985. */
  41986. static readonly GAMEPAD_ID_PREFIX: string;
  41987. /**
  41988. * Creates a new DaydreamController from a gamepad
  41989. * @param vrGamepad the gamepad that the controller should be created from
  41990. */
  41991. constructor(vrGamepad: any);
  41992. /**
  41993. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41994. * @param scene scene in which to add meshes
  41995. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41996. */
  41997. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41998. /**
  41999. * Called once for each button that changed state since the last frame
  42000. * @param buttonIdx Which button index changed
  42001. * @param state New state of the button
  42002. * @param changes Which properties on the state changed since last frame
  42003. */
  42004. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42005. }
  42006. }
  42007. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42008. import { Scene } from "babylonjs/scene";
  42009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42010. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42011. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42012. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42013. /**
  42014. * Gear VR Controller
  42015. */
  42016. export class GearVRController extends WebVRController {
  42017. /**
  42018. * Base Url for the controller model.
  42019. */
  42020. static MODEL_BASE_URL: string;
  42021. /**
  42022. * File name for the controller model.
  42023. */
  42024. static MODEL_FILENAME: string;
  42025. /**
  42026. * Gamepad Id prefix used to identify this controller.
  42027. */
  42028. static readonly GAMEPAD_ID_PREFIX: string;
  42029. private readonly _buttonIndexToObservableNameMap;
  42030. /**
  42031. * Creates a new GearVRController from a gamepad
  42032. * @param vrGamepad the gamepad that the controller should be created from
  42033. */
  42034. constructor(vrGamepad: any);
  42035. /**
  42036. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42037. * @param scene scene in which to add meshes
  42038. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42039. */
  42040. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42041. /**
  42042. * Called once for each button that changed state since the last frame
  42043. * @param buttonIdx Which button index changed
  42044. * @param state New state of the button
  42045. * @param changes Which properties on the state changed since last frame
  42046. */
  42047. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42048. }
  42049. }
  42050. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42051. import { Scene } from "babylonjs/scene";
  42052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42053. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42054. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42055. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42056. /**
  42057. * Generic Controller
  42058. */
  42059. export class GenericController extends WebVRController {
  42060. /**
  42061. * Base Url for the controller model.
  42062. */
  42063. static readonly MODEL_BASE_URL: string;
  42064. /**
  42065. * File name for the controller model.
  42066. */
  42067. static readonly MODEL_FILENAME: string;
  42068. /**
  42069. * Creates a new GenericController from a gamepad
  42070. * @param vrGamepad the gamepad that the controller should be created from
  42071. */
  42072. constructor(vrGamepad: any);
  42073. /**
  42074. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42075. * @param scene scene in which to add meshes
  42076. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42077. */
  42078. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42079. /**
  42080. * Called once for each button that changed state since the last frame
  42081. * @param buttonIdx Which button index changed
  42082. * @param state New state of the button
  42083. * @param changes Which properties on the state changed since last frame
  42084. */
  42085. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42086. }
  42087. }
  42088. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42089. import { Observable } from "babylonjs/Misc/observable";
  42090. import { Scene } from "babylonjs/scene";
  42091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42092. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42093. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42094. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42095. /**
  42096. * Oculus Touch Controller
  42097. */
  42098. export class OculusTouchController extends WebVRController {
  42099. /**
  42100. * Base Url for the controller model.
  42101. */
  42102. static MODEL_BASE_URL: string;
  42103. /**
  42104. * File name for the left controller model.
  42105. */
  42106. static MODEL_LEFT_FILENAME: string;
  42107. /**
  42108. * File name for the right controller model.
  42109. */
  42110. static MODEL_RIGHT_FILENAME: string;
  42111. /**
  42112. * Fired when the secondary trigger on this controller is modified
  42113. */
  42114. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42115. /**
  42116. * Fired when the thumb rest on this controller is modified
  42117. */
  42118. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42119. /**
  42120. * Creates a new OculusTouchController from a gamepad
  42121. * @param vrGamepad the gamepad that the controller should be created from
  42122. */
  42123. constructor(vrGamepad: any);
  42124. /**
  42125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42126. * @param scene scene in which to add meshes
  42127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42128. */
  42129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42130. /**
  42131. * Fired when the A button on this controller is modified
  42132. */
  42133. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42134. /**
  42135. * Fired when the B button on this controller is modified
  42136. */
  42137. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42138. /**
  42139. * Fired when the X button on this controller is modified
  42140. */
  42141. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42142. /**
  42143. * Fired when the Y button on this controller is modified
  42144. */
  42145. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42146. /**
  42147. * Called once for each button that changed state since the last frame
  42148. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42149. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42150. * 2) secondary trigger (same)
  42151. * 3) A (right) X (left), touch, pressed = value
  42152. * 4) B / Y
  42153. * 5) thumb rest
  42154. * @param buttonIdx Which button index changed
  42155. * @param state New state of the button
  42156. * @param changes Which properties on the state changed since last frame
  42157. */
  42158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42159. }
  42160. }
  42161. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42162. import { Scene } from "babylonjs/scene";
  42163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42164. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42165. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42166. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42167. import { Observable } from "babylonjs/Misc/observable";
  42168. /**
  42169. * Vive Controller
  42170. */
  42171. export class ViveController extends WebVRController {
  42172. /**
  42173. * Base Url for the controller model.
  42174. */
  42175. static MODEL_BASE_URL: string;
  42176. /**
  42177. * File name for the controller model.
  42178. */
  42179. static MODEL_FILENAME: string;
  42180. /**
  42181. * Creates a new ViveController from a gamepad
  42182. * @param vrGamepad the gamepad that the controller should be created from
  42183. */
  42184. constructor(vrGamepad: any);
  42185. /**
  42186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42187. * @param scene scene in which to add meshes
  42188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42189. */
  42190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42191. /**
  42192. * Fired when the left button on this controller is modified
  42193. */
  42194. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42195. /**
  42196. * Fired when the right button on this controller is modified
  42197. */
  42198. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42199. /**
  42200. * Fired when the menu button on this controller is modified
  42201. */
  42202. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42203. /**
  42204. * Called once for each button that changed state since the last frame
  42205. * Vive mapping:
  42206. * 0: touchpad
  42207. * 1: trigger
  42208. * 2: left AND right buttons
  42209. * 3: menu button
  42210. * @param buttonIdx Which button index changed
  42211. * @param state New state of the button
  42212. * @param changes Which properties on the state changed since last frame
  42213. */
  42214. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42215. }
  42216. }
  42217. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42218. import { Observable } from "babylonjs/Misc/observable";
  42219. import { Scene } from "babylonjs/scene";
  42220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42221. import { Ray } from "babylonjs/Culling/ray";
  42222. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42223. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42224. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42225. /**
  42226. * Defines the WindowsMotionController object that the state of the windows motion controller
  42227. */
  42228. export class WindowsMotionController extends WebVRController {
  42229. /**
  42230. * The base url used to load the left and right controller models
  42231. */
  42232. static MODEL_BASE_URL: string;
  42233. /**
  42234. * The name of the left controller model file
  42235. */
  42236. static MODEL_LEFT_FILENAME: string;
  42237. /**
  42238. * The name of the right controller model file
  42239. */
  42240. static MODEL_RIGHT_FILENAME: string;
  42241. /**
  42242. * The controller name prefix for this controller type
  42243. */
  42244. static readonly GAMEPAD_ID_PREFIX: string;
  42245. /**
  42246. * The controller id pattern for this controller type
  42247. */
  42248. private static readonly GAMEPAD_ID_PATTERN;
  42249. private _loadedMeshInfo;
  42250. private readonly _mapping;
  42251. /**
  42252. * Fired when the trackpad on this controller is clicked
  42253. */
  42254. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42255. /**
  42256. * Fired when the trackpad on this controller is modified
  42257. */
  42258. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42259. /**
  42260. * The current x and y values of this controller's trackpad
  42261. */
  42262. trackpad: StickValues;
  42263. /**
  42264. * Creates a new WindowsMotionController from a gamepad
  42265. * @param vrGamepad the gamepad that the controller should be created from
  42266. */
  42267. constructor(vrGamepad: any);
  42268. /**
  42269. * Fired when the trigger on this controller is modified
  42270. */
  42271. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42272. /**
  42273. * Fired when the menu button on this controller is modified
  42274. */
  42275. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42276. /**
  42277. * Fired when the grip button on this controller is modified
  42278. */
  42279. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42280. /**
  42281. * Fired when the thumbstick button on this controller is modified
  42282. */
  42283. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42284. /**
  42285. * Fired when the touchpad button on this controller is modified
  42286. */
  42287. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42288. /**
  42289. * Fired when the touchpad values on this controller are modified
  42290. */
  42291. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42292. private _updateTrackpad;
  42293. /**
  42294. * Called once per frame by the engine.
  42295. */
  42296. update(): void;
  42297. /**
  42298. * Called once for each button that changed state since the last frame
  42299. * @param buttonIdx Which button index changed
  42300. * @param state New state of the button
  42301. * @param changes Which properties on the state changed since last frame
  42302. */
  42303. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42304. /**
  42305. * Moves the buttons on the controller mesh based on their current state
  42306. * @param buttonName the name of the button to move
  42307. * @param buttonValue the value of the button which determines the buttons new position
  42308. */
  42309. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42310. /**
  42311. * Moves the axis on the controller mesh based on its current state
  42312. * @param axis the index of the axis
  42313. * @param axisValue the value of the axis which determines the meshes new position
  42314. * @hidden
  42315. */
  42316. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42317. /**
  42318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42319. * @param scene scene in which to add meshes
  42320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42321. */
  42322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42323. /**
  42324. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42325. * can be transformed by button presses and axes values, based on this._mapping.
  42326. *
  42327. * @param scene scene in which the meshes exist
  42328. * @param meshes list of meshes that make up the controller model to process
  42329. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42330. */
  42331. private processModel;
  42332. private createMeshInfo;
  42333. /**
  42334. * Gets the ray of the controller in the direction the controller is pointing
  42335. * @param length the length the resulting ray should be
  42336. * @returns a ray in the direction the controller is pointing
  42337. */
  42338. getForwardRay(length?: number): Ray;
  42339. /**
  42340. * Disposes of the controller
  42341. */
  42342. dispose(): void;
  42343. }
  42344. }
  42345. declare module "babylonjs/Gamepads/Controllers/index" {
  42346. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42347. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42348. export * from "babylonjs/Gamepads/Controllers/genericController";
  42349. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42350. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42351. export * from "babylonjs/Gamepads/Controllers/viveController";
  42352. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42353. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42354. }
  42355. declare module "babylonjs/Gamepads/gamepadManager" {
  42356. import { Observable } from "babylonjs/Misc/observable";
  42357. import { Nullable } from "babylonjs/types";
  42358. import { Scene } from "babylonjs/scene";
  42359. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42360. /**
  42361. * Manager for handling gamepads
  42362. */
  42363. export class GamepadManager {
  42364. private _scene?;
  42365. private _babylonGamepads;
  42366. private _oneGamepadConnected;
  42367. /** @hidden */
  42368. _isMonitoring: boolean;
  42369. private _gamepadEventSupported;
  42370. private _gamepadSupport;
  42371. /**
  42372. * observable to be triggered when the gamepad controller has been connected
  42373. */
  42374. onGamepadConnectedObservable: Observable<Gamepad>;
  42375. /**
  42376. * observable to be triggered when the gamepad controller has been disconnected
  42377. */
  42378. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42379. private _onGamepadConnectedEvent;
  42380. private _onGamepadDisconnectedEvent;
  42381. /**
  42382. * Initializes the gamepad manager
  42383. * @param _scene BabylonJS scene
  42384. */
  42385. constructor(_scene?: Scene | undefined);
  42386. /**
  42387. * The gamepads in the game pad manager
  42388. */
  42389. readonly gamepads: Gamepad[];
  42390. /**
  42391. * Get the gamepad controllers based on type
  42392. * @param type The type of gamepad controller
  42393. * @returns Nullable gamepad
  42394. */
  42395. getGamepadByType(type?: number): Nullable<Gamepad>;
  42396. /**
  42397. * Disposes the gamepad manager
  42398. */
  42399. dispose(): void;
  42400. private _addNewGamepad;
  42401. private _startMonitoringGamepads;
  42402. private _stopMonitoringGamepads;
  42403. /** @hidden */
  42404. _checkGamepadsStatus(): void;
  42405. private _updateGamepadObjects;
  42406. }
  42407. }
  42408. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42409. import { Nullable } from "babylonjs/types";
  42410. import { Scene } from "babylonjs/scene";
  42411. import { ISceneComponent } from "babylonjs/sceneComponent";
  42412. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42413. module "babylonjs/scene" {
  42414. interface Scene {
  42415. /** @hidden */
  42416. _gamepadManager: Nullable<GamepadManager>;
  42417. /**
  42418. * Gets the gamepad manager associated with the scene
  42419. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42420. */
  42421. gamepadManager: GamepadManager;
  42422. }
  42423. }
  42424. module "babylonjs/Cameras/freeCameraInputsManager" {
  42425. /**
  42426. * Interface representing a free camera inputs manager
  42427. */
  42428. interface FreeCameraInputsManager {
  42429. /**
  42430. * Adds gamepad input support to the FreeCameraInputsManager.
  42431. * @returns the FreeCameraInputsManager
  42432. */
  42433. addGamepad(): FreeCameraInputsManager;
  42434. }
  42435. }
  42436. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42437. /**
  42438. * Interface representing an arc rotate camera inputs manager
  42439. */
  42440. interface ArcRotateCameraInputsManager {
  42441. /**
  42442. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42443. * @returns the camera inputs manager
  42444. */
  42445. addGamepad(): ArcRotateCameraInputsManager;
  42446. }
  42447. }
  42448. /**
  42449. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42450. */
  42451. export class GamepadSystemSceneComponent implements ISceneComponent {
  42452. /**
  42453. * The component name helpfull to identify the component in the list of scene components.
  42454. */
  42455. readonly name: string;
  42456. /**
  42457. * The scene the component belongs to.
  42458. */
  42459. scene: Scene;
  42460. /**
  42461. * Creates a new instance of the component for the given scene
  42462. * @param scene Defines the scene to register the component in
  42463. */
  42464. constructor(scene: Scene);
  42465. /**
  42466. * Registers the component in a given scene
  42467. */
  42468. register(): void;
  42469. /**
  42470. * Rebuilds the elements related to this component in case of
  42471. * context lost for instance.
  42472. */
  42473. rebuild(): void;
  42474. /**
  42475. * Disposes the component and the associated ressources
  42476. */
  42477. dispose(): void;
  42478. private _beforeCameraUpdate;
  42479. }
  42480. }
  42481. declare module "babylonjs/Gamepads/index" {
  42482. export * from "babylonjs/Gamepads/Controllers/index";
  42483. export * from "babylonjs/Gamepads/gamepad";
  42484. export * from "babylonjs/Gamepads/gamepadManager";
  42485. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42486. export * from "babylonjs/Gamepads/xboxGamepad";
  42487. }
  42488. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42489. import { Observable } from "babylonjs/Misc/observable";
  42490. import { Nullable } from "babylonjs/types";
  42491. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42493. import { Mesh } from "babylonjs/Meshes/mesh";
  42494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42497. /**
  42498. * Single axis scale gizmo
  42499. */
  42500. export class AxisScaleGizmo extends Gizmo {
  42501. private _coloredMaterial;
  42502. /**
  42503. * Drag behavior responsible for the gizmos dragging interactions
  42504. */
  42505. dragBehavior: PointerDragBehavior;
  42506. private _pointerObserver;
  42507. /**
  42508. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42509. */
  42510. snapDistance: number;
  42511. /**
  42512. * Event that fires each time the gizmo snaps to a new location.
  42513. * * snapDistance is the the change in distance
  42514. */
  42515. onSnapObservable: Observable<{
  42516. snapDistance: number;
  42517. }>;
  42518. /**
  42519. * If the scaling operation should be done on all axis (default: false)
  42520. */
  42521. uniformScaling: boolean;
  42522. /**
  42523. * Creates an AxisScaleGizmo
  42524. * @param gizmoLayer The utility layer the gizmo will be added to
  42525. * @param dragAxis The axis which the gizmo will be able to scale on
  42526. * @param color The color of the gizmo
  42527. */
  42528. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42530. /**
  42531. * Disposes of the gizmo
  42532. */
  42533. dispose(): void;
  42534. /**
  42535. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42536. * @param mesh The mesh to replace the default mesh of the gizmo
  42537. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42538. */
  42539. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42540. }
  42541. }
  42542. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42543. import { Observable } from "babylonjs/Misc/observable";
  42544. import { Nullable } from "babylonjs/types";
  42545. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42547. import { Mesh } from "babylonjs/Meshes/mesh";
  42548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42549. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42550. import "babylonjs/Meshes/Builders/boxBuilder";
  42551. /**
  42552. * Bounding box gizmo
  42553. */
  42554. export class BoundingBoxGizmo extends Gizmo {
  42555. private _lineBoundingBox;
  42556. private _rotateSpheresParent;
  42557. private _scaleBoxesParent;
  42558. private _boundingDimensions;
  42559. private _renderObserver;
  42560. private _pointerObserver;
  42561. private _scaleDragSpeed;
  42562. private _tmpQuaternion;
  42563. private _tmpVector;
  42564. private _tmpRotationMatrix;
  42565. /**
  42566. * 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)
  42567. */
  42568. ignoreChildren: boolean;
  42569. /**
  42570. * 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)
  42571. */
  42572. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42573. /**
  42574. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42575. */
  42576. rotationSphereSize: number;
  42577. /**
  42578. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42579. */
  42580. scaleBoxSize: number;
  42581. /**
  42582. * 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)
  42583. */
  42584. fixedDragMeshScreenSize: boolean;
  42585. /**
  42586. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42587. */
  42588. fixedDragMeshScreenSizeDistanceFactor: number;
  42589. /**
  42590. * Fired when a rotation sphere or scale box is dragged
  42591. */
  42592. onDragStartObservable: Observable<{}>;
  42593. /**
  42594. * Fired when a scale box is dragged
  42595. */
  42596. onScaleBoxDragObservable: Observable<{}>;
  42597. /**
  42598. * Fired when a scale box drag is ended
  42599. */
  42600. onScaleBoxDragEndObservable: Observable<{}>;
  42601. /**
  42602. * Fired when a rotation sphere is dragged
  42603. */
  42604. onRotationSphereDragObservable: Observable<{}>;
  42605. /**
  42606. * Fired when a rotation sphere drag is ended
  42607. */
  42608. onRotationSphereDragEndObservable: Observable<{}>;
  42609. /**
  42610. * 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)
  42611. */
  42612. scalePivot: Nullable<Vector3>;
  42613. private _anchorMesh;
  42614. private _existingMeshScale;
  42615. private _dragMesh;
  42616. private pointerDragBehavior;
  42617. /**
  42618. * Creates an BoundingBoxGizmo
  42619. * @param gizmoLayer The utility layer the gizmo will be added to
  42620. * @param color The color of the gizmo
  42621. */
  42622. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42624. private _selectNode;
  42625. /**
  42626. * Updates the bounding box information for the Gizmo
  42627. */
  42628. updateBoundingBox(): void;
  42629. private _updateRotationSpheres;
  42630. private _updateScaleBoxes;
  42631. /**
  42632. * Enables rotation on the specified axis and disables rotation on the others
  42633. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42634. */
  42635. setEnabledRotationAxis(axis: string): void;
  42636. /**
  42637. * Enables/disables scaling
  42638. * @param enable if scaling should be enabled
  42639. */
  42640. setEnabledScaling(enable: boolean): void;
  42641. private _updateDummy;
  42642. /**
  42643. * Enables a pointer drag behavior on the bounding box of the gizmo
  42644. */
  42645. enableDragBehavior(): void;
  42646. /**
  42647. * Disposes of the gizmo
  42648. */
  42649. dispose(): void;
  42650. /**
  42651. * 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)
  42652. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42653. * @returns the bounding box mesh with the passed in mesh as a child
  42654. */
  42655. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42656. /**
  42657. * CustomMeshes are not supported by this gizmo
  42658. * @param mesh The mesh to replace the default mesh of the gizmo
  42659. */
  42660. setCustomMesh(mesh: Mesh): void;
  42661. }
  42662. }
  42663. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42664. import { Observable } from "babylonjs/Misc/observable";
  42665. import { Nullable } from "babylonjs/types";
  42666. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42668. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42669. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42670. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42671. import "babylonjs/Meshes/Builders/linesBuilder";
  42672. /**
  42673. * Single plane rotation gizmo
  42674. */
  42675. export class PlaneRotationGizmo extends Gizmo {
  42676. /**
  42677. * Drag behavior responsible for the gizmos dragging interactions
  42678. */
  42679. dragBehavior: PointerDragBehavior;
  42680. private _pointerObserver;
  42681. /**
  42682. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42683. */
  42684. snapDistance: number;
  42685. /**
  42686. * Event that fires each time the gizmo snaps to a new location.
  42687. * * snapDistance is the the change in distance
  42688. */
  42689. onSnapObservable: Observable<{
  42690. snapDistance: number;
  42691. }>;
  42692. /**
  42693. * Creates a PlaneRotationGizmo
  42694. * @param gizmoLayer The utility layer the gizmo will be added to
  42695. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42696. * @param color The color of the gizmo
  42697. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42698. */
  42699. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42700. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42701. /**
  42702. * Disposes of the gizmo
  42703. */
  42704. dispose(): void;
  42705. }
  42706. }
  42707. declare module "babylonjs/Gizmos/rotationGizmo" {
  42708. import { Observable } from "babylonjs/Misc/observable";
  42709. import { Nullable } from "babylonjs/types";
  42710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42711. import { Mesh } from "babylonjs/Meshes/mesh";
  42712. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42713. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42714. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42715. /**
  42716. * Gizmo that enables rotating a mesh along 3 axis
  42717. */
  42718. export class RotationGizmo extends Gizmo {
  42719. /**
  42720. * Internal gizmo used for interactions on the x axis
  42721. */
  42722. xGizmo: PlaneRotationGizmo;
  42723. /**
  42724. * Internal gizmo used for interactions on the y axis
  42725. */
  42726. yGizmo: PlaneRotationGizmo;
  42727. /**
  42728. * Internal gizmo used for interactions on the z axis
  42729. */
  42730. zGizmo: PlaneRotationGizmo;
  42731. /** Fires an event when any of it's sub gizmos are dragged */
  42732. onDragStartObservable: Observable<{}>;
  42733. /** Fires an event when any of it's sub gizmos are released from dragging */
  42734. onDragEndObservable: Observable<{}>;
  42735. attachedMesh: Nullable<AbstractMesh>;
  42736. /**
  42737. * Creates a RotationGizmo
  42738. * @param gizmoLayer The utility layer the gizmo will be added to
  42739. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42740. */
  42741. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42742. updateGizmoRotationToMatchAttachedMesh: boolean;
  42743. /**
  42744. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42745. */
  42746. snapDistance: number;
  42747. /**
  42748. * Ratio for the scale of the gizmo (Default: 1)
  42749. */
  42750. scaleRatio: number;
  42751. /**
  42752. * Disposes of the gizmo
  42753. */
  42754. dispose(): void;
  42755. /**
  42756. * CustomMeshes are not supported by this gizmo
  42757. * @param mesh The mesh to replace the default mesh of the gizmo
  42758. */
  42759. setCustomMesh(mesh: Mesh): void;
  42760. }
  42761. }
  42762. declare module "babylonjs/Gizmos/positionGizmo" {
  42763. import { Observable } from "babylonjs/Misc/observable";
  42764. import { Nullable } from "babylonjs/types";
  42765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42766. import { Mesh } from "babylonjs/Meshes/mesh";
  42767. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42768. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42769. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42770. /**
  42771. * Gizmo that enables dragging a mesh along 3 axis
  42772. */
  42773. export class PositionGizmo extends Gizmo {
  42774. /**
  42775. * Internal gizmo used for interactions on the x axis
  42776. */
  42777. xGizmo: AxisDragGizmo;
  42778. /**
  42779. * Internal gizmo used for interactions on the y axis
  42780. */
  42781. yGizmo: AxisDragGizmo;
  42782. /**
  42783. * Internal gizmo used for interactions on the z axis
  42784. */
  42785. zGizmo: AxisDragGizmo;
  42786. /** Fires an event when any of it's sub gizmos are dragged */
  42787. onDragStartObservable: Observable<{}>;
  42788. /** Fires an event when any of it's sub gizmos are released from dragging */
  42789. onDragEndObservable: Observable<{}>;
  42790. attachedMesh: Nullable<AbstractMesh>;
  42791. /**
  42792. * Creates a PositionGizmo
  42793. * @param gizmoLayer The utility layer the gizmo will be added to
  42794. */
  42795. constructor(gizmoLayer?: UtilityLayerRenderer);
  42796. updateGizmoRotationToMatchAttachedMesh: boolean;
  42797. /**
  42798. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42799. */
  42800. snapDistance: number;
  42801. /**
  42802. * Ratio for the scale of the gizmo (Default: 1)
  42803. */
  42804. scaleRatio: number;
  42805. /**
  42806. * Disposes of the gizmo
  42807. */
  42808. dispose(): void;
  42809. /**
  42810. * CustomMeshes are not supported by this gizmo
  42811. * @param mesh The mesh to replace the default mesh of the gizmo
  42812. */
  42813. setCustomMesh(mesh: Mesh): void;
  42814. }
  42815. }
  42816. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42817. import { Scene } from "babylonjs/scene";
  42818. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42819. import { Mesh } from "babylonjs/Meshes/mesh";
  42820. /**
  42821. * Class containing static functions to help procedurally build meshes
  42822. */
  42823. export class PolyhedronBuilder {
  42824. /**
  42825. * Creates a polyhedron mesh
  42826. * * 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
  42827. * * The parameter `size` (positive float, default 1) sets the polygon size
  42828. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42829. * * 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`
  42830. * * 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
  42831. * * 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)`)
  42832. * * 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
  42833. * * 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
  42834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42837. * @param name defines the name of the mesh
  42838. * @param options defines the options used to create the mesh
  42839. * @param scene defines the hosting scene
  42840. * @returns the polyhedron mesh
  42841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42842. */
  42843. static CreatePolyhedron(name: string, options: {
  42844. type?: number;
  42845. size?: number;
  42846. sizeX?: number;
  42847. sizeY?: number;
  42848. sizeZ?: number;
  42849. custom?: any;
  42850. faceUV?: Vector4[];
  42851. faceColors?: Color4[];
  42852. flat?: boolean;
  42853. updatable?: boolean;
  42854. sideOrientation?: number;
  42855. frontUVs?: Vector4;
  42856. backUVs?: Vector4;
  42857. }, scene: Scene): Mesh;
  42858. }
  42859. }
  42860. declare module "babylonjs/Gizmos/scaleGizmo" {
  42861. import { Observable } from "babylonjs/Misc/observable";
  42862. import { Nullable } from "babylonjs/types";
  42863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42864. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42865. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42866. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42867. /**
  42868. * Gizmo that enables scaling a mesh along 3 axis
  42869. */
  42870. export class ScaleGizmo extends Gizmo {
  42871. /**
  42872. * Internal gizmo used for interactions on the x axis
  42873. */
  42874. xGizmo: AxisScaleGizmo;
  42875. /**
  42876. * Internal gizmo used for interactions on the y axis
  42877. */
  42878. yGizmo: AxisScaleGizmo;
  42879. /**
  42880. * Internal gizmo used for interactions on the z axis
  42881. */
  42882. zGizmo: AxisScaleGizmo;
  42883. /**
  42884. * Internal gizmo used to scale all axis equally
  42885. */
  42886. uniformScaleGizmo: AxisScaleGizmo;
  42887. /** Fires an event when any of it's sub gizmos are dragged */
  42888. onDragStartObservable: Observable<{}>;
  42889. /** Fires an event when any of it's sub gizmos are released from dragging */
  42890. onDragEndObservable: Observable<{}>;
  42891. attachedMesh: Nullable<AbstractMesh>;
  42892. /**
  42893. * Creates a ScaleGizmo
  42894. * @param gizmoLayer The utility layer the gizmo will be added to
  42895. */
  42896. constructor(gizmoLayer?: UtilityLayerRenderer);
  42897. updateGizmoRotationToMatchAttachedMesh: boolean;
  42898. /**
  42899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42900. */
  42901. snapDistance: number;
  42902. /**
  42903. * Ratio for the scale of the gizmo (Default: 1)
  42904. */
  42905. scaleRatio: number;
  42906. /**
  42907. * Disposes of the gizmo
  42908. */
  42909. dispose(): void;
  42910. }
  42911. }
  42912. declare module "babylonjs/Gizmos/gizmoManager" {
  42913. import { Observable } from "babylonjs/Misc/observable";
  42914. import { Nullable } from "babylonjs/types";
  42915. import { Scene, IDisposable } from "babylonjs/scene";
  42916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42917. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42918. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42919. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42920. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42921. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42922. /**
  42923. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42924. */
  42925. export class GizmoManager implements IDisposable {
  42926. private scene;
  42927. /**
  42928. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42929. */
  42930. gizmos: {
  42931. positionGizmo: Nullable<PositionGizmo>;
  42932. rotationGizmo: Nullable<RotationGizmo>;
  42933. scaleGizmo: Nullable<ScaleGizmo>;
  42934. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42935. };
  42936. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42937. clearGizmoOnEmptyPointerEvent: boolean;
  42938. /** Fires an event when the manager is attached to a mesh */
  42939. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42940. private _gizmosEnabled;
  42941. private _pointerObserver;
  42942. private _attachedMesh;
  42943. private _boundingBoxColor;
  42944. private _defaultUtilityLayer;
  42945. private _defaultKeepDepthUtilityLayer;
  42946. /**
  42947. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42948. */
  42949. boundingBoxDragBehavior: SixDofDragBehavior;
  42950. /**
  42951. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42952. */
  42953. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42954. /**
  42955. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42956. */
  42957. usePointerToAttachGizmos: boolean;
  42958. /**
  42959. * Instatiates a gizmo manager
  42960. * @param scene the scene to overlay the gizmos on top of
  42961. */
  42962. constructor(scene: Scene);
  42963. /**
  42964. * Attaches a set of gizmos to the specified mesh
  42965. * @param mesh The mesh the gizmo's should be attached to
  42966. */
  42967. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42968. /**
  42969. * If the position gizmo is enabled
  42970. */
  42971. positionGizmoEnabled: boolean;
  42972. /**
  42973. * If the rotation gizmo is enabled
  42974. */
  42975. rotationGizmoEnabled: boolean;
  42976. /**
  42977. * If the scale gizmo is enabled
  42978. */
  42979. scaleGizmoEnabled: boolean;
  42980. /**
  42981. * If the boundingBox gizmo is enabled
  42982. */
  42983. boundingBoxGizmoEnabled: boolean;
  42984. /**
  42985. * Disposes of the gizmo manager
  42986. */
  42987. dispose(): void;
  42988. }
  42989. }
  42990. declare module "babylonjs/Gizmos/index" {
  42991. export * from "babylonjs/Gizmos/axisDragGizmo";
  42992. export * from "babylonjs/Gizmos/axisScaleGizmo";
  42993. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  42994. export * from "babylonjs/Gizmos/gizmo";
  42995. export * from "babylonjs/Gizmos/gizmoManager";
  42996. export * from "babylonjs/Gizmos/planeRotationGizmo";
  42997. export * from "babylonjs/Gizmos/positionGizmo";
  42998. export * from "babylonjs/Gizmos/rotationGizmo";
  42999. export * from "babylonjs/Gizmos/scaleGizmo";
  43000. }
  43001. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43002. /** @hidden */
  43003. export var backgroundFragmentDeclaration: {
  43004. name: string;
  43005. shader: string;
  43006. };
  43007. }
  43008. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43009. /** @hidden */
  43010. export var backgroundUboDeclaration: {
  43011. name: string;
  43012. shader: string;
  43013. };
  43014. }
  43015. declare module "babylonjs/Shaders/background.fragment" {
  43016. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43017. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43018. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43019. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43020. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43021. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43023. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43024. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43025. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43026. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43027. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43028. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43029. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43030. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43031. /** @hidden */
  43032. export var backgroundPixelShader: {
  43033. name: string;
  43034. shader: string;
  43035. };
  43036. }
  43037. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43038. /** @hidden */
  43039. export var backgroundVertexDeclaration: {
  43040. name: string;
  43041. shader: string;
  43042. };
  43043. }
  43044. declare module "babylonjs/Shaders/background.vertex" {
  43045. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43046. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43047. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43048. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43049. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43051. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43052. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43053. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43054. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43055. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43056. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43057. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43058. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43059. /** @hidden */
  43060. export var backgroundVertexShader: {
  43061. name: string;
  43062. shader: string;
  43063. };
  43064. }
  43065. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43066. import { Nullable, int, float } from "babylonjs/types";
  43067. import { Scene } from "babylonjs/scene";
  43068. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43071. import { Mesh } from "babylonjs/Meshes/mesh";
  43072. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43073. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43074. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43076. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43077. import "babylonjs/Shaders/background.fragment";
  43078. import "babylonjs/Shaders/background.vertex";
  43079. /**
  43080. * Background material used to create an efficient environement around your scene.
  43081. */
  43082. export class BackgroundMaterial extends PushMaterial {
  43083. /**
  43084. * Standard reflectance value at parallel view angle.
  43085. */
  43086. static StandardReflectance0: number;
  43087. /**
  43088. * Standard reflectance value at grazing angle.
  43089. */
  43090. static StandardReflectance90: number;
  43091. protected _primaryColor: Color3;
  43092. /**
  43093. * Key light Color (multiply against the environement texture)
  43094. */
  43095. primaryColor: Color3;
  43096. protected __perceptualColor: Nullable<Color3>;
  43097. /**
  43098. * Experimental Internal Use Only.
  43099. *
  43100. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43101. * This acts as a helper to set the primary color to a more "human friendly" value.
  43102. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43103. * output color as close as possible from the chosen value.
  43104. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43105. * part of lighting setup.)
  43106. */
  43107. _perceptualColor: Nullable<Color3>;
  43108. protected _primaryColorShadowLevel: float;
  43109. /**
  43110. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43111. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43112. */
  43113. primaryColorShadowLevel: float;
  43114. protected _primaryColorHighlightLevel: float;
  43115. /**
  43116. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43117. * The primary color is used at the level chosen to define what the white area would look.
  43118. */
  43119. primaryColorHighlightLevel: float;
  43120. protected _reflectionTexture: Nullable<BaseTexture>;
  43121. /**
  43122. * Reflection Texture used in the material.
  43123. * Should be author in a specific way for the best result (refer to the documentation).
  43124. */
  43125. reflectionTexture: Nullable<BaseTexture>;
  43126. protected _reflectionBlur: float;
  43127. /**
  43128. * Reflection Texture level of blur.
  43129. *
  43130. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43131. * texture twice.
  43132. */
  43133. reflectionBlur: float;
  43134. protected _diffuseTexture: Nullable<BaseTexture>;
  43135. /**
  43136. * Diffuse Texture used in the material.
  43137. * Should be author in a specific way for the best result (refer to the documentation).
  43138. */
  43139. diffuseTexture: Nullable<BaseTexture>;
  43140. protected _shadowLights: Nullable<IShadowLight[]>;
  43141. /**
  43142. * Specify the list of lights casting shadow on the material.
  43143. * All scene shadow lights will be included if null.
  43144. */
  43145. shadowLights: Nullable<IShadowLight[]>;
  43146. protected _shadowLevel: float;
  43147. /**
  43148. * Helps adjusting the shadow to a softer level if required.
  43149. * 0 means black shadows and 1 means no shadows.
  43150. */
  43151. shadowLevel: float;
  43152. protected _sceneCenter: Vector3;
  43153. /**
  43154. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43155. * It is usually zero but might be interesting to modify according to your setup.
  43156. */
  43157. sceneCenter: Vector3;
  43158. protected _opacityFresnel: boolean;
  43159. /**
  43160. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43161. * This helps ensuring a nice transition when the camera goes under the ground.
  43162. */
  43163. opacityFresnel: boolean;
  43164. protected _reflectionFresnel: boolean;
  43165. /**
  43166. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43167. * This helps adding a mirror texture on the ground.
  43168. */
  43169. reflectionFresnel: boolean;
  43170. protected _reflectionFalloffDistance: number;
  43171. /**
  43172. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43173. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43174. */
  43175. reflectionFalloffDistance: number;
  43176. protected _reflectionAmount: number;
  43177. /**
  43178. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43179. */
  43180. reflectionAmount: number;
  43181. protected _reflectionReflectance0: number;
  43182. /**
  43183. * This specifies the weight of the reflection at grazing angle.
  43184. */
  43185. reflectionReflectance0: number;
  43186. protected _reflectionReflectance90: number;
  43187. /**
  43188. * This specifies the weight of the reflection at a perpendicular point of view.
  43189. */
  43190. reflectionReflectance90: number;
  43191. /**
  43192. * Sets the reflection reflectance fresnel values according to the default standard
  43193. * empirically know to work well :-)
  43194. */
  43195. reflectionStandardFresnelWeight: number;
  43196. protected _useRGBColor: boolean;
  43197. /**
  43198. * Helps to directly use the maps channels instead of their level.
  43199. */
  43200. useRGBColor: boolean;
  43201. protected _enableNoise: boolean;
  43202. /**
  43203. * This helps reducing the banding effect that could occur on the background.
  43204. */
  43205. enableNoise: boolean;
  43206. /**
  43207. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43208. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43209. * Recommended to be keep at 1.0 except for special cases.
  43210. */
  43211. fovMultiplier: number;
  43212. private _fovMultiplier;
  43213. /**
  43214. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43215. */
  43216. useEquirectangularFOV: boolean;
  43217. private _maxSimultaneousLights;
  43218. /**
  43219. * Number of Simultaneous lights allowed on the material.
  43220. */
  43221. maxSimultaneousLights: int;
  43222. /**
  43223. * Default configuration related to image processing available in the Background Material.
  43224. */
  43225. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43226. /**
  43227. * Keep track of the image processing observer to allow dispose and replace.
  43228. */
  43229. private _imageProcessingObserver;
  43230. /**
  43231. * Attaches a new image processing configuration to the PBR Material.
  43232. * @param configuration (if null the scene configuration will be use)
  43233. */
  43234. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43235. /**
  43236. * Gets the image processing configuration used either in this material.
  43237. */
  43238. /**
  43239. * Sets the Default image processing configuration used either in the this material.
  43240. *
  43241. * If sets to null, the scene one is in use.
  43242. */
  43243. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43244. /**
  43245. * Gets wether the color curves effect is enabled.
  43246. */
  43247. /**
  43248. * Sets wether the color curves effect is enabled.
  43249. */
  43250. cameraColorCurvesEnabled: boolean;
  43251. /**
  43252. * Gets wether the color grading effect is enabled.
  43253. */
  43254. /**
  43255. * Gets wether the color grading effect is enabled.
  43256. */
  43257. cameraColorGradingEnabled: boolean;
  43258. /**
  43259. * Gets wether tonemapping is enabled or not.
  43260. */
  43261. /**
  43262. * Sets wether tonemapping is enabled or not
  43263. */
  43264. cameraToneMappingEnabled: boolean;
  43265. /**
  43266. * The camera exposure used on this material.
  43267. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43268. * This corresponds to a photographic exposure.
  43269. */
  43270. /**
  43271. * The camera exposure used on this material.
  43272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43273. * This corresponds to a photographic exposure.
  43274. */
  43275. cameraExposure: float;
  43276. /**
  43277. * Gets The camera contrast used on this material.
  43278. */
  43279. /**
  43280. * Sets The camera contrast used on this material.
  43281. */
  43282. cameraContrast: float;
  43283. /**
  43284. * Gets the Color Grading 2D Lookup Texture.
  43285. */
  43286. /**
  43287. * Sets the Color Grading 2D Lookup Texture.
  43288. */
  43289. cameraColorGradingTexture: Nullable<BaseTexture>;
  43290. /**
  43291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43293. * 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;
  43294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43295. */
  43296. /**
  43297. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43298. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43299. * 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;
  43300. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43301. */
  43302. cameraColorCurves: Nullable<ColorCurves>;
  43303. /**
  43304. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43305. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43306. */
  43307. switchToBGR: boolean;
  43308. private _renderTargets;
  43309. private _reflectionControls;
  43310. private _white;
  43311. private _primaryShadowColor;
  43312. private _primaryHighlightColor;
  43313. /**
  43314. * Instantiates a Background Material in the given scene
  43315. * @param name The friendly name of the material
  43316. * @param scene The scene to add the material to
  43317. */
  43318. constructor(name: string, scene: Scene);
  43319. /**
  43320. * Gets a boolean indicating that current material needs to register RTT
  43321. */
  43322. readonly hasRenderTargetTextures: boolean;
  43323. /**
  43324. * The entire material has been created in order to prevent overdraw.
  43325. * @returns false
  43326. */
  43327. needAlphaTesting(): boolean;
  43328. /**
  43329. * The entire material has been created in order to prevent overdraw.
  43330. * @returns true if blending is enable
  43331. */
  43332. needAlphaBlending(): boolean;
  43333. /**
  43334. * Checks wether the material is ready to be rendered for a given mesh.
  43335. * @param mesh The mesh to render
  43336. * @param subMesh The submesh to check against
  43337. * @param useInstances Specify wether or not the material is used with instances
  43338. * @returns true if all the dependencies are ready (Textures, Effects...)
  43339. */
  43340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43341. /**
  43342. * Compute the primary color according to the chosen perceptual color.
  43343. */
  43344. private _computePrimaryColorFromPerceptualColor;
  43345. /**
  43346. * Compute the highlights and shadow colors according to their chosen levels.
  43347. */
  43348. private _computePrimaryColors;
  43349. /**
  43350. * Build the uniform buffer used in the material.
  43351. */
  43352. buildUniformLayout(): void;
  43353. /**
  43354. * Unbind the material.
  43355. */
  43356. unbind(): void;
  43357. /**
  43358. * Bind only the world matrix to the material.
  43359. * @param world The world matrix to bind.
  43360. */
  43361. bindOnlyWorldMatrix(world: Matrix): void;
  43362. /**
  43363. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43364. * @param world The world matrix to bind.
  43365. * @param subMesh The submesh to bind for.
  43366. */
  43367. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43368. /**
  43369. * Dispose the material.
  43370. * @param forceDisposeEffect Force disposal of the associated effect.
  43371. * @param forceDisposeTextures Force disposal of the associated textures.
  43372. */
  43373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43374. /**
  43375. * Clones the material.
  43376. * @param name The cloned name.
  43377. * @returns The cloned material.
  43378. */
  43379. clone(name: string): BackgroundMaterial;
  43380. /**
  43381. * Serializes the current material to its JSON representation.
  43382. * @returns The JSON representation.
  43383. */
  43384. serialize(): any;
  43385. /**
  43386. * Gets the class name of the material
  43387. * @returns "BackgroundMaterial"
  43388. */
  43389. getClassName(): string;
  43390. /**
  43391. * Parse a JSON input to create back a background material.
  43392. * @param source The JSON data to parse
  43393. * @param scene The scene to create the parsed material in
  43394. * @param rootUrl The root url of the assets the material depends upon
  43395. * @returns the instantiated BackgroundMaterial.
  43396. */
  43397. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43398. }
  43399. }
  43400. declare module "babylonjs/Helpers/environmentHelper" {
  43401. import { Observable } from "babylonjs/Misc/observable";
  43402. import { Nullable } from "babylonjs/types";
  43403. import { Scene } from "babylonjs/scene";
  43404. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43406. import { Mesh } from "babylonjs/Meshes/mesh";
  43407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43408. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43409. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43410. import "babylonjs/Meshes/Builders/planeBuilder";
  43411. import "babylonjs/Meshes/Builders/boxBuilder";
  43412. /**
  43413. * Represents the different options available during the creation of
  43414. * a Environment helper.
  43415. *
  43416. * This can control the default ground, skybox and image processing setup of your scene.
  43417. */
  43418. export interface IEnvironmentHelperOptions {
  43419. /**
  43420. * Specifies wether or not to create a ground.
  43421. * True by default.
  43422. */
  43423. createGround: boolean;
  43424. /**
  43425. * Specifies the ground size.
  43426. * 15 by default.
  43427. */
  43428. groundSize: number;
  43429. /**
  43430. * The texture used on the ground for the main color.
  43431. * Comes from the BabylonJS CDN by default.
  43432. *
  43433. * Remarks: Can be either a texture or a url.
  43434. */
  43435. groundTexture: string | BaseTexture;
  43436. /**
  43437. * The color mixed in the ground texture by default.
  43438. * BabylonJS clearColor by default.
  43439. */
  43440. groundColor: Color3;
  43441. /**
  43442. * Specifies the ground opacity.
  43443. * 1 by default.
  43444. */
  43445. groundOpacity: number;
  43446. /**
  43447. * Enables the ground to receive shadows.
  43448. * True by default.
  43449. */
  43450. enableGroundShadow: boolean;
  43451. /**
  43452. * Helps preventing the shadow to be fully black on the ground.
  43453. * 0.5 by default.
  43454. */
  43455. groundShadowLevel: number;
  43456. /**
  43457. * Creates a mirror texture attach to the ground.
  43458. * false by default.
  43459. */
  43460. enableGroundMirror: boolean;
  43461. /**
  43462. * Specifies the ground mirror size ratio.
  43463. * 0.3 by default as the default kernel is 64.
  43464. */
  43465. groundMirrorSizeRatio: number;
  43466. /**
  43467. * Specifies the ground mirror blur kernel size.
  43468. * 64 by default.
  43469. */
  43470. groundMirrorBlurKernel: number;
  43471. /**
  43472. * Specifies the ground mirror visibility amount.
  43473. * 1 by default
  43474. */
  43475. groundMirrorAmount: number;
  43476. /**
  43477. * Specifies the ground mirror reflectance weight.
  43478. * This uses the standard weight of the background material to setup the fresnel effect
  43479. * of the mirror.
  43480. * 1 by default.
  43481. */
  43482. groundMirrorFresnelWeight: number;
  43483. /**
  43484. * Specifies the ground mirror Falloff distance.
  43485. * This can helps reducing the size of the reflection.
  43486. * 0 by Default.
  43487. */
  43488. groundMirrorFallOffDistance: number;
  43489. /**
  43490. * Specifies the ground mirror texture type.
  43491. * Unsigned Int by Default.
  43492. */
  43493. groundMirrorTextureType: number;
  43494. /**
  43495. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43496. * the shown objects.
  43497. */
  43498. groundYBias: number;
  43499. /**
  43500. * Specifies wether or not to create a skybox.
  43501. * True by default.
  43502. */
  43503. createSkybox: boolean;
  43504. /**
  43505. * Specifies the skybox size.
  43506. * 20 by default.
  43507. */
  43508. skyboxSize: number;
  43509. /**
  43510. * The texture used on the skybox for the main color.
  43511. * Comes from the BabylonJS CDN by default.
  43512. *
  43513. * Remarks: Can be either a texture or a url.
  43514. */
  43515. skyboxTexture: string | BaseTexture;
  43516. /**
  43517. * The color mixed in the skybox texture by default.
  43518. * BabylonJS clearColor by default.
  43519. */
  43520. skyboxColor: Color3;
  43521. /**
  43522. * The background rotation around the Y axis of the scene.
  43523. * This helps aligning the key lights of your scene with the background.
  43524. * 0 by default.
  43525. */
  43526. backgroundYRotation: number;
  43527. /**
  43528. * Compute automatically the size of the elements to best fit with the scene.
  43529. */
  43530. sizeAuto: boolean;
  43531. /**
  43532. * Default position of the rootMesh if autoSize is not true.
  43533. */
  43534. rootPosition: Vector3;
  43535. /**
  43536. * Sets up the image processing in the scene.
  43537. * true by default.
  43538. */
  43539. setupImageProcessing: boolean;
  43540. /**
  43541. * The texture used as your environment texture in the scene.
  43542. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43543. *
  43544. * Remarks: Can be either a texture or a url.
  43545. */
  43546. environmentTexture: string | BaseTexture;
  43547. /**
  43548. * The value of the exposure to apply to the scene.
  43549. * 0.6 by default if setupImageProcessing is true.
  43550. */
  43551. cameraExposure: number;
  43552. /**
  43553. * The value of the contrast to apply to the scene.
  43554. * 1.6 by default if setupImageProcessing is true.
  43555. */
  43556. cameraContrast: number;
  43557. /**
  43558. * Specifies wether or not tonemapping should be enabled in the scene.
  43559. * true by default if setupImageProcessing is true.
  43560. */
  43561. toneMappingEnabled: boolean;
  43562. }
  43563. /**
  43564. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43565. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43566. * It also helps with the default setup of your imageProcessing configuration.
  43567. */
  43568. export class EnvironmentHelper {
  43569. /**
  43570. * Default ground texture URL.
  43571. */
  43572. private static _groundTextureCDNUrl;
  43573. /**
  43574. * Default skybox texture URL.
  43575. */
  43576. private static _skyboxTextureCDNUrl;
  43577. /**
  43578. * Default environment texture URL.
  43579. */
  43580. private static _environmentTextureCDNUrl;
  43581. /**
  43582. * Creates the default options for the helper.
  43583. */
  43584. private static _getDefaultOptions;
  43585. private _rootMesh;
  43586. /**
  43587. * Gets the root mesh created by the helper.
  43588. */
  43589. readonly rootMesh: Mesh;
  43590. private _skybox;
  43591. /**
  43592. * Gets the skybox created by the helper.
  43593. */
  43594. readonly skybox: Nullable<Mesh>;
  43595. private _skyboxTexture;
  43596. /**
  43597. * Gets the skybox texture created by the helper.
  43598. */
  43599. readonly skyboxTexture: Nullable<BaseTexture>;
  43600. private _skyboxMaterial;
  43601. /**
  43602. * Gets the skybox material created by the helper.
  43603. */
  43604. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43605. private _ground;
  43606. /**
  43607. * Gets the ground mesh created by the helper.
  43608. */
  43609. readonly ground: Nullable<Mesh>;
  43610. private _groundTexture;
  43611. /**
  43612. * Gets the ground texture created by the helper.
  43613. */
  43614. readonly groundTexture: Nullable<BaseTexture>;
  43615. private _groundMirror;
  43616. /**
  43617. * Gets the ground mirror created by the helper.
  43618. */
  43619. readonly groundMirror: Nullable<MirrorTexture>;
  43620. /**
  43621. * Gets the ground mirror render list to helps pushing the meshes
  43622. * you wish in the ground reflection.
  43623. */
  43624. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43625. private _groundMaterial;
  43626. /**
  43627. * Gets the ground material created by the helper.
  43628. */
  43629. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43630. /**
  43631. * Stores the creation options.
  43632. */
  43633. private readonly _scene;
  43634. private _options;
  43635. /**
  43636. * This observable will be notified with any error during the creation of the environment,
  43637. * mainly texture creation errors.
  43638. */
  43639. onErrorObservable: Observable<{
  43640. message?: string;
  43641. exception?: any;
  43642. }>;
  43643. /**
  43644. * constructor
  43645. * @param options Defines the options we want to customize the helper
  43646. * @param scene The scene to add the material to
  43647. */
  43648. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43649. /**
  43650. * Updates the background according to the new options
  43651. * @param options
  43652. */
  43653. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43654. /**
  43655. * Sets the primary color of all the available elements.
  43656. * @param color the main color to affect to the ground and the background
  43657. */
  43658. setMainColor(color: Color3): void;
  43659. /**
  43660. * Setup the image processing according to the specified options.
  43661. */
  43662. private _setupImageProcessing;
  43663. /**
  43664. * Setup the environment texture according to the specified options.
  43665. */
  43666. private _setupEnvironmentTexture;
  43667. /**
  43668. * Setup the background according to the specified options.
  43669. */
  43670. private _setupBackground;
  43671. /**
  43672. * Get the scene sizes according to the setup.
  43673. */
  43674. private _getSceneSize;
  43675. /**
  43676. * Setup the ground according to the specified options.
  43677. */
  43678. private _setupGround;
  43679. /**
  43680. * Setup the ground material according to the specified options.
  43681. */
  43682. private _setupGroundMaterial;
  43683. /**
  43684. * Setup the ground diffuse texture according to the specified options.
  43685. */
  43686. private _setupGroundDiffuseTexture;
  43687. /**
  43688. * Setup the ground mirror texture according to the specified options.
  43689. */
  43690. private _setupGroundMirrorTexture;
  43691. /**
  43692. * Setup the ground to receive the mirror texture.
  43693. */
  43694. private _setupMirrorInGroundMaterial;
  43695. /**
  43696. * Setup the skybox according to the specified options.
  43697. */
  43698. private _setupSkybox;
  43699. /**
  43700. * Setup the skybox material according to the specified options.
  43701. */
  43702. private _setupSkyboxMaterial;
  43703. /**
  43704. * Setup the skybox reflection texture according to the specified options.
  43705. */
  43706. private _setupSkyboxReflectionTexture;
  43707. private _errorHandler;
  43708. /**
  43709. * Dispose all the elements created by the Helper.
  43710. */
  43711. dispose(): void;
  43712. }
  43713. }
  43714. declare module "babylonjs/Helpers/photoDome" {
  43715. import { Observable } from "babylonjs/Misc/observable";
  43716. import { Nullable } from "babylonjs/types";
  43717. import { Scene } from "babylonjs/scene";
  43718. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43719. import { Mesh } from "babylonjs/Meshes/mesh";
  43720. import { Texture } from "babylonjs/Materials/Textures/texture";
  43721. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43722. import "babylonjs/Meshes/Builders/sphereBuilder";
  43723. /**
  43724. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43725. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43726. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43727. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43728. */
  43729. export class PhotoDome extends TransformNode {
  43730. private _useDirectMapping;
  43731. /**
  43732. * The texture being displayed on the sphere
  43733. */
  43734. protected _photoTexture: Texture;
  43735. /**
  43736. * Gets or sets the texture being displayed on the sphere
  43737. */
  43738. photoTexture: Texture;
  43739. /**
  43740. * Observable raised when an error occured while loading the 360 image
  43741. */
  43742. onLoadErrorObservable: Observable<string>;
  43743. /**
  43744. * The skybox material
  43745. */
  43746. protected _material: BackgroundMaterial;
  43747. /**
  43748. * The surface used for the skybox
  43749. */
  43750. protected _mesh: Mesh;
  43751. /**
  43752. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43753. * Also see the options.resolution property.
  43754. */
  43755. fovMultiplier: number;
  43756. /**
  43757. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43758. * @param name Element's name, child elements will append suffixes for their own names.
  43759. * @param urlsOfPhoto defines the url of the photo to display
  43760. * @param options defines an object containing optional or exposed sub element properties
  43761. * @param onError defines a callback called when an error occured while loading the texture
  43762. */
  43763. constructor(name: string, urlOfPhoto: string, options: {
  43764. resolution?: number;
  43765. size?: number;
  43766. useDirectMapping?: boolean;
  43767. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43768. /**
  43769. * Releases resources associated with this node.
  43770. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43771. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43772. */
  43773. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43774. }
  43775. }
  43776. declare module "babylonjs/Misc/textureTools" {
  43777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43778. import { Texture } from "babylonjs/Materials/Textures/texture";
  43779. import { Scene } from "babylonjs/scene";
  43780. /**
  43781. * Class used to host texture specific utilities
  43782. */
  43783. export class TextureTools {
  43784. /**
  43785. * Uses the GPU to create a copy texture rescaled at a given size
  43786. * @param texture Texture to copy from
  43787. * @param width defines the desired width
  43788. * @param height defines the desired height
  43789. * @param useBilinearMode defines if bilinear mode has to be used
  43790. * @return the generated texture
  43791. */
  43792. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43793. /**
  43794. * Gets an environment BRDF texture for a given scene
  43795. * @param scene defines the hosting scene
  43796. * @returns the environment BRDF texture
  43797. */
  43798. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43799. private static _environmentBRDFBase64Texture;
  43800. }
  43801. }
  43802. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43803. /** @hidden */
  43804. export var pbrFragmentDeclaration: {
  43805. name: string;
  43806. shader: string;
  43807. };
  43808. }
  43809. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43810. /** @hidden */
  43811. export var pbrUboDeclaration: {
  43812. name: string;
  43813. shader: string;
  43814. };
  43815. }
  43816. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43817. /** @hidden */
  43818. export var pbrFunctions: {
  43819. name: string;
  43820. shader: string;
  43821. };
  43822. }
  43823. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43824. /** @hidden */
  43825. export var harmonicsFunctions: {
  43826. name: string;
  43827. shader: string;
  43828. };
  43829. }
  43830. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43831. /** @hidden */
  43832. export var pbrLightFunctions: {
  43833. name: string;
  43834. shader: string;
  43835. };
  43836. }
  43837. declare module "babylonjs/Shaders/pbr.fragment" {
  43838. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  43839. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43840. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43841. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43842. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43843. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43844. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43845. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43846. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43847. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  43848. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43849. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  43850. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  43851. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43852. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43853. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43854. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43855. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  43856. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  43857. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43858. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  43859. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43860. /** @hidden */
  43861. export var pbrPixelShader: {
  43862. name: string;
  43863. shader: string;
  43864. };
  43865. }
  43866. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  43867. /** @hidden */
  43868. export var pbrVertexDeclaration: {
  43869. name: string;
  43870. shader: string;
  43871. };
  43872. }
  43873. declare module "babylonjs/Shaders/pbr.vertex" {
  43874. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  43875. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43876. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43877. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43878. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43879. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43880. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  43881. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43882. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43883. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43884. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  43886. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  43887. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  43889. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43890. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43891. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  43892. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43893. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43894. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43895. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  43896. /** @hidden */
  43897. export var pbrVertexShader: {
  43898. name: string;
  43899. shader: string;
  43900. };
  43901. }
  43902. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  43903. import { IAnimatable } from "babylonjs/Misc/tools";
  43904. import { Nullable } from "babylonjs/types";
  43905. import { Scene } from "babylonjs/scene";
  43906. import { Matrix, Color3 } from "babylonjs/Maths/math";
  43907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43908. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43909. import { Mesh } from "babylonjs/Meshes/mesh";
  43910. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43911. import { Material } from "babylonjs/Materials/material";
  43912. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43914. import "babylonjs/Shaders/pbr.fragment";
  43915. import "babylonjs/Shaders/pbr.vertex";
  43916. /**
  43917. * The Physically based material base class of BJS.
  43918. *
  43919. * This offers the main features of a standard PBR material.
  43920. * For more information, please refer to the documentation :
  43921. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43922. */
  43923. export abstract class PBRBaseMaterial extends PushMaterial {
  43924. /**
  43925. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43926. */
  43927. static readonly PBRMATERIAL_OPAQUE: number;
  43928. /**
  43929. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43930. */
  43931. static readonly PBRMATERIAL_ALPHATEST: number;
  43932. /**
  43933. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43934. */
  43935. static readonly PBRMATERIAL_ALPHABLEND: number;
  43936. /**
  43937. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43938. * They are also discarded below the alpha cutoff threshold to improve performances.
  43939. */
  43940. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43941. /**
  43942. * Defines the default value of how much AO map is occluding the analytical lights
  43943. * (point spot...).
  43944. */
  43945. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43946. /**
  43947. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43948. */
  43949. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43950. /**
  43951. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43952. * to enhance interoperability with other engines.
  43953. */
  43954. static readonly LIGHTFALLOFF_GLTF: number;
  43955. /**
  43956. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43957. * to enhance interoperability with other materials.
  43958. */
  43959. static readonly LIGHTFALLOFF_STANDARD: number;
  43960. /**
  43961. * Intensity of the direct lights e.g. the four lights available in your scene.
  43962. * This impacts both the direct diffuse and specular highlights.
  43963. */
  43964. protected _directIntensity: number;
  43965. /**
  43966. * Intensity of the emissive part of the material.
  43967. * This helps controlling the emissive effect without modifying the emissive color.
  43968. */
  43969. protected _emissiveIntensity: number;
  43970. /**
  43971. * Intensity of the environment e.g. how much the environment will light the object
  43972. * either through harmonics for rough material or through the refelction for shiny ones.
  43973. */
  43974. protected _environmentIntensity: number;
  43975. /**
  43976. * This is a special control allowing the reduction of the specular highlights coming from the
  43977. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43978. */
  43979. protected _specularIntensity: number;
  43980. /**
  43981. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43982. */
  43983. private _lightingInfos;
  43984. /**
  43985. * Debug Control allowing disabling the bump map on this material.
  43986. */
  43987. protected _disableBumpMap: boolean;
  43988. /**
  43989. * AKA Diffuse Texture in standard nomenclature.
  43990. */
  43991. protected _albedoTexture: BaseTexture;
  43992. /**
  43993. * AKA Occlusion Texture in other nomenclature.
  43994. */
  43995. protected _ambientTexture: BaseTexture;
  43996. /**
  43997. * AKA Occlusion Texture Intensity in other nomenclature.
  43998. */
  43999. protected _ambientTextureStrength: number;
  44000. /**
  44001. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44002. * 1 means it completely occludes it
  44003. * 0 mean it has no impact
  44004. */
  44005. protected _ambientTextureImpactOnAnalyticalLights: number;
  44006. /**
  44007. * Stores the alpha values in a texture.
  44008. */
  44009. protected _opacityTexture: BaseTexture;
  44010. /**
  44011. * Stores the reflection values in a texture.
  44012. */
  44013. protected _reflectionTexture: BaseTexture;
  44014. /**
  44015. * Stores the refraction values in a texture.
  44016. */
  44017. protected _refractionTexture: BaseTexture;
  44018. /**
  44019. * Stores the emissive values in a texture.
  44020. */
  44021. protected _emissiveTexture: BaseTexture;
  44022. /**
  44023. * AKA Specular texture in other nomenclature.
  44024. */
  44025. protected _reflectivityTexture: BaseTexture;
  44026. /**
  44027. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44028. */
  44029. protected _metallicTexture: BaseTexture;
  44030. /**
  44031. * Specifies the metallic scalar of the metallic/roughness workflow.
  44032. * Can also be used to scale the metalness values of the metallic texture.
  44033. */
  44034. protected _metallic: Nullable<number>;
  44035. /**
  44036. * Specifies the roughness scalar of the metallic/roughness workflow.
  44037. * Can also be used to scale the roughness values of the metallic texture.
  44038. */
  44039. protected _roughness: Nullable<number>;
  44040. /**
  44041. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44042. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44043. */
  44044. protected _microSurfaceTexture: BaseTexture;
  44045. /**
  44046. * Stores surface normal data used to displace a mesh in a texture.
  44047. */
  44048. protected _bumpTexture: BaseTexture;
  44049. /**
  44050. * Stores the pre-calculated light information of a mesh in a texture.
  44051. */
  44052. protected _lightmapTexture: BaseTexture;
  44053. /**
  44054. * The color of a material in ambient lighting.
  44055. */
  44056. protected _ambientColor: Color3;
  44057. /**
  44058. * AKA Diffuse Color in other nomenclature.
  44059. */
  44060. protected _albedoColor: Color3;
  44061. /**
  44062. * AKA Specular Color in other nomenclature.
  44063. */
  44064. protected _reflectivityColor: Color3;
  44065. /**
  44066. * The color applied when light is reflected from a material.
  44067. */
  44068. protected _reflectionColor: Color3;
  44069. /**
  44070. * The color applied when light is emitted from a material.
  44071. */
  44072. protected _emissiveColor: Color3;
  44073. /**
  44074. * AKA Glossiness in other nomenclature.
  44075. */
  44076. protected _microSurface: number;
  44077. /**
  44078. * source material index of refraction (IOR)' / 'destination material IOR.
  44079. */
  44080. protected _indexOfRefraction: number;
  44081. /**
  44082. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44083. */
  44084. protected _invertRefractionY: boolean;
  44085. /**
  44086. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44087. * Materials half opaque for instance using refraction could benefit from this control.
  44088. */
  44089. protected _linkRefractionWithTransparency: boolean;
  44090. /**
  44091. * Specifies that the material will use the light map as a show map.
  44092. */
  44093. protected _useLightmapAsShadowmap: boolean;
  44094. /**
  44095. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44096. * makes the reflect vector face the model (under horizon).
  44097. */
  44098. protected _useHorizonOcclusion: boolean;
  44099. /**
  44100. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44101. * too much the area relying on ambient texture to define their ambient occlusion.
  44102. */
  44103. protected _useRadianceOcclusion: boolean;
  44104. /**
  44105. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44106. */
  44107. protected _useAlphaFromAlbedoTexture: boolean;
  44108. /**
  44109. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44110. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44111. */
  44112. protected _useSpecularOverAlpha: boolean;
  44113. /**
  44114. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44115. */
  44116. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44117. /**
  44118. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44119. */
  44120. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44121. /**
  44122. * Specifies if the metallic texture contains the roughness information in its green channel.
  44123. */
  44124. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44125. /**
  44126. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44127. */
  44128. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44129. /**
  44130. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44131. */
  44132. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44133. /**
  44134. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44135. */
  44136. protected _useAmbientInGrayScale: boolean;
  44137. /**
  44138. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44139. * The material will try to infer what glossiness each pixel should be.
  44140. */
  44141. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44142. /**
  44143. * Defines the falloff type used in this material.
  44144. * It by default is Physical.
  44145. */
  44146. protected _lightFalloff: number;
  44147. /**
  44148. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44149. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44150. */
  44151. protected _useRadianceOverAlpha: boolean;
  44152. /**
  44153. * Allows using an object space normal map (instead of tangent space).
  44154. */
  44155. protected _useObjectSpaceNormalMap: boolean;
  44156. /**
  44157. * Allows using the bump map in parallax mode.
  44158. */
  44159. protected _useParallax: boolean;
  44160. /**
  44161. * Allows using the bump map in parallax occlusion mode.
  44162. */
  44163. protected _useParallaxOcclusion: boolean;
  44164. /**
  44165. * Controls the scale bias of the parallax mode.
  44166. */
  44167. protected _parallaxScaleBias: number;
  44168. /**
  44169. * If sets to true, disables all the lights affecting the material.
  44170. */
  44171. protected _disableLighting: boolean;
  44172. /**
  44173. * Number of Simultaneous lights allowed on the material.
  44174. */
  44175. protected _maxSimultaneousLights: number;
  44176. /**
  44177. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44178. */
  44179. protected _invertNormalMapX: boolean;
  44180. /**
  44181. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44182. */
  44183. protected _invertNormalMapY: boolean;
  44184. /**
  44185. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44186. */
  44187. protected _twoSidedLighting: boolean;
  44188. /**
  44189. * Defines the alpha limits in alpha test mode.
  44190. */
  44191. protected _alphaCutOff: number;
  44192. /**
  44193. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44194. */
  44195. protected _forceAlphaTest: boolean;
  44196. /**
  44197. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44198. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44199. */
  44200. protected _useAlphaFresnel: boolean;
  44201. /**
  44202. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44203. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44204. */
  44205. protected _useLinearAlphaFresnel: boolean;
  44206. /**
  44207. * The transparency mode of the material.
  44208. */
  44209. protected _transparencyMode: Nullable<number>;
  44210. /**
  44211. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44212. * from cos thetav and roughness:
  44213. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44214. */
  44215. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44216. /**
  44217. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44218. */
  44219. protected _forceIrradianceInFragment: boolean;
  44220. /**
  44221. * Force normal to face away from face.
  44222. */
  44223. protected _forceNormalForward: boolean;
  44224. /**
  44225. * Enables specular anti aliasing in the PBR shader.
  44226. * It will both interacts on the Geometry for analytical and IBL lighting.
  44227. * It also prefilter the roughness map based on the bump values.
  44228. */
  44229. protected _enableSpecularAntiAliasing: boolean;
  44230. /**
  44231. * Default configuration related to image processing available in the PBR Material.
  44232. */
  44233. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44234. /**
  44235. * Keep track of the image processing observer to allow dispose and replace.
  44236. */
  44237. private _imageProcessingObserver;
  44238. /**
  44239. * Attaches a new image processing configuration to the PBR Material.
  44240. * @param configuration
  44241. */
  44242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44243. /**
  44244. * Stores the available render targets.
  44245. */
  44246. private _renderTargets;
  44247. /**
  44248. * Sets the global ambient color for the material used in lighting calculations.
  44249. */
  44250. private _globalAmbientColor;
  44251. /**
  44252. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44253. */
  44254. private _useLogarithmicDepth;
  44255. /**
  44256. * If set to true, no lighting calculations will be applied.
  44257. */
  44258. private _unlit;
  44259. /**
  44260. * Instantiates a new PBRMaterial instance.
  44261. *
  44262. * @param name The material name
  44263. * @param scene The scene the material will be use in.
  44264. */
  44265. constructor(name: string, scene: Scene);
  44266. /**
  44267. * Gets a boolean indicating that current material needs to register RTT
  44268. */
  44269. readonly hasRenderTargetTextures: boolean;
  44270. /**
  44271. * Gets the name of the material class.
  44272. */
  44273. getClassName(): string;
  44274. /**
  44275. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44276. */
  44277. /**
  44278. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44279. */
  44280. useLogarithmicDepth: boolean;
  44281. /**
  44282. * Gets the current transparency mode.
  44283. */
  44284. /**
  44285. * Sets the transparency mode of the material.
  44286. *
  44287. * | Value | Type | Description |
  44288. * | ----- | ----------------------------------- | ----------- |
  44289. * | 0 | OPAQUE | |
  44290. * | 1 | ALPHATEST | |
  44291. * | 2 | ALPHABLEND | |
  44292. * | 3 | ALPHATESTANDBLEND | |
  44293. *
  44294. */
  44295. transparencyMode: Nullable<number>;
  44296. /**
  44297. * Returns true if alpha blending should be disabled.
  44298. */
  44299. private readonly _disableAlphaBlending;
  44300. /**
  44301. * Specifies whether or not this material should be rendered in alpha blend mode.
  44302. */
  44303. needAlphaBlending(): boolean;
  44304. /**
  44305. * Specifies if the mesh will require alpha blending.
  44306. * @param mesh - BJS mesh.
  44307. */
  44308. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44309. /**
  44310. * Specifies whether or not this material should be rendered in alpha test mode.
  44311. */
  44312. needAlphaTesting(): boolean;
  44313. /**
  44314. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44315. */
  44316. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44317. /**
  44318. * Gets the texture used for the alpha test.
  44319. */
  44320. getAlphaTestTexture(): BaseTexture;
  44321. /**
  44322. * Specifies that the submesh is ready to be used.
  44323. * @param mesh - BJS mesh.
  44324. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44325. * @param useInstances - Specifies that instances should be used.
  44326. * @returns - boolean indicating that the submesh is ready or not.
  44327. */
  44328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44329. /**
  44330. * Specifies if the material uses metallic roughness workflow.
  44331. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44332. */
  44333. isMetallicWorkflow(): boolean;
  44334. private _prepareEffect;
  44335. private _prepareDefines;
  44336. /**
  44337. * Force shader compilation
  44338. */
  44339. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44340. clipPlane: boolean;
  44341. }>): void;
  44342. /**
  44343. * Initializes the uniform buffer layout for the shader.
  44344. */
  44345. buildUniformLayout(): void;
  44346. /**
  44347. * Unbinds the textures.
  44348. */
  44349. unbind(): void;
  44350. /**
  44351. * Binds the submesh data.
  44352. * @param world - The world matrix.
  44353. * @param mesh - The BJS mesh.
  44354. * @param subMesh - A submesh of the BJS mesh.
  44355. */
  44356. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44357. /**
  44358. * Returns the animatable textures.
  44359. * @returns - Array of animatable textures.
  44360. */
  44361. getAnimatables(): IAnimatable[];
  44362. /**
  44363. * Returns the texture used for reflections.
  44364. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44365. */
  44366. private _getReflectionTexture;
  44367. /**
  44368. * Returns the texture used for refraction or null if none is used.
  44369. * @returns - Refection texture if present. If no refraction texture and refraction
  44370. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44371. */
  44372. private _getRefractionTexture;
  44373. /**
  44374. * Disposes the resources of the material.
  44375. * @param forceDisposeEffect - Forces the disposal of effects.
  44376. * @param forceDisposeTextures - Forces the disposal of all textures.
  44377. */
  44378. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44379. }
  44380. }
  44381. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44382. import { Nullable } from "babylonjs/types";
  44383. import { Scene } from "babylonjs/scene";
  44384. import { Color3 } from "babylonjs/Maths/math";
  44385. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44386. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44388. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44389. /**
  44390. * The Physically based material of BJS.
  44391. *
  44392. * This offers the main features of a standard PBR material.
  44393. * For more information, please refer to the documentation :
  44394. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44395. */
  44396. export class PBRMaterial extends PBRBaseMaterial {
  44397. /**
  44398. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44399. */
  44400. static readonly PBRMATERIAL_OPAQUE: number;
  44401. /**
  44402. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44403. */
  44404. static readonly PBRMATERIAL_ALPHATEST: number;
  44405. /**
  44406. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44407. */
  44408. static readonly PBRMATERIAL_ALPHABLEND: number;
  44409. /**
  44410. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44411. * They are also discarded below the alpha cutoff threshold to improve performances.
  44412. */
  44413. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44414. /**
  44415. * Defines the default value of how much AO map is occluding the analytical lights
  44416. * (point spot...).
  44417. */
  44418. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44419. /**
  44420. * Intensity of the direct lights e.g. the four lights available in your scene.
  44421. * This impacts both the direct diffuse and specular highlights.
  44422. */
  44423. directIntensity: number;
  44424. /**
  44425. * Intensity of the emissive part of the material.
  44426. * This helps controlling the emissive effect without modifying the emissive color.
  44427. */
  44428. emissiveIntensity: number;
  44429. /**
  44430. * Intensity of the environment e.g. how much the environment will light the object
  44431. * either through harmonics for rough material or through the refelction for shiny ones.
  44432. */
  44433. environmentIntensity: number;
  44434. /**
  44435. * This is a special control allowing the reduction of the specular highlights coming from the
  44436. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44437. */
  44438. specularIntensity: number;
  44439. /**
  44440. * Debug Control allowing disabling the bump map on this material.
  44441. */
  44442. disableBumpMap: boolean;
  44443. /**
  44444. * AKA Diffuse Texture in standard nomenclature.
  44445. */
  44446. albedoTexture: BaseTexture;
  44447. /**
  44448. * AKA Occlusion Texture in other nomenclature.
  44449. */
  44450. ambientTexture: BaseTexture;
  44451. /**
  44452. * AKA Occlusion Texture Intensity in other nomenclature.
  44453. */
  44454. ambientTextureStrength: number;
  44455. /**
  44456. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44457. * 1 means it completely occludes it
  44458. * 0 mean it has no impact
  44459. */
  44460. ambientTextureImpactOnAnalyticalLights: number;
  44461. /**
  44462. * Stores the alpha values in a texture.
  44463. */
  44464. opacityTexture: BaseTexture;
  44465. /**
  44466. * Stores the reflection values in a texture.
  44467. */
  44468. reflectionTexture: Nullable<BaseTexture>;
  44469. /**
  44470. * Stores the emissive values in a texture.
  44471. */
  44472. emissiveTexture: BaseTexture;
  44473. /**
  44474. * AKA Specular texture in other nomenclature.
  44475. */
  44476. reflectivityTexture: BaseTexture;
  44477. /**
  44478. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44479. */
  44480. metallicTexture: BaseTexture;
  44481. /**
  44482. * Specifies the metallic scalar of the metallic/roughness workflow.
  44483. * Can also be used to scale the metalness values of the metallic texture.
  44484. */
  44485. metallic: Nullable<number>;
  44486. /**
  44487. * Specifies the roughness scalar of the metallic/roughness workflow.
  44488. * Can also be used to scale the roughness values of the metallic texture.
  44489. */
  44490. roughness: Nullable<number>;
  44491. /**
  44492. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44493. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44494. */
  44495. microSurfaceTexture: BaseTexture;
  44496. /**
  44497. * Stores surface normal data used to displace a mesh in a texture.
  44498. */
  44499. bumpTexture: BaseTexture;
  44500. /**
  44501. * Stores the pre-calculated light information of a mesh in a texture.
  44502. */
  44503. lightmapTexture: BaseTexture;
  44504. /**
  44505. * Stores the refracted light information in a texture.
  44506. */
  44507. refractionTexture: BaseTexture;
  44508. /**
  44509. * The color of a material in ambient lighting.
  44510. */
  44511. ambientColor: Color3;
  44512. /**
  44513. * AKA Diffuse Color in other nomenclature.
  44514. */
  44515. albedoColor: Color3;
  44516. /**
  44517. * AKA Specular Color in other nomenclature.
  44518. */
  44519. reflectivityColor: Color3;
  44520. /**
  44521. * The color reflected from the material.
  44522. */
  44523. reflectionColor: Color3;
  44524. /**
  44525. * The color emitted from the material.
  44526. */
  44527. emissiveColor: Color3;
  44528. /**
  44529. * AKA Glossiness in other nomenclature.
  44530. */
  44531. microSurface: number;
  44532. /**
  44533. * source material index of refraction (IOR)' / 'destination material IOR.
  44534. */
  44535. indexOfRefraction: number;
  44536. /**
  44537. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44538. */
  44539. invertRefractionY: boolean;
  44540. /**
  44541. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44542. * Materials half opaque for instance using refraction could benefit from this control.
  44543. */
  44544. linkRefractionWithTransparency: boolean;
  44545. /**
  44546. * If true, the light map contains occlusion information instead of lighting info.
  44547. */
  44548. useLightmapAsShadowmap: boolean;
  44549. /**
  44550. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44551. */
  44552. useAlphaFromAlbedoTexture: boolean;
  44553. /**
  44554. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44555. */
  44556. forceAlphaTest: boolean;
  44557. /**
  44558. * Defines the alpha limits in alpha test mode.
  44559. */
  44560. alphaCutOff: number;
  44561. /**
  44562. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44563. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44564. */
  44565. useSpecularOverAlpha: boolean;
  44566. /**
  44567. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44568. */
  44569. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44570. /**
  44571. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44572. */
  44573. useRoughnessFromMetallicTextureAlpha: boolean;
  44574. /**
  44575. * Specifies if the metallic texture contains the roughness information in its green channel.
  44576. */
  44577. useRoughnessFromMetallicTextureGreen: boolean;
  44578. /**
  44579. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44580. */
  44581. useMetallnessFromMetallicTextureBlue: boolean;
  44582. /**
  44583. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44584. */
  44585. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44586. /**
  44587. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44588. */
  44589. useAmbientInGrayScale: boolean;
  44590. /**
  44591. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44592. * The material will try to infer what glossiness each pixel should be.
  44593. */
  44594. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44595. /**
  44596. * BJS is using an harcoded light falloff based on a manually sets up range.
  44597. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44598. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44599. */
  44600. /**
  44601. * BJS is using an harcoded light falloff based on a manually sets up range.
  44602. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44603. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44604. */
  44605. usePhysicalLightFalloff: boolean;
  44606. /**
  44607. * In order to support the falloff compatibility with gltf, a special mode has been added
  44608. * to reproduce the gltf light falloff.
  44609. */
  44610. /**
  44611. * In order to support the falloff compatibility with gltf, a special mode has been added
  44612. * to reproduce the gltf light falloff.
  44613. */
  44614. useGLTFLightFalloff: boolean;
  44615. /**
  44616. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44617. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44618. */
  44619. useRadianceOverAlpha: boolean;
  44620. /**
  44621. * Allows using an object space normal map (instead of tangent space).
  44622. */
  44623. useObjectSpaceNormalMap: boolean;
  44624. /**
  44625. * Allows using the bump map in parallax mode.
  44626. */
  44627. useParallax: boolean;
  44628. /**
  44629. * Allows using the bump map in parallax occlusion mode.
  44630. */
  44631. useParallaxOcclusion: boolean;
  44632. /**
  44633. * Controls the scale bias of the parallax mode.
  44634. */
  44635. parallaxScaleBias: number;
  44636. /**
  44637. * If sets to true, disables all the lights affecting the material.
  44638. */
  44639. disableLighting: boolean;
  44640. /**
  44641. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44642. */
  44643. forceIrradianceInFragment: boolean;
  44644. /**
  44645. * Number of Simultaneous lights allowed on the material.
  44646. */
  44647. maxSimultaneousLights: number;
  44648. /**
  44649. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44650. */
  44651. invertNormalMapX: boolean;
  44652. /**
  44653. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44654. */
  44655. invertNormalMapY: boolean;
  44656. /**
  44657. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44658. */
  44659. twoSidedLighting: boolean;
  44660. /**
  44661. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44662. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44663. */
  44664. useAlphaFresnel: boolean;
  44665. /**
  44666. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44667. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44668. */
  44669. useLinearAlphaFresnel: boolean;
  44670. /**
  44671. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44672. * And/Or occlude the blended part.
  44673. */
  44674. environmentBRDFTexture: Nullable<BaseTexture>;
  44675. /**
  44676. * Force normal to face away from face.
  44677. */
  44678. forceNormalForward: boolean;
  44679. /**
  44680. * Enables specular anti aliasing in the PBR shader.
  44681. * It will both interacts on the Geometry for analytical and IBL lighting.
  44682. * It also prefilter the roughness map based on the bump values.
  44683. */
  44684. enableSpecularAntiAliasing: boolean;
  44685. /**
  44686. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44687. * makes the reflect vector face the model (under horizon).
  44688. */
  44689. useHorizonOcclusion: boolean;
  44690. /**
  44691. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44692. * too much the area relying on ambient texture to define their ambient occlusion.
  44693. */
  44694. useRadianceOcclusion: boolean;
  44695. /**
  44696. * If set to true, no lighting calculations will be applied.
  44697. */
  44698. unlit: boolean;
  44699. /**
  44700. * Gets the image processing configuration used either in this material.
  44701. */
  44702. /**
  44703. * Sets the Default image processing configuration used either in the this material.
  44704. *
  44705. * If sets to null, the scene one is in use.
  44706. */
  44707. imageProcessingConfiguration: ImageProcessingConfiguration;
  44708. /**
  44709. * Gets wether the color curves effect is enabled.
  44710. */
  44711. /**
  44712. * Sets wether the color curves effect is enabled.
  44713. */
  44714. cameraColorCurvesEnabled: boolean;
  44715. /**
  44716. * Gets wether the color grading effect is enabled.
  44717. */
  44718. /**
  44719. * Gets wether the color grading effect is enabled.
  44720. */
  44721. cameraColorGradingEnabled: boolean;
  44722. /**
  44723. * Gets wether tonemapping is enabled or not.
  44724. */
  44725. /**
  44726. * Sets wether tonemapping is enabled or not
  44727. */
  44728. cameraToneMappingEnabled: boolean;
  44729. /**
  44730. * The camera exposure used on this material.
  44731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44732. * This corresponds to a photographic exposure.
  44733. */
  44734. /**
  44735. * The camera exposure used on this material.
  44736. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44737. * This corresponds to a photographic exposure.
  44738. */
  44739. cameraExposure: number;
  44740. /**
  44741. * Gets The camera contrast used on this material.
  44742. */
  44743. /**
  44744. * Sets The camera contrast used on this material.
  44745. */
  44746. cameraContrast: number;
  44747. /**
  44748. * Gets the Color Grading 2D Lookup Texture.
  44749. */
  44750. /**
  44751. * Sets the Color Grading 2D Lookup Texture.
  44752. */
  44753. cameraColorGradingTexture: Nullable<BaseTexture>;
  44754. /**
  44755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44757. * 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;
  44758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44759. */
  44760. /**
  44761. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44762. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44763. * 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;
  44764. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44765. */
  44766. cameraColorCurves: Nullable<ColorCurves>;
  44767. /**
  44768. * Instantiates a new PBRMaterial instance.
  44769. *
  44770. * @param name The material name
  44771. * @param scene The scene the material will be use in.
  44772. */
  44773. constructor(name: string, scene: Scene);
  44774. /**
  44775. * Returns the name of this material class.
  44776. */
  44777. getClassName(): string;
  44778. /**
  44779. * Returns an array of the actively used textures.
  44780. * @returns - Array of BaseTextures
  44781. */
  44782. getActiveTextures(): BaseTexture[];
  44783. /**
  44784. * Checks to see if a texture is used in the material.
  44785. * @param texture - Base texture to use.
  44786. * @returns - Boolean specifying if a texture is used in the material.
  44787. */
  44788. hasTexture(texture: BaseTexture): boolean;
  44789. /**
  44790. * Makes a duplicate of the current material.
  44791. * @param name - name to use for the new material.
  44792. */
  44793. clone(name: string): PBRMaterial;
  44794. /**
  44795. * Serializes this PBR Material.
  44796. * @returns - An object with the serialized material.
  44797. */
  44798. serialize(): any;
  44799. /**
  44800. * Parses a PBR Material from a serialized object.
  44801. * @param source - Serialized object.
  44802. * @param scene - BJS scene instance.
  44803. * @param rootUrl - url for the scene object
  44804. * @returns - PBRMaterial
  44805. */
  44806. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44807. }
  44808. }
  44809. declare module "babylonjs/Helpers/sceneHelpers" {
  44810. import { Nullable } from "babylonjs/types";
  44811. import { Mesh } from "babylonjs/Meshes/mesh";
  44812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44813. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44814. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44815. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44816. import "babylonjs/Meshes/Builders/boxBuilder";
  44817. /** @hidden */
  44818. export var _forceSceneHelpersToBundle: boolean;
  44819. module "babylonjs/scene" {
  44820. interface Scene {
  44821. /**
  44822. * Creates a default light for the scene.
  44823. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44824. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44825. */
  44826. createDefaultLight(replace?: boolean): void;
  44827. /**
  44828. * Creates a default camera for the scene.
  44829. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44830. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44831. * @param replace has default false, when true replaces the active camera in the scene
  44832. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44833. */
  44834. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44835. /**
  44836. * Creates a default camera and a default light.
  44837. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44838. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44839. * @param replace has the default false, when true replaces the active camera/light in the scene
  44840. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  44841. */
  44842. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44843. /**
  44844. * Creates a new sky box
  44845. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  44846. * @param environmentTexture defines the texture to use as environment texture
  44847. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  44848. * @param scale defines the overall scale of the skybox
  44849. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  44850. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  44851. * @returns a new mesh holding the sky box
  44852. */
  44853. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  44854. /**
  44855. * Creates a new environment
  44856. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  44857. * @param options defines the options you can use to configure the environment
  44858. * @returns the new EnvironmentHelper
  44859. */
  44860. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  44861. /**
  44862. * Creates a new VREXperienceHelper
  44863. * @see http://doc.babylonjs.com/how_to/webvr_helper
  44864. * @param webVROptions defines the options used to create the new VREXperienceHelper
  44865. * @returns a new VREXperienceHelper
  44866. */
  44867. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  44868. /**
  44869. * Creates a new XREXperienceHelper
  44870. * @see http://doc.babylonjs.com/how_to/webxr
  44871. * @returns a promise for a new XREXperienceHelper
  44872. */
  44873. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  44874. }
  44875. }
  44876. }
  44877. declare module "babylonjs/Helpers/videoDome" {
  44878. import { Scene } from "babylonjs/scene";
  44879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44880. import { Mesh } from "babylonjs/Meshes/mesh";
  44881. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  44882. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44883. import "babylonjs/Meshes/Builders/sphereBuilder";
  44884. /**
  44885. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  44886. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  44887. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  44888. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44889. */
  44890. export class VideoDome extends TransformNode {
  44891. private _useDirectMapping;
  44892. /**
  44893. * The video texture being displayed on the sphere
  44894. */
  44895. protected _videoTexture: VideoTexture;
  44896. /**
  44897. * Gets the video texture being displayed on the sphere
  44898. */
  44899. readonly videoTexture: VideoTexture;
  44900. /**
  44901. * The skybox material
  44902. */
  44903. protected _material: BackgroundMaterial;
  44904. /**
  44905. * The surface used for the skybox
  44906. */
  44907. protected _mesh: Mesh;
  44908. /**
  44909. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44910. * Also see the options.resolution property.
  44911. */
  44912. fovMultiplier: number;
  44913. /**
  44914. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  44915. * @param name Element's name, child elements will append suffixes for their own names.
  44916. * @param urlsOrVideo defines the url(s) or the video element to use
  44917. * @param options An object containing optional or exposed sub element properties
  44918. */
  44919. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  44920. resolution?: number;
  44921. clickToPlay?: boolean;
  44922. autoPlay?: boolean;
  44923. loop?: boolean;
  44924. size?: number;
  44925. poster?: string;
  44926. useDirectMapping?: boolean;
  44927. }, scene: Scene);
  44928. /**
  44929. * Releases resources associated with this node.
  44930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44932. */
  44933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44934. }
  44935. }
  44936. declare module "babylonjs/Helpers/index" {
  44937. export * from "babylonjs/Helpers/environmentHelper";
  44938. export * from "babylonjs/Helpers/photoDome";
  44939. export * from "babylonjs/Helpers/sceneHelpers";
  44940. export * from "babylonjs/Helpers/videoDome";
  44941. }
  44942. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  44943. import { PerfCounter } from "babylonjs/Misc/tools";
  44944. import { IDisposable } from "babylonjs/scene";
  44945. import { Engine } from "babylonjs/Engines/engine";
  44946. /**
  44947. * This class can be used to get instrumentation data from a Babylon engine
  44948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44949. */
  44950. export class EngineInstrumentation implements IDisposable {
  44951. /**
  44952. * Define the instrumented engine.
  44953. */
  44954. engine: Engine;
  44955. private _captureGPUFrameTime;
  44956. private _gpuFrameTimeToken;
  44957. private _gpuFrameTime;
  44958. private _captureShaderCompilationTime;
  44959. private _shaderCompilationTime;
  44960. private _onBeginFrameObserver;
  44961. private _onEndFrameObserver;
  44962. private _onBeforeShaderCompilationObserver;
  44963. private _onAfterShaderCompilationObserver;
  44964. /**
  44965. * Gets the perf counter used for GPU frame time
  44966. */
  44967. readonly gpuFrameTimeCounter: PerfCounter;
  44968. /**
  44969. * Gets the GPU frame time capture status
  44970. */
  44971. /**
  44972. * Enable or disable the GPU frame time capture
  44973. */
  44974. captureGPUFrameTime: boolean;
  44975. /**
  44976. * Gets the perf counter used for shader compilation time
  44977. */
  44978. readonly shaderCompilationTimeCounter: PerfCounter;
  44979. /**
  44980. * Gets the shader compilation time capture status
  44981. */
  44982. /**
  44983. * Enable or disable the shader compilation time capture
  44984. */
  44985. captureShaderCompilationTime: boolean;
  44986. /**
  44987. * Instantiates a new engine instrumentation.
  44988. * This class can be used to get instrumentation data from a Babylon engine
  44989. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44990. * @param engine Defines the engine to instrument
  44991. */
  44992. constructor(
  44993. /**
  44994. * Define the instrumented engine.
  44995. */
  44996. engine: Engine);
  44997. /**
  44998. * Dispose and release associated resources.
  44999. */
  45000. dispose(): void;
  45001. }
  45002. }
  45003. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45004. import { PerfCounter } from "babylonjs/Misc/tools";
  45005. import { Scene, IDisposable } from "babylonjs/scene";
  45006. /**
  45007. * This class can be used to get instrumentation data from a Babylon engine
  45008. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45009. */
  45010. export class SceneInstrumentation implements IDisposable {
  45011. /**
  45012. * Defines the scene to instrument
  45013. */
  45014. scene: Scene;
  45015. private _captureActiveMeshesEvaluationTime;
  45016. private _activeMeshesEvaluationTime;
  45017. private _captureRenderTargetsRenderTime;
  45018. private _renderTargetsRenderTime;
  45019. private _captureFrameTime;
  45020. private _frameTime;
  45021. private _captureRenderTime;
  45022. private _renderTime;
  45023. private _captureInterFrameTime;
  45024. private _interFrameTime;
  45025. private _captureParticlesRenderTime;
  45026. private _particlesRenderTime;
  45027. private _captureSpritesRenderTime;
  45028. private _spritesRenderTime;
  45029. private _capturePhysicsTime;
  45030. private _physicsTime;
  45031. private _captureAnimationsTime;
  45032. private _animationsTime;
  45033. private _captureCameraRenderTime;
  45034. private _cameraRenderTime;
  45035. private _onBeforeActiveMeshesEvaluationObserver;
  45036. private _onAfterActiveMeshesEvaluationObserver;
  45037. private _onBeforeRenderTargetsRenderObserver;
  45038. private _onAfterRenderTargetsRenderObserver;
  45039. private _onAfterRenderObserver;
  45040. private _onBeforeDrawPhaseObserver;
  45041. private _onAfterDrawPhaseObserver;
  45042. private _onBeforeAnimationsObserver;
  45043. private _onBeforeParticlesRenderingObserver;
  45044. private _onAfterParticlesRenderingObserver;
  45045. private _onBeforeSpritesRenderingObserver;
  45046. private _onAfterSpritesRenderingObserver;
  45047. private _onBeforePhysicsObserver;
  45048. private _onAfterPhysicsObserver;
  45049. private _onAfterAnimationsObserver;
  45050. private _onBeforeCameraRenderObserver;
  45051. private _onAfterCameraRenderObserver;
  45052. /**
  45053. * Gets the perf counter used for active meshes evaluation time
  45054. */
  45055. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45056. /**
  45057. * Gets the active meshes evaluation time capture status
  45058. */
  45059. /**
  45060. * Enable or disable the active meshes evaluation time capture
  45061. */
  45062. captureActiveMeshesEvaluationTime: boolean;
  45063. /**
  45064. * Gets the perf counter used for render targets render time
  45065. */
  45066. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45067. /**
  45068. * Gets the render targets render time capture status
  45069. */
  45070. /**
  45071. * Enable or disable the render targets render time capture
  45072. */
  45073. captureRenderTargetsRenderTime: boolean;
  45074. /**
  45075. * Gets the perf counter used for particles render time
  45076. */
  45077. readonly particlesRenderTimeCounter: PerfCounter;
  45078. /**
  45079. * Gets the particles render time capture status
  45080. */
  45081. /**
  45082. * Enable or disable the particles render time capture
  45083. */
  45084. captureParticlesRenderTime: boolean;
  45085. /**
  45086. * Gets the perf counter used for sprites render time
  45087. */
  45088. readonly spritesRenderTimeCounter: PerfCounter;
  45089. /**
  45090. * Gets the sprites render time capture status
  45091. */
  45092. /**
  45093. * Enable or disable the sprites render time capture
  45094. */
  45095. captureSpritesRenderTime: boolean;
  45096. /**
  45097. * Gets the perf counter used for physics time
  45098. */
  45099. readonly physicsTimeCounter: PerfCounter;
  45100. /**
  45101. * Gets the physics time capture status
  45102. */
  45103. /**
  45104. * Enable or disable the physics time capture
  45105. */
  45106. capturePhysicsTime: boolean;
  45107. /**
  45108. * Gets the perf counter used for animations time
  45109. */
  45110. readonly animationsTimeCounter: PerfCounter;
  45111. /**
  45112. * Gets the animations time capture status
  45113. */
  45114. /**
  45115. * Enable or disable the animations time capture
  45116. */
  45117. captureAnimationsTime: boolean;
  45118. /**
  45119. * Gets the perf counter used for frame time capture
  45120. */
  45121. readonly frameTimeCounter: PerfCounter;
  45122. /**
  45123. * Gets the frame time capture status
  45124. */
  45125. /**
  45126. * Enable or disable the frame time capture
  45127. */
  45128. captureFrameTime: boolean;
  45129. /**
  45130. * Gets the perf counter used for inter-frames time capture
  45131. */
  45132. readonly interFrameTimeCounter: PerfCounter;
  45133. /**
  45134. * Gets the inter-frames time capture status
  45135. */
  45136. /**
  45137. * Enable or disable the inter-frames time capture
  45138. */
  45139. captureInterFrameTime: boolean;
  45140. /**
  45141. * Gets the perf counter used for render time capture
  45142. */
  45143. readonly renderTimeCounter: PerfCounter;
  45144. /**
  45145. * Gets the render time capture status
  45146. */
  45147. /**
  45148. * Enable or disable the render time capture
  45149. */
  45150. captureRenderTime: boolean;
  45151. /**
  45152. * Gets the perf counter used for camera render time capture
  45153. */
  45154. readonly cameraRenderTimeCounter: PerfCounter;
  45155. /**
  45156. * Gets the camera render time capture status
  45157. */
  45158. /**
  45159. * Enable or disable the camera render time capture
  45160. */
  45161. captureCameraRenderTime: boolean;
  45162. /**
  45163. * Gets the perf counter used for draw calls
  45164. */
  45165. readonly drawCallsCounter: PerfCounter;
  45166. /**
  45167. * Gets the perf counter used for texture collisions
  45168. */
  45169. readonly textureCollisionsCounter: PerfCounter;
  45170. /**
  45171. * Instantiates a new scene instrumentation.
  45172. * This class can be used to get instrumentation data from a Babylon engine
  45173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45174. * @param scene Defines the scene to instrument
  45175. */
  45176. constructor(
  45177. /**
  45178. * Defines the scene to instrument
  45179. */
  45180. scene: Scene);
  45181. /**
  45182. * Dispose and release associated resources.
  45183. */
  45184. dispose(): void;
  45185. }
  45186. }
  45187. declare module "babylonjs/Instrumentation/index" {
  45188. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45189. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45190. export * from "babylonjs/Instrumentation/timeToken";
  45191. }
  45192. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45193. /** @hidden */
  45194. export var glowMapGenerationPixelShader: {
  45195. name: string;
  45196. shader: string;
  45197. };
  45198. }
  45199. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45200. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45202. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45203. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45205. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45206. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45207. /** @hidden */
  45208. export var glowMapGenerationVertexShader: {
  45209. name: string;
  45210. shader: string;
  45211. };
  45212. }
  45213. declare module "babylonjs/Layers/effectLayer" {
  45214. import { Observable } from "babylonjs/Misc/observable";
  45215. import { Nullable } from "babylonjs/types";
  45216. import { Camera } from "babylonjs/Cameras/camera";
  45217. import { Scene } from "babylonjs/scene";
  45218. import { Color4, ISize } from "babylonjs/Maths/math";
  45219. import { Engine } from "babylonjs/Engines/engine";
  45220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45222. import { Mesh } from "babylonjs/Meshes/mesh";
  45223. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45226. import { Effect } from "babylonjs/Materials/effect";
  45227. import { Material } from "babylonjs/Materials/material";
  45228. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45229. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45230. /**
  45231. * Effect layer options. This helps customizing the behaviour
  45232. * of the effect layer.
  45233. */
  45234. export interface IEffectLayerOptions {
  45235. /**
  45236. * Multiplication factor apply to the canvas size to compute the render target size
  45237. * used to generated the objects (the smaller the faster).
  45238. */
  45239. mainTextureRatio: number;
  45240. /**
  45241. * Enforces a fixed size texture to ensure effect stability across devices.
  45242. */
  45243. mainTextureFixedSize?: number;
  45244. /**
  45245. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45246. */
  45247. alphaBlendingMode: number;
  45248. /**
  45249. * The camera attached to the layer.
  45250. */
  45251. camera: Nullable<Camera>;
  45252. /**
  45253. * The rendering group to draw the layer in.
  45254. */
  45255. renderingGroupId: number;
  45256. }
  45257. /**
  45258. * The effect layer Helps adding post process effect blended with the main pass.
  45259. *
  45260. * This can be for instance use to generate glow or higlight effects on the scene.
  45261. *
  45262. * The effect layer class can not be used directly and is intented to inherited from to be
  45263. * customized per effects.
  45264. */
  45265. export abstract class EffectLayer {
  45266. private _vertexBuffers;
  45267. private _indexBuffer;
  45268. private _cachedDefines;
  45269. private _effectLayerMapGenerationEffect;
  45270. private _effectLayerOptions;
  45271. private _mergeEffect;
  45272. protected _scene: Scene;
  45273. protected _engine: Engine;
  45274. protected _maxSize: number;
  45275. protected _mainTextureDesiredSize: ISize;
  45276. protected _mainTexture: RenderTargetTexture;
  45277. protected _shouldRender: boolean;
  45278. protected _postProcesses: PostProcess[];
  45279. protected _textures: BaseTexture[];
  45280. protected _emissiveTextureAndColor: {
  45281. texture: Nullable<BaseTexture>;
  45282. color: Color4;
  45283. };
  45284. /**
  45285. * The name of the layer
  45286. */
  45287. name: string;
  45288. /**
  45289. * The clear color of the texture used to generate the glow map.
  45290. */
  45291. neutralColor: Color4;
  45292. /**
  45293. * Specifies wether the highlight layer is enabled or not.
  45294. */
  45295. isEnabled: boolean;
  45296. /**
  45297. * Gets the camera attached to the layer.
  45298. */
  45299. readonly camera: Nullable<Camera>;
  45300. /**
  45301. * Gets the rendering group id the layer should render in.
  45302. */
  45303. readonly renderingGroupId: number;
  45304. /**
  45305. * An event triggered when the effect layer has been disposed.
  45306. */
  45307. onDisposeObservable: Observable<EffectLayer>;
  45308. /**
  45309. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45310. */
  45311. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45312. /**
  45313. * An event triggered when the generated texture is being merged in the scene.
  45314. */
  45315. onBeforeComposeObservable: Observable<EffectLayer>;
  45316. /**
  45317. * An event triggered when the generated texture has been merged in the scene.
  45318. */
  45319. onAfterComposeObservable: Observable<EffectLayer>;
  45320. /**
  45321. * An event triggered when the efffect layer changes its size.
  45322. */
  45323. onSizeChangedObservable: Observable<EffectLayer>;
  45324. /** @hidden */
  45325. static _SceneComponentInitialization: (scene: Scene) => void;
  45326. /**
  45327. * Instantiates a new effect Layer and references it in the scene.
  45328. * @param name The name of the layer
  45329. * @param scene The scene to use the layer in
  45330. */
  45331. constructor(
  45332. /** The Friendly of the effect in the scene */
  45333. name: string, scene: Scene);
  45334. /**
  45335. * Get the effect name of the layer.
  45336. * @return The effect name
  45337. */
  45338. abstract getEffectName(): string;
  45339. /**
  45340. * Checks for the readiness of the element composing the layer.
  45341. * @param subMesh the mesh to check for
  45342. * @param useInstances specify wether or not to use instances to render the mesh
  45343. * @return true if ready otherwise, false
  45344. */
  45345. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45346. /**
  45347. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45348. * @returns true if the effect requires stencil during the main canvas render pass.
  45349. */
  45350. abstract needStencil(): boolean;
  45351. /**
  45352. * Create the merge effect. This is the shader use to blit the information back
  45353. * to the main canvas at the end of the scene rendering.
  45354. * @returns The effect containing the shader used to merge the effect on the main canvas
  45355. */
  45356. protected abstract _createMergeEffect(): Effect;
  45357. /**
  45358. * Creates the render target textures and post processes used in the effect layer.
  45359. */
  45360. protected abstract _createTextureAndPostProcesses(): void;
  45361. /**
  45362. * Implementation specific of rendering the generating effect on the main canvas.
  45363. * @param effect The effect used to render through
  45364. */
  45365. protected abstract _internalRender(effect: Effect): void;
  45366. /**
  45367. * Sets the required values for both the emissive texture and and the main color.
  45368. */
  45369. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45370. /**
  45371. * Free any resources and references associated to a mesh.
  45372. * Internal use
  45373. * @param mesh The mesh to free.
  45374. */
  45375. abstract _disposeMesh(mesh: Mesh): void;
  45376. /**
  45377. * Serializes this layer (Glow or Highlight for example)
  45378. * @returns a serialized layer object
  45379. */
  45380. abstract serialize?(): any;
  45381. /**
  45382. * Initializes the effect layer with the required options.
  45383. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45384. */
  45385. protected _init(options: Partial<IEffectLayerOptions>): void;
  45386. /**
  45387. * Generates the index buffer of the full screen quad blending to the main canvas.
  45388. */
  45389. private _generateIndexBuffer;
  45390. /**
  45391. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45392. */
  45393. private _genrateVertexBuffer;
  45394. /**
  45395. * Sets the main texture desired size which is the closest power of two
  45396. * of the engine canvas size.
  45397. */
  45398. private _setMainTextureSize;
  45399. /**
  45400. * Creates the main texture for the effect layer.
  45401. */
  45402. protected _createMainTexture(): void;
  45403. /**
  45404. * Adds specific effects defines.
  45405. * @param defines The defines to add specifics to.
  45406. */
  45407. protected _addCustomEffectDefines(defines: string[]): void;
  45408. /**
  45409. * Checks for the readiness of the element composing the layer.
  45410. * @param subMesh the mesh to check for
  45411. * @param useInstances specify wether or not to use instances to render the mesh
  45412. * @param emissiveTexture the associated emissive texture used to generate the glow
  45413. * @return true if ready otherwise, false
  45414. */
  45415. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45416. /**
  45417. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45418. */
  45419. render(): void;
  45420. /**
  45421. * Determine if a given mesh will be used in the current effect.
  45422. * @param mesh mesh to test
  45423. * @returns true if the mesh will be used
  45424. */
  45425. hasMesh(mesh: AbstractMesh): boolean;
  45426. /**
  45427. * Returns true if the layer contains information to display, otherwise false.
  45428. * @returns true if the glow layer should be rendered
  45429. */
  45430. shouldRender(): boolean;
  45431. /**
  45432. * Returns true if the mesh should render, otherwise false.
  45433. * @param mesh The mesh to render
  45434. * @returns true if it should render otherwise false
  45435. */
  45436. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45437. /**
  45438. * Returns true if the mesh can be rendered, otherwise false.
  45439. * @param mesh The mesh to render
  45440. * @param material The material used on the mesh
  45441. * @returns true if it can be rendered otherwise false
  45442. */
  45443. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45444. /**
  45445. * Returns true if the mesh should render, otherwise false.
  45446. * @param mesh The mesh to render
  45447. * @returns true if it should render otherwise false
  45448. */
  45449. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45450. /**
  45451. * Renders the submesh passed in parameter to the generation map.
  45452. */
  45453. protected _renderSubMesh(subMesh: SubMesh): void;
  45454. /**
  45455. * Rebuild the required buffers.
  45456. * @hidden Internal use only.
  45457. */
  45458. _rebuild(): void;
  45459. /**
  45460. * Dispose only the render target textures and post process.
  45461. */
  45462. private _disposeTextureAndPostProcesses;
  45463. /**
  45464. * Dispose the highlight layer and free resources.
  45465. */
  45466. dispose(): void;
  45467. /**
  45468. * Gets the class name of the effect layer
  45469. * @returns the string with the class name of the effect layer
  45470. */
  45471. getClassName(): string;
  45472. /**
  45473. * Creates an effect layer from parsed effect layer data
  45474. * @param parsedEffectLayer defines effect layer data
  45475. * @param scene defines the current scene
  45476. * @param rootUrl defines the root URL containing the effect layer information
  45477. * @returns a parsed effect Layer
  45478. */
  45479. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45480. }
  45481. }
  45482. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45483. import { Scene } from "babylonjs/scene";
  45484. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45485. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45486. import { AbstractScene } from "babylonjs/abstractScene";
  45487. module "babylonjs/abstractScene" {
  45488. interface AbstractScene {
  45489. /**
  45490. * The list of effect layers (highlights/glow) added to the scene
  45491. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45492. * @see http://doc.babylonjs.com/how_to/glow_layer
  45493. */
  45494. effectLayers: Array<EffectLayer>;
  45495. /**
  45496. * Removes the given effect layer from this scene.
  45497. * @param toRemove defines the effect layer to remove
  45498. * @returns the index of the removed effect layer
  45499. */
  45500. removeEffectLayer(toRemove: EffectLayer): number;
  45501. /**
  45502. * Adds the given effect layer to this scene
  45503. * @param newEffectLayer defines the effect layer to add
  45504. */
  45505. addEffectLayer(newEffectLayer: EffectLayer): void;
  45506. }
  45507. }
  45508. /**
  45509. * Defines the layer scene component responsible to manage any effect layers
  45510. * in a given scene.
  45511. */
  45512. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45513. /**
  45514. * The component name helpfull to identify the component in the list of scene components.
  45515. */
  45516. readonly name: string;
  45517. /**
  45518. * The scene the component belongs to.
  45519. */
  45520. scene: Scene;
  45521. private _engine;
  45522. private _renderEffects;
  45523. private _needStencil;
  45524. private _previousStencilState;
  45525. /**
  45526. * Creates a new instance of the component for the given scene
  45527. * @param scene Defines the scene to register the component in
  45528. */
  45529. constructor(scene: Scene);
  45530. /**
  45531. * Registers the component in a given scene
  45532. */
  45533. register(): void;
  45534. /**
  45535. * Rebuilds the elements related to this component in case of
  45536. * context lost for instance.
  45537. */
  45538. rebuild(): void;
  45539. /**
  45540. * Serializes the component data to the specified json object
  45541. * @param serializationObject The object to serialize to
  45542. */
  45543. serialize(serializationObject: any): void;
  45544. /**
  45545. * Adds all the element from the container to the scene
  45546. * @param container the container holding the elements
  45547. */
  45548. addFromContainer(container: AbstractScene): void;
  45549. /**
  45550. * Removes all the elements in the container from the scene
  45551. * @param container contains the elements to remove
  45552. */
  45553. removeFromContainer(container: AbstractScene): void;
  45554. /**
  45555. * Disposes the component and the associated ressources.
  45556. */
  45557. dispose(): void;
  45558. private _isReadyForMesh;
  45559. private _renderMainTexture;
  45560. private _setStencil;
  45561. private _setStencilBack;
  45562. private _draw;
  45563. private _drawCamera;
  45564. private _drawRenderingGroup;
  45565. }
  45566. }
  45567. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45568. /** @hidden */
  45569. export var glowMapMergePixelShader: {
  45570. name: string;
  45571. shader: string;
  45572. };
  45573. }
  45574. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45575. /** @hidden */
  45576. export var glowMapMergeVertexShader: {
  45577. name: string;
  45578. shader: string;
  45579. };
  45580. }
  45581. declare module "babylonjs/Layers/glowLayer" {
  45582. import { Nullable } from "babylonjs/types";
  45583. import { Camera } from "babylonjs/Cameras/camera";
  45584. import { Scene } from "babylonjs/scene";
  45585. import { Color4 } from "babylonjs/Maths/math";
  45586. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45588. import { Mesh } from "babylonjs/Meshes/mesh";
  45589. import { Texture } from "babylonjs/Materials/Textures/texture";
  45590. import { Effect } from "babylonjs/Materials/effect";
  45591. import { Material } from "babylonjs/Materials/material";
  45592. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45593. import "babylonjs/Shaders/glowMapMerge.fragment";
  45594. import "babylonjs/Shaders/glowMapMerge.vertex";
  45595. module "babylonjs/abstractScene" {
  45596. interface AbstractScene {
  45597. /**
  45598. * Return a the first highlight layer of the scene with a given name.
  45599. * @param name The name of the highlight layer to look for.
  45600. * @return The highlight layer if found otherwise null.
  45601. */
  45602. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45603. }
  45604. }
  45605. /**
  45606. * Glow layer options. This helps customizing the behaviour
  45607. * of the glow layer.
  45608. */
  45609. export interface IGlowLayerOptions {
  45610. /**
  45611. * Multiplication factor apply to the canvas size to compute the render target size
  45612. * used to generated the glowing objects (the smaller the faster).
  45613. */
  45614. mainTextureRatio: number;
  45615. /**
  45616. * Enforces a fixed size texture to ensure resize independant blur.
  45617. */
  45618. mainTextureFixedSize?: number;
  45619. /**
  45620. * How big is the kernel of the blur texture.
  45621. */
  45622. blurKernelSize: number;
  45623. /**
  45624. * The camera attached to the layer.
  45625. */
  45626. camera: Nullable<Camera>;
  45627. /**
  45628. * Enable MSAA by chosing the number of samples.
  45629. */
  45630. mainTextureSamples?: number;
  45631. /**
  45632. * The rendering group to draw the layer in.
  45633. */
  45634. renderingGroupId: number;
  45635. }
  45636. /**
  45637. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45638. *
  45639. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45640. * glowy meshes to your scene.
  45641. *
  45642. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45643. */
  45644. export class GlowLayer extends EffectLayer {
  45645. /**
  45646. * Effect Name of the layer.
  45647. */
  45648. static readonly EffectName: string;
  45649. /**
  45650. * The default blur kernel size used for the glow.
  45651. */
  45652. static DefaultBlurKernelSize: number;
  45653. /**
  45654. * The default texture size ratio used for the glow.
  45655. */
  45656. static DefaultTextureRatio: number;
  45657. /**
  45658. * Sets the kernel size of the blur.
  45659. */
  45660. /**
  45661. * Gets the kernel size of the blur.
  45662. */
  45663. blurKernelSize: number;
  45664. /**
  45665. * Sets the glow intensity.
  45666. */
  45667. /**
  45668. * Gets the glow intensity.
  45669. */
  45670. intensity: number;
  45671. private _options;
  45672. private _intensity;
  45673. private _horizontalBlurPostprocess1;
  45674. private _verticalBlurPostprocess1;
  45675. private _horizontalBlurPostprocess2;
  45676. private _verticalBlurPostprocess2;
  45677. private _blurTexture1;
  45678. private _blurTexture2;
  45679. private _postProcesses1;
  45680. private _postProcesses2;
  45681. private _includedOnlyMeshes;
  45682. private _excludedMeshes;
  45683. /**
  45684. * Callback used to let the user override the color selection on a per mesh basis
  45685. */
  45686. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45687. /**
  45688. * Callback used to let the user override the texture selection on a per mesh basis
  45689. */
  45690. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45691. /**
  45692. * Instantiates a new glow Layer and references it to the scene.
  45693. * @param name The name of the layer
  45694. * @param scene The scene to use the layer in
  45695. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45696. */
  45697. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45698. /**
  45699. * Get the effect name of the layer.
  45700. * @return The effect name
  45701. */
  45702. getEffectName(): string;
  45703. /**
  45704. * Create the merge effect. This is the shader use to blit the information back
  45705. * to the main canvas at the end of the scene rendering.
  45706. */
  45707. protected _createMergeEffect(): Effect;
  45708. /**
  45709. * Creates the render target textures and post processes used in the glow layer.
  45710. */
  45711. protected _createTextureAndPostProcesses(): void;
  45712. /**
  45713. * Checks for the readiness of the element composing the layer.
  45714. * @param subMesh the mesh to check for
  45715. * @param useInstances specify wether or not to use instances to render the mesh
  45716. * @param emissiveTexture the associated emissive texture used to generate the glow
  45717. * @return true if ready otherwise, false
  45718. */
  45719. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45720. /**
  45721. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45722. */
  45723. needStencil(): boolean;
  45724. /**
  45725. * Returns true if the mesh can be rendered, otherwise false.
  45726. * @param mesh The mesh to render
  45727. * @param material The material used on the mesh
  45728. * @returns true if it can be rendered otherwise false
  45729. */
  45730. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45731. /**
  45732. * Implementation specific of rendering the generating effect on the main canvas.
  45733. * @param effect The effect used to render through
  45734. */
  45735. protected _internalRender(effect: Effect): void;
  45736. /**
  45737. * Sets the required values for both the emissive texture and and the main color.
  45738. */
  45739. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45740. /**
  45741. * Returns true if the mesh should render, otherwise false.
  45742. * @param mesh The mesh to render
  45743. * @returns true if it should render otherwise false
  45744. */
  45745. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45746. /**
  45747. * Adds specific effects defines.
  45748. * @param defines The defines to add specifics to.
  45749. */
  45750. protected _addCustomEffectDefines(defines: string[]): void;
  45751. /**
  45752. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45753. * @param mesh The mesh to exclude from the glow layer
  45754. */
  45755. addExcludedMesh(mesh: Mesh): void;
  45756. /**
  45757. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45758. * @param mesh The mesh to remove
  45759. */
  45760. removeExcludedMesh(mesh: Mesh): void;
  45761. /**
  45762. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45763. * @param mesh The mesh to include in the glow layer
  45764. */
  45765. addIncludedOnlyMesh(mesh: Mesh): void;
  45766. /**
  45767. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45768. * @param mesh The mesh to remove
  45769. */
  45770. removeIncludedOnlyMesh(mesh: Mesh): void;
  45771. /**
  45772. * Determine if a given mesh will be used in the glow layer
  45773. * @param mesh The mesh to test
  45774. * @returns true if the mesh will be highlighted by the current glow layer
  45775. */
  45776. hasMesh(mesh: AbstractMesh): boolean;
  45777. /**
  45778. * Free any resources and references associated to a mesh.
  45779. * Internal use
  45780. * @param mesh The mesh to free.
  45781. * @hidden
  45782. */
  45783. _disposeMesh(mesh: Mesh): void;
  45784. /**
  45785. * Gets the class name of the effect layer
  45786. * @returns the string with the class name of the effect layer
  45787. */
  45788. getClassName(): string;
  45789. /**
  45790. * Serializes this glow layer
  45791. * @returns a serialized glow layer object
  45792. */
  45793. serialize(): any;
  45794. /**
  45795. * Creates a Glow Layer from parsed glow layer data
  45796. * @param parsedGlowLayer defines glow layer data
  45797. * @param scene defines the current scene
  45798. * @param rootUrl defines the root URL containing the glow layer information
  45799. * @returns a parsed Glow Layer
  45800. */
  45801. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45802. }
  45803. }
  45804. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45805. /** @hidden */
  45806. export var glowBlurPostProcessPixelShader: {
  45807. name: string;
  45808. shader: string;
  45809. };
  45810. }
  45811. declare module "babylonjs/Layers/highlightLayer" {
  45812. import { Observable } from "babylonjs/Misc/observable";
  45813. import { Nullable } from "babylonjs/types";
  45814. import { Camera } from "babylonjs/Cameras/camera";
  45815. import { Scene } from "babylonjs/scene";
  45816. import { Color3, Color4 } from "babylonjs/Maths/math";
  45817. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45819. import { Mesh } from "babylonjs/Meshes/mesh";
  45820. import { Effect } from "babylonjs/Materials/effect";
  45821. import { Material } from "babylonjs/Materials/material";
  45822. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45823. import "babylonjs/Shaders/glowMapMerge.fragment";
  45824. import "babylonjs/Shaders/glowMapMerge.vertex";
  45825. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  45826. module "babylonjs/abstractScene" {
  45827. interface AbstractScene {
  45828. /**
  45829. * Return a the first highlight layer of the scene with a given name.
  45830. * @param name The name of the highlight layer to look for.
  45831. * @return The highlight layer if found otherwise null.
  45832. */
  45833. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45834. }
  45835. }
  45836. /**
  45837. * Highlight layer options. This helps customizing the behaviour
  45838. * of the highlight layer.
  45839. */
  45840. export interface IHighlightLayerOptions {
  45841. /**
  45842. * Multiplication factor apply to the canvas size to compute the render target size
  45843. * used to generated the glowing objects (the smaller the faster).
  45844. */
  45845. mainTextureRatio: number;
  45846. /**
  45847. * Enforces a fixed size texture to ensure resize independant blur.
  45848. */
  45849. mainTextureFixedSize?: number;
  45850. /**
  45851. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45852. * of the picture to blur (the smaller the faster).
  45853. */
  45854. blurTextureSizeRatio: number;
  45855. /**
  45856. * How big in texel of the blur texture is the vertical blur.
  45857. */
  45858. blurVerticalSize: number;
  45859. /**
  45860. * How big in texel of the blur texture is the horizontal blur.
  45861. */
  45862. blurHorizontalSize: number;
  45863. /**
  45864. * Alpha blending mode used to apply the blur. Default is combine.
  45865. */
  45866. alphaBlendingMode: number;
  45867. /**
  45868. * The camera attached to the layer.
  45869. */
  45870. camera: Nullable<Camera>;
  45871. /**
  45872. * Should we display highlight as a solid stroke?
  45873. */
  45874. isStroke?: boolean;
  45875. /**
  45876. * The rendering group to draw the layer in.
  45877. */
  45878. renderingGroupId: number;
  45879. }
  45880. /**
  45881. * The highlight layer Helps adding a glow effect around a mesh.
  45882. *
  45883. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45884. * glowy meshes to your scene.
  45885. *
  45886. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  45887. */
  45888. export class HighlightLayer extends EffectLayer {
  45889. name: string;
  45890. /**
  45891. * Effect Name of the highlight layer.
  45892. */
  45893. static readonly EffectName: string;
  45894. /**
  45895. * The neutral color used during the preparation of the glow effect.
  45896. * This is black by default as the blend operation is a blend operation.
  45897. */
  45898. static NeutralColor: Color4;
  45899. /**
  45900. * Stencil value used for glowing meshes.
  45901. */
  45902. static GlowingMeshStencilReference: number;
  45903. /**
  45904. * Stencil value used for the other meshes in the scene.
  45905. */
  45906. static NormalMeshStencilReference: number;
  45907. /**
  45908. * Specifies whether or not the inner glow is ACTIVE in the layer.
  45909. */
  45910. innerGlow: boolean;
  45911. /**
  45912. * Specifies whether or not the outer glow is ACTIVE in the layer.
  45913. */
  45914. outerGlow: boolean;
  45915. /**
  45916. * Specifies the horizontal size of the blur.
  45917. */
  45918. /**
  45919. * Gets the horizontal size of the blur.
  45920. */
  45921. blurHorizontalSize: number;
  45922. /**
  45923. * Specifies the vertical size of the blur.
  45924. */
  45925. /**
  45926. * Gets the vertical size of the blur.
  45927. */
  45928. blurVerticalSize: number;
  45929. /**
  45930. * An event triggered when the highlight layer is being blurred.
  45931. */
  45932. onBeforeBlurObservable: Observable<HighlightLayer>;
  45933. /**
  45934. * An event triggered when the highlight layer has been blurred.
  45935. */
  45936. onAfterBlurObservable: Observable<HighlightLayer>;
  45937. private _instanceGlowingMeshStencilReference;
  45938. private _options;
  45939. private _downSamplePostprocess;
  45940. private _horizontalBlurPostprocess;
  45941. private _verticalBlurPostprocess;
  45942. private _blurTexture;
  45943. private _meshes;
  45944. private _excludedMeshes;
  45945. /**
  45946. * Instantiates a new highlight Layer and references it to the scene..
  45947. * @param name The name of the layer
  45948. * @param scene The scene to use the layer in
  45949. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  45950. */
  45951. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  45952. /**
  45953. * Get the effect name of the layer.
  45954. * @return The effect name
  45955. */
  45956. getEffectName(): string;
  45957. /**
  45958. * Create the merge effect. This is the shader use to blit the information back
  45959. * to the main canvas at the end of the scene rendering.
  45960. */
  45961. protected _createMergeEffect(): Effect;
  45962. /**
  45963. * Creates the render target textures and post processes used in the highlight layer.
  45964. */
  45965. protected _createTextureAndPostProcesses(): void;
  45966. /**
  45967. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45968. */
  45969. needStencil(): boolean;
  45970. /**
  45971. * Checks for the readiness of the element composing the layer.
  45972. * @param subMesh the mesh to check for
  45973. * @param useInstances specify wether or not to use instances to render the mesh
  45974. * @param emissiveTexture the associated emissive texture used to generate the glow
  45975. * @return true if ready otherwise, false
  45976. */
  45977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45978. /**
  45979. * Implementation specific of rendering the generating effect on the main canvas.
  45980. * @param effect The effect used to render through
  45981. */
  45982. protected _internalRender(effect: Effect): void;
  45983. /**
  45984. * Returns true if the layer contains information to display, otherwise false.
  45985. */
  45986. shouldRender(): boolean;
  45987. /**
  45988. * Returns true if the mesh should render, otherwise false.
  45989. * @param mesh The mesh to render
  45990. * @returns true if it should render otherwise false
  45991. */
  45992. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45993. /**
  45994. * Sets the required values for both the emissive texture and and the main color.
  45995. */
  45996. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45997. /**
  45998. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  45999. * @param mesh The mesh to exclude from the highlight layer
  46000. */
  46001. addExcludedMesh(mesh: Mesh): void;
  46002. /**
  46003. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46004. * @param mesh The mesh to highlight
  46005. */
  46006. removeExcludedMesh(mesh: Mesh): void;
  46007. /**
  46008. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46009. * @param mesh mesh to test
  46010. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46011. */
  46012. hasMesh(mesh: AbstractMesh): boolean;
  46013. /**
  46014. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46015. * @param mesh The mesh to highlight
  46016. * @param color The color of the highlight
  46017. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46018. */
  46019. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46020. /**
  46021. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46022. * @param mesh The mesh to highlight
  46023. */
  46024. removeMesh(mesh: Mesh): void;
  46025. /**
  46026. * Force the stencil to the normal expected value for none glowing parts
  46027. */
  46028. private _defaultStencilReference;
  46029. /**
  46030. * Free any resources and references associated to a mesh.
  46031. * Internal use
  46032. * @param mesh The mesh to free.
  46033. * @hidden
  46034. */
  46035. _disposeMesh(mesh: Mesh): void;
  46036. /**
  46037. * Dispose the highlight layer and free resources.
  46038. */
  46039. dispose(): void;
  46040. /**
  46041. * Gets the class name of the effect layer
  46042. * @returns the string with the class name of the effect layer
  46043. */
  46044. getClassName(): string;
  46045. /**
  46046. * Serializes this Highlight layer
  46047. * @returns a serialized Highlight layer object
  46048. */
  46049. serialize(): any;
  46050. /**
  46051. * Creates a Highlight layer from parsed Highlight layer data
  46052. * @param parsedHightlightLayer defines the Highlight layer data
  46053. * @param scene defines the current scene
  46054. * @param rootUrl defines the root URL containing the Highlight layer information
  46055. * @returns a parsed Highlight layer
  46056. */
  46057. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46058. }
  46059. }
  46060. declare module "babylonjs/Layers/index" {
  46061. export * from "babylonjs/Layers/effectLayer";
  46062. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46063. export * from "babylonjs/Layers/glowLayer";
  46064. export * from "babylonjs/Layers/highlightLayer";
  46065. export * from "babylonjs/Layers/layer";
  46066. export * from "babylonjs/Layers/layerSceneComponent";
  46067. }
  46068. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46069. /** @hidden */
  46070. export var lensFlarePixelShader: {
  46071. name: string;
  46072. shader: string;
  46073. };
  46074. }
  46075. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46076. /** @hidden */
  46077. export var lensFlareVertexShader: {
  46078. name: string;
  46079. shader: string;
  46080. };
  46081. }
  46082. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46083. import { Scene } from "babylonjs/scene";
  46084. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46086. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46087. import "babylonjs/Shaders/lensFlare.fragment";
  46088. import "babylonjs/Shaders/lensFlare.vertex";
  46089. /**
  46090. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46091. * It is usually composed of several `lensFlare`.
  46092. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46093. */
  46094. export class LensFlareSystem {
  46095. /**
  46096. * Define the name of the lens flare system
  46097. */
  46098. name: string;
  46099. /**
  46100. * List of lens flares used in this system.
  46101. */
  46102. lensFlares: LensFlare[];
  46103. /**
  46104. * Define a limit from the border the lens flare can be visible.
  46105. */
  46106. borderLimit: number;
  46107. /**
  46108. * Define a viewport border we do not want to see the lens flare in.
  46109. */
  46110. viewportBorder: number;
  46111. /**
  46112. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46113. */
  46114. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46115. /**
  46116. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46117. */
  46118. layerMask: number;
  46119. /**
  46120. * Define the id of the lens flare system in the scene.
  46121. * (equal to name by default)
  46122. */
  46123. id: string;
  46124. private _scene;
  46125. private _emitter;
  46126. private _vertexBuffers;
  46127. private _indexBuffer;
  46128. private _effect;
  46129. private _positionX;
  46130. private _positionY;
  46131. private _isEnabled;
  46132. /** @hidden */
  46133. static _SceneComponentInitialization: (scene: Scene) => void;
  46134. /**
  46135. * Instantiates a lens flare system.
  46136. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46137. * It is usually composed of several `lensFlare`.
  46138. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46139. * @param name Define the name of the lens flare system in the scene
  46140. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46141. * @param scene Define the scene the lens flare system belongs to
  46142. */
  46143. constructor(
  46144. /**
  46145. * Define the name of the lens flare system
  46146. */
  46147. name: string, emitter: any, scene: Scene);
  46148. /**
  46149. * Define if the lens flare system is enabled.
  46150. */
  46151. isEnabled: boolean;
  46152. /**
  46153. * Get the scene the effects belongs to.
  46154. * @returns the scene holding the lens flare system
  46155. */
  46156. getScene(): Scene;
  46157. /**
  46158. * Get the emitter of the lens flare system.
  46159. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46160. * @returns the emitter of the lens flare system
  46161. */
  46162. getEmitter(): any;
  46163. /**
  46164. * Set the emitter of the lens flare system.
  46165. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46166. * @param newEmitter Define the new emitter of the system
  46167. */
  46168. setEmitter(newEmitter: any): void;
  46169. /**
  46170. * Get the lens flare system emitter position.
  46171. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46172. * @returns the position
  46173. */
  46174. getEmitterPosition(): Vector3;
  46175. /**
  46176. * @hidden
  46177. */
  46178. computeEffectivePosition(globalViewport: Viewport): boolean;
  46179. /** @hidden */
  46180. _isVisible(): boolean;
  46181. /**
  46182. * @hidden
  46183. */
  46184. render(): boolean;
  46185. /**
  46186. * Dispose and release the lens flare with its associated resources.
  46187. */
  46188. dispose(): void;
  46189. /**
  46190. * Parse a lens flare system from a JSON repressentation
  46191. * @param parsedLensFlareSystem Define the JSON to parse
  46192. * @param scene Define the scene the parsed system should be instantiated in
  46193. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46194. * @returns the parsed system
  46195. */
  46196. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46197. /**
  46198. * Serialize the current Lens Flare System into a JSON representation.
  46199. * @returns the serialized JSON
  46200. */
  46201. serialize(): any;
  46202. }
  46203. }
  46204. declare module "babylonjs/LensFlares/lensFlare" {
  46205. import { Nullable } from "babylonjs/types";
  46206. import { Color3 } from "babylonjs/Maths/math";
  46207. import { Texture } from "babylonjs/Materials/Textures/texture";
  46208. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46209. /**
  46210. * This represents one of the lens effect in a `lensFlareSystem`.
  46211. * It controls one of the indiviual texture used in the effect.
  46212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46213. */
  46214. export class LensFlare {
  46215. /**
  46216. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46217. */
  46218. size: number;
  46219. /**
  46220. * 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.
  46221. */
  46222. position: number;
  46223. /**
  46224. * Define the lens color.
  46225. */
  46226. color: Color3;
  46227. /**
  46228. * Define the lens texture.
  46229. */
  46230. texture: Nullable<Texture>;
  46231. /**
  46232. * Define the alpha mode to render this particular lens.
  46233. */
  46234. alphaMode: number;
  46235. private _system;
  46236. /**
  46237. * Creates a new Lens Flare.
  46238. * This represents one of the lens effect in a `lensFlareSystem`.
  46239. * It controls one of the indiviual texture used in the effect.
  46240. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46241. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46242. * @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.
  46243. * @param color Define the lens color
  46244. * @param imgUrl Define the lens texture url
  46245. * @param system Define the `lensFlareSystem` this flare is part of
  46246. * @returns The newly created Lens Flare
  46247. */
  46248. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46249. /**
  46250. * Instantiates a new Lens Flare.
  46251. * This represents one of the lens effect in a `lensFlareSystem`.
  46252. * It controls one of the indiviual texture used in the effect.
  46253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46254. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46255. * @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.
  46256. * @param color Define the lens color
  46257. * @param imgUrl Define the lens texture url
  46258. * @param system Define the `lensFlareSystem` this flare is part of
  46259. */
  46260. constructor(
  46261. /**
  46262. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46263. */
  46264. size: number,
  46265. /**
  46266. * 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.
  46267. */
  46268. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46269. /**
  46270. * Dispose and release the lens flare with its associated resources.
  46271. */
  46272. dispose(): void;
  46273. }
  46274. }
  46275. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46276. import { Nullable } from "babylonjs/types";
  46277. import { Scene } from "babylonjs/scene";
  46278. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46279. import { AbstractScene } from "babylonjs/abstractScene";
  46280. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46281. module "babylonjs/abstractScene" {
  46282. interface AbstractScene {
  46283. /**
  46284. * The list of lens flare system added to the scene
  46285. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46286. */
  46287. lensFlareSystems: Array<LensFlareSystem>;
  46288. /**
  46289. * Removes the given lens flare system from this scene.
  46290. * @param toRemove The lens flare system to remove
  46291. * @returns The index of the removed lens flare system
  46292. */
  46293. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46294. /**
  46295. * Adds the given lens flare system to this scene
  46296. * @param newLensFlareSystem The lens flare system to add
  46297. */
  46298. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46299. /**
  46300. * Gets a lens flare system using its name
  46301. * @param name defines the name to look for
  46302. * @returns the lens flare system or null if not found
  46303. */
  46304. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46305. /**
  46306. * Gets a lens flare system using its id
  46307. * @param id defines the id to look for
  46308. * @returns the lens flare system or null if not found
  46309. */
  46310. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46311. }
  46312. }
  46313. /**
  46314. * Defines the lens flare scene component responsible to manage any lens flares
  46315. * in a given scene.
  46316. */
  46317. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46318. /**
  46319. * The component name helpfull to identify the component in the list of scene components.
  46320. */
  46321. readonly name: string;
  46322. /**
  46323. * The scene the component belongs to.
  46324. */
  46325. scene: Scene;
  46326. /**
  46327. * Creates a new instance of the component for the given scene
  46328. * @param scene Defines the scene to register the component in
  46329. */
  46330. constructor(scene: Scene);
  46331. /**
  46332. * Registers the component in a given scene
  46333. */
  46334. register(): void;
  46335. /**
  46336. * Rebuilds the elements related to this component in case of
  46337. * context lost for instance.
  46338. */
  46339. rebuild(): void;
  46340. /**
  46341. * Adds all the element from the container to the scene
  46342. * @param container the container holding the elements
  46343. */
  46344. addFromContainer(container: AbstractScene): void;
  46345. /**
  46346. * Removes all the elements in the container from the scene
  46347. * @param container contains the elements to remove
  46348. */
  46349. removeFromContainer(container: AbstractScene): void;
  46350. /**
  46351. * Serializes the component data to the specified json object
  46352. * @param serializationObject The object to serialize to
  46353. */
  46354. serialize(serializationObject: any): void;
  46355. /**
  46356. * Disposes the component and the associated ressources.
  46357. */
  46358. dispose(): void;
  46359. private _draw;
  46360. }
  46361. }
  46362. declare module "babylonjs/LensFlares/index" {
  46363. export * from "babylonjs/LensFlares/lensFlare";
  46364. export * from "babylonjs/LensFlares/lensFlareSystem";
  46365. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46366. }
  46367. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46368. import { Scene } from "babylonjs/scene";
  46369. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46370. import { AbstractScene } from "babylonjs/abstractScene";
  46371. /**
  46372. * Defines the shadow generator component responsible to manage any shadow generators
  46373. * in a given scene.
  46374. */
  46375. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46376. /**
  46377. * The component name helpfull to identify the component in the list of scene components.
  46378. */
  46379. readonly name: string;
  46380. /**
  46381. * The scene the component belongs to.
  46382. */
  46383. scene: Scene;
  46384. /**
  46385. * Creates a new instance of the component for the given scene
  46386. * @param scene Defines the scene to register the component in
  46387. */
  46388. constructor(scene: Scene);
  46389. /**
  46390. * Registers the component in a given scene
  46391. */
  46392. register(): void;
  46393. /**
  46394. * Rebuilds the elements related to this component in case of
  46395. * context lost for instance.
  46396. */
  46397. rebuild(): void;
  46398. /**
  46399. * Serializes the component data to the specified json object
  46400. * @param serializationObject The object to serialize to
  46401. */
  46402. serialize(serializationObject: any): void;
  46403. /**
  46404. * Adds all the element from the container to the scene
  46405. * @param container the container holding the elements
  46406. */
  46407. addFromContainer(container: AbstractScene): void;
  46408. /**
  46409. * Removes all the elements in the container from the scene
  46410. * @param container contains the elements to remove
  46411. */
  46412. removeFromContainer(container: AbstractScene): void;
  46413. /**
  46414. * Rebuilds the elements related to this component in case of
  46415. * context lost for instance.
  46416. */
  46417. dispose(): void;
  46418. private _gatherRenderTargets;
  46419. }
  46420. }
  46421. declare module "babylonjs/Lights/Shadows/index" {
  46422. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46423. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46424. }
  46425. declare module "babylonjs/Lights/directionalLight" {
  46426. import { Camera } from "babylonjs/Cameras/camera";
  46427. import { Scene } from "babylonjs/scene";
  46428. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46430. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46431. import { Effect } from "babylonjs/Materials/effect";
  46432. /**
  46433. * A directional light is defined by a direction (what a surprise!).
  46434. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46435. * 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.
  46436. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46437. */
  46438. export class DirectionalLight extends ShadowLight {
  46439. private _shadowFrustumSize;
  46440. /**
  46441. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46442. */
  46443. /**
  46444. * Specifies a fix frustum size for the shadow generation.
  46445. */
  46446. shadowFrustumSize: number;
  46447. private _shadowOrthoScale;
  46448. /**
  46449. * Gets the shadow projection scale against the optimal computed one.
  46450. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46451. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46452. */
  46453. /**
  46454. * Sets the shadow projection scale against the optimal computed one.
  46455. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46456. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46457. */
  46458. shadowOrthoScale: number;
  46459. /**
  46460. * Automatically compute the projection matrix to best fit (including all the casters)
  46461. * on each frame.
  46462. */
  46463. autoUpdateExtends: boolean;
  46464. private _orthoLeft;
  46465. private _orthoRight;
  46466. private _orthoTop;
  46467. private _orthoBottom;
  46468. /**
  46469. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46470. * The directional light is emitted from everywhere in the given direction.
  46471. * It can cast shadows.
  46472. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46473. * @param name The friendly name of the light
  46474. * @param direction The direction of the light
  46475. * @param scene The scene the light belongs to
  46476. */
  46477. constructor(name: string, direction: Vector3, scene: Scene);
  46478. /**
  46479. * Returns the string "DirectionalLight".
  46480. * @return The class name
  46481. */
  46482. getClassName(): string;
  46483. /**
  46484. * Returns the integer 1.
  46485. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46486. */
  46487. getTypeID(): number;
  46488. /**
  46489. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46490. * Returns the DirectionalLight Shadow projection matrix.
  46491. */
  46492. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46493. /**
  46494. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46495. * Returns the DirectionalLight Shadow projection matrix.
  46496. */
  46497. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46498. /**
  46499. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46500. * Returns the DirectionalLight Shadow projection matrix.
  46501. */
  46502. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46503. protected _buildUniformLayout(): void;
  46504. /**
  46505. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46506. * @param effect The effect to update
  46507. * @param lightIndex The index of the light in the effect to update
  46508. * @returns The directional light
  46509. */
  46510. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46511. /**
  46512. * Gets the minZ used for shadow according to both the scene and the light.
  46513. *
  46514. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46515. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46516. * @param activeCamera The camera we are returning the min for
  46517. * @returns the depth min z
  46518. */
  46519. getDepthMinZ(activeCamera: Camera): number;
  46520. /**
  46521. * Gets the maxZ used for shadow according to both the scene and the light.
  46522. *
  46523. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46524. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46525. * @param activeCamera The camera we are returning the max for
  46526. * @returns the depth max z
  46527. */
  46528. getDepthMaxZ(activeCamera: Camera): number;
  46529. /**
  46530. * Prepares the list of defines specific to the light type.
  46531. * @param defines the list of defines
  46532. * @param lightIndex defines the index of the light for the effect
  46533. */
  46534. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46535. }
  46536. }
  46537. declare module "babylonjs/Lights/pointLight" {
  46538. import { Scene } from "babylonjs/scene";
  46539. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46541. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46542. import { Effect } from "babylonjs/Materials/effect";
  46543. /**
  46544. * A point light is a light defined by an unique point in world space.
  46545. * The light is emitted in every direction from this point.
  46546. * A good example of a point light is a standard light bulb.
  46547. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46548. */
  46549. export class PointLight extends ShadowLight {
  46550. private _shadowAngle;
  46551. /**
  46552. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46553. * This specifies what angle the shadow will use to be created.
  46554. *
  46555. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46556. */
  46557. /**
  46558. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46559. * This specifies what angle the shadow will use to be created.
  46560. *
  46561. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46562. */
  46563. shadowAngle: number;
  46564. /**
  46565. * Gets the direction if it has been set.
  46566. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46567. */
  46568. /**
  46569. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46570. */
  46571. direction: Vector3;
  46572. /**
  46573. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46574. * A PointLight emits the light in every direction.
  46575. * It can cast shadows.
  46576. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46577. * ```javascript
  46578. * var pointLight = new PointLight("pl", camera.position, scene);
  46579. * ```
  46580. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46581. * @param name The light friendly name
  46582. * @param position The position of the point light in the scene
  46583. * @param scene The scene the lights belongs to
  46584. */
  46585. constructor(name: string, position: Vector3, scene: Scene);
  46586. /**
  46587. * Returns the string "PointLight"
  46588. * @returns the class name
  46589. */
  46590. getClassName(): string;
  46591. /**
  46592. * Returns the integer 0.
  46593. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46594. */
  46595. getTypeID(): number;
  46596. /**
  46597. * Specifies wether or not the shadowmap should be a cube texture.
  46598. * @returns true if the shadowmap needs to be a cube texture.
  46599. */
  46600. needCube(): boolean;
  46601. /**
  46602. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46603. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46604. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46605. */
  46606. getShadowDirection(faceIndex?: number): Vector3;
  46607. /**
  46608. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46609. * - fov = PI / 2
  46610. * - aspect ratio : 1.0
  46611. * - z-near and far equal to the active camera minZ and maxZ.
  46612. * Returns the PointLight.
  46613. */
  46614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46615. protected _buildUniformLayout(): void;
  46616. /**
  46617. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46618. * @param effect The effect to update
  46619. * @param lightIndex The index of the light in the effect to update
  46620. * @returns The point light
  46621. */
  46622. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46623. /**
  46624. * Prepares the list of defines specific to the light type.
  46625. * @param defines the list of defines
  46626. * @param lightIndex defines the index of the light for the effect
  46627. */
  46628. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46629. }
  46630. }
  46631. declare module "babylonjs/Lights/spotLight" {
  46632. import { Nullable } from "babylonjs/types";
  46633. import { Scene } from "babylonjs/scene";
  46634. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46636. import { Effect } from "babylonjs/Materials/effect";
  46637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46638. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46639. /**
  46640. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46641. * These values define a cone of light starting from the position, emitting toward the direction.
  46642. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46643. * and the exponent defines the speed of the decay of the light with distance (reach).
  46644. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46645. */
  46646. export class SpotLight extends ShadowLight {
  46647. private _angle;
  46648. private _innerAngle;
  46649. private _cosHalfAngle;
  46650. private _lightAngleScale;
  46651. private _lightAngleOffset;
  46652. /**
  46653. * Gets the cone angle of the spot light in Radians.
  46654. */
  46655. /**
  46656. * Sets the cone angle of the spot light in Radians.
  46657. */
  46658. angle: number;
  46659. /**
  46660. * Only used in gltf falloff mode, this defines the angle where
  46661. * the directional falloff will start before cutting at angle which could be seen
  46662. * as outer angle.
  46663. */
  46664. /**
  46665. * Only used in gltf falloff mode, this defines the angle where
  46666. * the directional falloff will start before cutting at angle which could be seen
  46667. * as outer angle.
  46668. */
  46669. innerAngle: number;
  46670. private _shadowAngleScale;
  46671. /**
  46672. * Allows scaling the angle of the light for shadow generation only.
  46673. */
  46674. /**
  46675. * Allows scaling the angle of the light for shadow generation only.
  46676. */
  46677. shadowAngleScale: number;
  46678. /**
  46679. * The light decay speed with the distance from the emission spot.
  46680. */
  46681. exponent: number;
  46682. private _projectionTextureMatrix;
  46683. /**
  46684. * Allows reading the projecton texture
  46685. */
  46686. readonly projectionTextureMatrix: Matrix;
  46687. protected _projectionTextureLightNear: number;
  46688. /**
  46689. * Gets the near clip of the Spotlight for texture projection.
  46690. */
  46691. /**
  46692. * Sets the near clip of the Spotlight for texture projection.
  46693. */
  46694. projectionTextureLightNear: number;
  46695. protected _projectionTextureLightFar: number;
  46696. /**
  46697. * Gets the far clip of the Spotlight for texture projection.
  46698. */
  46699. /**
  46700. * Sets the far clip of the Spotlight for texture projection.
  46701. */
  46702. projectionTextureLightFar: number;
  46703. protected _projectionTextureUpDirection: Vector3;
  46704. /**
  46705. * Gets the Up vector of the Spotlight for texture projection.
  46706. */
  46707. /**
  46708. * Sets the Up vector of the Spotlight for texture projection.
  46709. */
  46710. projectionTextureUpDirection: Vector3;
  46711. private _projectionTexture;
  46712. /**
  46713. * Gets the projection texture of the light.
  46714. */
  46715. /**
  46716. * Sets the projection texture of the light.
  46717. */
  46718. projectionTexture: Nullable<BaseTexture>;
  46719. private _projectionTextureViewLightDirty;
  46720. private _projectionTextureProjectionLightDirty;
  46721. private _projectionTextureDirty;
  46722. private _projectionTextureViewTargetVector;
  46723. private _projectionTextureViewLightMatrix;
  46724. private _projectionTextureProjectionLightMatrix;
  46725. private _projectionTextureScalingMatrix;
  46726. /**
  46727. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46728. * It can cast shadows.
  46729. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46730. * @param name The light friendly name
  46731. * @param position The position of the spot light in the scene
  46732. * @param direction The direction of the light in the scene
  46733. * @param angle The cone angle of the light in Radians
  46734. * @param exponent The light decay speed with the distance from the emission spot
  46735. * @param scene The scene the lights belongs to
  46736. */
  46737. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46738. /**
  46739. * Returns the string "SpotLight".
  46740. * @returns the class name
  46741. */
  46742. getClassName(): string;
  46743. /**
  46744. * Returns the integer 2.
  46745. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46746. */
  46747. getTypeID(): number;
  46748. /**
  46749. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46750. */
  46751. protected _setDirection(value: Vector3): void;
  46752. /**
  46753. * Overrides the position setter to recompute the projection texture view light Matrix.
  46754. */
  46755. protected _setPosition(value: Vector3): void;
  46756. /**
  46757. * 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.
  46758. * Returns the SpotLight.
  46759. */
  46760. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46761. protected _computeProjectionTextureViewLightMatrix(): void;
  46762. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46763. /**
  46764. * Main function for light texture projection matrix computing.
  46765. */
  46766. protected _computeProjectionTextureMatrix(): void;
  46767. protected _buildUniformLayout(): void;
  46768. private _computeAngleValues;
  46769. /**
  46770. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46771. * @param effect The effect to update
  46772. * @param lightIndex The index of the light in the effect to update
  46773. * @returns The spot light
  46774. */
  46775. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46776. /**
  46777. * Disposes the light and the associated resources.
  46778. */
  46779. dispose(): void;
  46780. /**
  46781. * Prepares the list of defines specific to the light type.
  46782. * @param defines the list of defines
  46783. * @param lightIndex defines the index of the light for the effect
  46784. */
  46785. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46786. }
  46787. }
  46788. declare module "babylonjs/Lights/index" {
  46789. export * from "babylonjs/Lights/light";
  46790. export * from "babylonjs/Lights/shadowLight";
  46791. export * from "babylonjs/Lights/Shadows/index";
  46792. export * from "babylonjs/Lights/directionalLight";
  46793. export * from "babylonjs/Lights/hemisphericLight";
  46794. export * from "babylonjs/Lights/pointLight";
  46795. export * from "babylonjs/Lights/spotLight";
  46796. }
  46797. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46798. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46799. /**
  46800. * Header information of HDR texture files.
  46801. */
  46802. export interface HDRInfo {
  46803. /**
  46804. * The height of the texture in pixels.
  46805. */
  46806. height: number;
  46807. /**
  46808. * The width of the texture in pixels.
  46809. */
  46810. width: number;
  46811. /**
  46812. * The index of the beginning of the data in the binary file.
  46813. */
  46814. dataPosition: number;
  46815. }
  46816. /**
  46817. * This groups tools to convert HDR texture to native colors array.
  46818. */
  46819. export class HDRTools {
  46820. private static Ldexp;
  46821. private static Rgbe2float;
  46822. private static readStringLine;
  46823. /**
  46824. * Reads header information from an RGBE texture stored in a native array.
  46825. * More information on this format are available here:
  46826. * https://en.wikipedia.org/wiki/RGBE_image_format
  46827. *
  46828. * @param uint8array The binary file stored in native array.
  46829. * @return The header information.
  46830. */
  46831. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46832. /**
  46833. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46834. * This RGBE texture needs to store the information as a panorama.
  46835. *
  46836. * More information on this format are available here:
  46837. * https://en.wikipedia.org/wiki/RGBE_image_format
  46838. *
  46839. * @param buffer The binary file stored in an array buffer.
  46840. * @param size The expected size of the extracted cubemap.
  46841. * @return The Cube Map information.
  46842. */
  46843. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46844. /**
  46845. * Returns the pixels data extracted from an RGBE texture.
  46846. * This pixels will be stored left to right up to down in the R G B order in one array.
  46847. *
  46848. * More information on this format are available here:
  46849. * https://en.wikipedia.org/wiki/RGBE_image_format
  46850. *
  46851. * @param uint8array The binary file stored in an array buffer.
  46852. * @param hdrInfo The header information of the file.
  46853. * @return The pixels data in RGB right to left up to down order.
  46854. */
  46855. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46856. private static RGBE_ReadPixels_RLE;
  46857. }
  46858. }
  46859. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46860. import { Nullable } from "babylonjs/types";
  46861. import { Scene } from "babylonjs/scene";
  46862. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46864. /**
  46865. * This represents a texture coming from an HDR input.
  46866. *
  46867. * The only supported format is currently panorama picture stored in RGBE format.
  46868. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46869. */
  46870. export class HDRCubeTexture extends BaseTexture {
  46871. private static _facesMapping;
  46872. private _generateHarmonics;
  46873. private _noMipmap;
  46874. private _textureMatrix;
  46875. private _size;
  46876. private _onLoad;
  46877. private _onError;
  46878. /**
  46879. * The texture URL.
  46880. */
  46881. url: string;
  46882. /**
  46883. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46884. */
  46885. coordinatesMode: number;
  46886. protected _isBlocking: boolean;
  46887. /**
  46888. * Sets wether or not the texture is blocking during loading.
  46889. */
  46890. /**
  46891. * Gets wether or not the texture is blocking during loading.
  46892. */
  46893. isBlocking: boolean;
  46894. protected _rotationY: number;
  46895. /**
  46896. * Sets texture matrix rotation angle around Y axis in radians.
  46897. */
  46898. /**
  46899. * Gets texture matrix rotation angle around Y axis radians.
  46900. */
  46901. rotationY: number;
  46902. /**
  46903. * Gets or sets the center of the bounding box associated with the cube texture
  46904. * It must define where the camera used to render the texture was set
  46905. */
  46906. boundingBoxPosition: Vector3;
  46907. private _boundingBoxSize;
  46908. /**
  46909. * Gets or sets the size of the bounding box associated with the cube texture
  46910. * When defined, the cubemap will switch to local mode
  46911. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46912. * @example https://www.babylonjs-playground.com/#RNASML
  46913. */
  46914. boundingBoxSize: Vector3;
  46915. /**
  46916. * Instantiates an HDRTexture from the following parameters.
  46917. *
  46918. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46919. * @param scene The scene the texture will be used in
  46920. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46921. * @param noMipmap Forces to not generate the mipmap if true
  46922. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46923. * @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)
  46924. * @param reserved Reserved flag for internal use.
  46925. */
  46926. 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>);
  46927. /**
  46928. * Get the current class name of the texture useful for serialization or dynamic coding.
  46929. * @returns "HDRCubeTexture"
  46930. */
  46931. getClassName(): string;
  46932. /**
  46933. * Occurs when the file is raw .hdr file.
  46934. */
  46935. private loadTexture;
  46936. clone(): HDRCubeTexture;
  46937. delayLoad(): void;
  46938. /**
  46939. * Get the texture reflection matrix used to rotate/transform the reflection.
  46940. * @returns the reflection matrix
  46941. */
  46942. getReflectionTextureMatrix(): Matrix;
  46943. /**
  46944. * Set the texture reflection matrix used to rotate/transform the reflection.
  46945. * @param value Define the reflection matrix to set
  46946. */
  46947. setReflectionTextureMatrix(value: Matrix): void;
  46948. /**
  46949. * Parses a JSON representation of an HDR Texture in order to create the texture
  46950. * @param parsedTexture Define the JSON representation
  46951. * @param scene Define the scene the texture should be created in
  46952. * @param rootUrl Define the root url in case we need to load relative dependencies
  46953. * @returns the newly created texture after parsing
  46954. */
  46955. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46956. serialize(): any;
  46957. }
  46958. }
  46959. declare module "babylonjs/Physics/physicsEngine" {
  46960. import { Nullable } from "babylonjs/types";
  46961. import { Vector3 } from "babylonjs/Maths/math";
  46962. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46963. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  46964. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  46965. /**
  46966. * Class used to control physics engine
  46967. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  46968. */
  46969. export class PhysicsEngine implements IPhysicsEngine {
  46970. private _physicsPlugin;
  46971. /**
  46972. * Global value used to control the smallest number supported by the simulation
  46973. */
  46974. static Epsilon: number;
  46975. private _impostors;
  46976. private _joints;
  46977. /**
  46978. * Gets the gravity vector used by the simulation
  46979. */
  46980. gravity: Vector3;
  46981. /**
  46982. * Factory used to create the default physics plugin.
  46983. * @returns The default physics plugin
  46984. */
  46985. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  46986. /**
  46987. * Creates a new Physics Engine
  46988. * @param gravity defines the gravity vector used by the simulation
  46989. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  46990. */
  46991. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  46992. /**
  46993. * Sets the gravity vector used by the simulation
  46994. * @param gravity defines the gravity vector to use
  46995. */
  46996. setGravity(gravity: Vector3): void;
  46997. /**
  46998. * Set the time step of the physics engine.
  46999. * Default is 1/60.
  47000. * To slow it down, enter 1/600 for example.
  47001. * To speed it up, 1/30
  47002. * @param newTimeStep defines the new timestep to apply to this world.
  47003. */
  47004. setTimeStep(newTimeStep?: number): void;
  47005. /**
  47006. * Get the time step of the physics engine.
  47007. * @returns the current time step
  47008. */
  47009. getTimeStep(): number;
  47010. /**
  47011. * Release all resources
  47012. */
  47013. dispose(): void;
  47014. /**
  47015. * Gets the name of the current physics plugin
  47016. * @returns the name of the plugin
  47017. */
  47018. getPhysicsPluginName(): string;
  47019. /**
  47020. * Adding a new impostor for the impostor tracking.
  47021. * This will be done by the impostor itself.
  47022. * @param impostor the impostor to add
  47023. */
  47024. addImpostor(impostor: PhysicsImpostor): void;
  47025. /**
  47026. * Remove an impostor from the engine.
  47027. * This impostor and its mesh will not longer be updated by the physics engine.
  47028. * @param impostor the impostor to remove
  47029. */
  47030. removeImpostor(impostor: PhysicsImpostor): void;
  47031. /**
  47032. * Add a joint to the physics engine
  47033. * @param mainImpostor defines the main impostor to which the joint is added.
  47034. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47035. * @param joint defines the joint that will connect both impostors.
  47036. */
  47037. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47038. /**
  47039. * Removes a joint from the simulation
  47040. * @param mainImpostor defines the impostor used with the joint
  47041. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47042. * @param joint defines the joint to remove
  47043. */
  47044. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47045. /**
  47046. * Called by the scene. No need to call it.
  47047. * @param delta defines the timespam between frames
  47048. */
  47049. _step(delta: number): void;
  47050. /**
  47051. * Gets the current plugin used to run the simulation
  47052. * @returns current plugin
  47053. */
  47054. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47055. /**
  47056. * Gets the list of physic impostors
  47057. * @returns an array of PhysicsImpostor
  47058. */
  47059. getImpostors(): Array<PhysicsImpostor>;
  47060. /**
  47061. * Gets the impostor for a physics enabled object
  47062. * @param object defines the object impersonated by the impostor
  47063. * @returns the PhysicsImpostor or null if not found
  47064. */
  47065. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47066. /**
  47067. * Gets the impostor for a physics body object
  47068. * @param body defines physics body used by the impostor
  47069. * @returns the PhysicsImpostor or null if not found
  47070. */
  47071. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47072. }
  47073. }
  47074. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47075. import { Nullable } from "babylonjs/types";
  47076. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47078. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47079. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47080. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47081. /** @hidden */
  47082. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47083. private _useDeltaForWorldStep;
  47084. world: any;
  47085. name: string;
  47086. private _physicsMaterials;
  47087. private _fixedTimeStep;
  47088. BJSCANNON: any;
  47089. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47090. setGravity(gravity: Vector3): void;
  47091. setTimeStep(timeStep: number): void;
  47092. getTimeStep(): number;
  47093. executeStep(delta: number): void;
  47094. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47095. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47096. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47097. private _processChildMeshes;
  47098. removePhysicsBody(impostor: PhysicsImpostor): void;
  47099. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47100. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47101. private _addMaterial;
  47102. private _checkWithEpsilon;
  47103. private _createShape;
  47104. private _createHeightmap;
  47105. private _minus90X;
  47106. private _plus90X;
  47107. private _tmpPosition;
  47108. private _tmpDeltaPosition;
  47109. private _tmpUnityRotation;
  47110. private _updatePhysicsBodyTransformation;
  47111. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47112. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47113. isSupported(): boolean;
  47114. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47115. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47116. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47117. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47118. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47119. getBodyMass(impostor: PhysicsImpostor): number;
  47120. getBodyFriction(impostor: PhysicsImpostor): number;
  47121. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47122. getBodyRestitution(impostor: PhysicsImpostor): number;
  47123. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47124. sleepBody(impostor: PhysicsImpostor): void;
  47125. wakeUpBody(impostor: PhysicsImpostor): void;
  47126. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47127. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47128. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47129. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47130. getRadius(impostor: PhysicsImpostor): number;
  47131. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47132. dispose(): void;
  47133. private _extendNamespace;
  47134. }
  47135. }
  47136. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47137. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47138. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47139. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47141. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47142. import { Nullable } from "babylonjs/types";
  47143. /** @hidden */
  47144. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47145. world: any;
  47146. name: string;
  47147. BJSOIMO: any;
  47148. constructor(iterations?: number, oimoInjection?: any);
  47149. setGravity(gravity: Vector3): void;
  47150. setTimeStep(timeStep: number): void;
  47151. getTimeStep(): number;
  47152. private _tmpImpostorsArray;
  47153. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47154. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47155. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47156. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47157. private _tmpPositionVector;
  47158. removePhysicsBody(impostor: PhysicsImpostor): void;
  47159. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47160. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47161. isSupported(): boolean;
  47162. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47164. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47165. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47166. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47167. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47168. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47169. getBodyMass(impostor: PhysicsImpostor): number;
  47170. getBodyFriction(impostor: PhysicsImpostor): number;
  47171. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47172. getBodyRestitution(impostor: PhysicsImpostor): number;
  47173. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47174. sleepBody(impostor: PhysicsImpostor): void;
  47175. wakeUpBody(impostor: PhysicsImpostor): void;
  47176. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47177. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47178. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47179. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47180. getRadius(impostor: PhysicsImpostor): number;
  47181. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47182. dispose(): void;
  47183. }
  47184. }
  47185. declare module "babylonjs/Probes/reflectionProbe" {
  47186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47187. import { Vector3 } from "babylonjs/Maths/math";
  47188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47189. import { Nullable } from "babylonjs/types";
  47190. import { Scene } from "babylonjs/scene";
  47191. module "babylonjs/abstractScene" {
  47192. interface AbstractScene {
  47193. /**
  47194. * The list of reflection probes added to the scene
  47195. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47196. */
  47197. reflectionProbes: Array<ReflectionProbe>;
  47198. /**
  47199. * Removes the given reflection probe from this scene.
  47200. * @param toRemove The reflection probe to remove
  47201. * @returns The index of the removed reflection probe
  47202. */
  47203. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47204. /**
  47205. * Adds the given reflection probe to this scene.
  47206. * @param newReflectionProbe The reflection probe to add
  47207. */
  47208. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47209. }
  47210. }
  47211. /**
  47212. * Class used to generate realtime reflection / refraction cube textures
  47213. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47214. */
  47215. export class ReflectionProbe {
  47216. /** defines the name of the probe */
  47217. name: string;
  47218. private _scene;
  47219. private _renderTargetTexture;
  47220. private _projectionMatrix;
  47221. private _viewMatrix;
  47222. private _target;
  47223. private _add;
  47224. private _attachedMesh;
  47225. private _invertYAxis;
  47226. /** Gets or sets probe position (center of the cube map) */
  47227. position: Vector3;
  47228. /**
  47229. * Creates a new reflection probe
  47230. * @param name defines the name of the probe
  47231. * @param size defines the texture resolution (for each face)
  47232. * @param scene defines the hosting scene
  47233. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47234. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47235. */
  47236. constructor(
  47237. /** defines the name of the probe */
  47238. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47239. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47240. samples: number;
  47241. /** Gets or sets the refresh rate to use (on every frame by default) */
  47242. refreshRate: number;
  47243. /**
  47244. * Gets the hosting scene
  47245. * @returns a Scene
  47246. */
  47247. getScene(): Scene;
  47248. /** Gets the internal CubeTexture used to render to */
  47249. readonly cubeTexture: RenderTargetTexture;
  47250. /** Gets the list of meshes to render */
  47251. readonly renderList: Nullable<AbstractMesh[]>;
  47252. /**
  47253. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47254. * @param mesh defines the mesh to attach to
  47255. */
  47256. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47257. /**
  47258. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47259. * @param renderingGroupId The rendering group id corresponding to its index
  47260. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47261. */
  47262. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47263. /**
  47264. * Clean all associated resources
  47265. */
  47266. dispose(): void;
  47267. /**
  47268. * Converts the reflection probe information to a readable string for debug purpose.
  47269. * @param fullDetails Supports for multiple levels of logging within scene loading
  47270. * @returns the human readable reflection probe info
  47271. */
  47272. toString(fullDetails?: boolean): string;
  47273. /**
  47274. * Get the class name of the relfection probe.
  47275. * @returns "ReflectionProbe"
  47276. */
  47277. getClassName(): string;
  47278. /**
  47279. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47280. * @returns The JSON representation of the texture
  47281. */
  47282. serialize(): any;
  47283. /**
  47284. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47285. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47286. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47287. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47288. * @returns The parsed reflection probe if successful
  47289. */
  47290. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47291. }
  47292. }
  47293. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47294. /** @hidden */
  47295. export var _BabylonLoaderRegistered: boolean;
  47296. }
  47297. declare module "babylonjs/Loading/Plugins/index" {
  47298. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47299. }
  47300. declare module "babylonjs/Loading/index" {
  47301. export * from "babylonjs/Loading/loadingScreen";
  47302. export * from "babylonjs/Loading/Plugins/index";
  47303. export * from "babylonjs/Loading/sceneLoader";
  47304. export * from "babylonjs/Loading/sceneLoaderFlags";
  47305. }
  47306. declare module "babylonjs/Materials/Background/index" {
  47307. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47308. }
  47309. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47310. import { Scene } from "babylonjs/scene";
  47311. import { Color3 } from "babylonjs/Maths/math";
  47312. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47314. /**
  47315. * The Physically based simple base material of BJS.
  47316. *
  47317. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47318. * It is used as the base class for both the specGloss and metalRough conventions.
  47319. */
  47320. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47321. /**
  47322. * Number of Simultaneous lights allowed on the material.
  47323. */
  47324. maxSimultaneousLights: number;
  47325. /**
  47326. * If sets to true, disables all the lights affecting the material.
  47327. */
  47328. disableLighting: boolean;
  47329. /**
  47330. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47331. */
  47332. environmentTexture: BaseTexture;
  47333. /**
  47334. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47335. */
  47336. invertNormalMapX: boolean;
  47337. /**
  47338. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47339. */
  47340. invertNormalMapY: boolean;
  47341. /**
  47342. * Normal map used in the model.
  47343. */
  47344. normalTexture: BaseTexture;
  47345. /**
  47346. * Emissivie color used to self-illuminate the model.
  47347. */
  47348. emissiveColor: Color3;
  47349. /**
  47350. * Emissivie texture used to self-illuminate the model.
  47351. */
  47352. emissiveTexture: BaseTexture;
  47353. /**
  47354. * Occlusion Channel Strenght.
  47355. */
  47356. occlusionStrength: number;
  47357. /**
  47358. * Occlusion Texture of the material (adding extra occlusion effects).
  47359. */
  47360. occlusionTexture: BaseTexture;
  47361. /**
  47362. * Defines the alpha limits in alpha test mode.
  47363. */
  47364. alphaCutOff: number;
  47365. /**
  47366. * Gets the current double sided mode.
  47367. */
  47368. /**
  47369. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47370. */
  47371. doubleSided: boolean;
  47372. /**
  47373. * Stores the pre-calculated light information of a mesh in a texture.
  47374. */
  47375. lightmapTexture: BaseTexture;
  47376. /**
  47377. * If true, the light map contains occlusion information instead of lighting info.
  47378. */
  47379. useLightmapAsShadowmap: boolean;
  47380. /**
  47381. * Return the active textures of the material.
  47382. */
  47383. getActiveTextures(): BaseTexture[];
  47384. hasTexture(texture: BaseTexture): boolean;
  47385. /**
  47386. * Instantiates a new PBRMaterial instance.
  47387. *
  47388. * @param name The material name
  47389. * @param scene The scene the material will be use in.
  47390. */
  47391. constructor(name: string, scene: Scene);
  47392. getClassName(): string;
  47393. }
  47394. }
  47395. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47396. import { Scene } from "babylonjs/scene";
  47397. import { Color3 } from "babylonjs/Maths/math";
  47398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47399. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47400. /**
  47401. * The PBR material of BJS following the metal roughness convention.
  47402. *
  47403. * This fits to the PBR convention in the GLTF definition:
  47404. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47405. */
  47406. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47407. /**
  47408. * The base color has two different interpretations depending on the value of metalness.
  47409. * When the material is a metal, the base color is the specific measured reflectance value
  47410. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47411. * of the material.
  47412. */
  47413. baseColor: Color3;
  47414. /**
  47415. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47416. * well as opacity information in the alpha channel.
  47417. */
  47418. baseTexture: BaseTexture;
  47419. /**
  47420. * Specifies the metallic scalar value of the material.
  47421. * Can also be used to scale the metalness values of the metallic texture.
  47422. */
  47423. metallic: number;
  47424. /**
  47425. * Specifies the roughness scalar value of the material.
  47426. * Can also be used to scale the roughness values of the metallic texture.
  47427. */
  47428. roughness: number;
  47429. /**
  47430. * Texture containing both the metallic value in the B channel and the
  47431. * roughness value in the G channel to keep better precision.
  47432. */
  47433. metallicRoughnessTexture: BaseTexture;
  47434. /**
  47435. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47436. *
  47437. * @param name The material name
  47438. * @param scene The scene the material will be use in.
  47439. */
  47440. constructor(name: string, scene: Scene);
  47441. /**
  47442. * Return the currrent class name of the material.
  47443. */
  47444. getClassName(): string;
  47445. /**
  47446. * Return the active textures of the material.
  47447. */
  47448. getActiveTextures(): BaseTexture[];
  47449. /**
  47450. * Checks to see if a texture is used in the material.
  47451. * @param texture - Base texture to use.
  47452. * @returns - Boolean specifying if a texture is used in the material.
  47453. */
  47454. hasTexture(texture: BaseTexture): boolean;
  47455. /**
  47456. * Makes a duplicate of the current material.
  47457. * @param name - name to use for the new material.
  47458. */
  47459. clone(name: string): PBRMetallicRoughnessMaterial;
  47460. /**
  47461. * Serialize the material to a parsable JSON object.
  47462. */
  47463. serialize(): any;
  47464. /**
  47465. * Parses a JSON object correponding to the serialize function.
  47466. */
  47467. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47468. }
  47469. }
  47470. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47471. import { Scene } from "babylonjs/scene";
  47472. import { Color3 } from "babylonjs/Maths/math";
  47473. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47474. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47475. /**
  47476. * The PBR material of BJS following the specular glossiness convention.
  47477. *
  47478. * This fits to the PBR convention in the GLTF definition:
  47479. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47480. */
  47481. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47482. /**
  47483. * Specifies the diffuse color of the material.
  47484. */
  47485. diffuseColor: Color3;
  47486. /**
  47487. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47488. * channel.
  47489. */
  47490. diffuseTexture: BaseTexture;
  47491. /**
  47492. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47493. */
  47494. specularColor: Color3;
  47495. /**
  47496. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47497. */
  47498. glossiness: number;
  47499. /**
  47500. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47501. */
  47502. specularGlossinessTexture: BaseTexture;
  47503. /**
  47504. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47505. *
  47506. * @param name The material name
  47507. * @param scene The scene the material will be use in.
  47508. */
  47509. constructor(name: string, scene: Scene);
  47510. /**
  47511. * Return the currrent class name of the material.
  47512. */
  47513. getClassName(): string;
  47514. /**
  47515. * Return the active textures of the material.
  47516. */
  47517. getActiveTextures(): BaseTexture[];
  47518. /**
  47519. * Checks to see if a texture is used in the material.
  47520. * @param texture - Base texture to use.
  47521. * @returns - Boolean specifying if a texture is used in the material.
  47522. */
  47523. hasTexture(texture: BaseTexture): boolean;
  47524. /**
  47525. * Makes a duplicate of the current material.
  47526. * @param name - name to use for the new material.
  47527. */
  47528. clone(name: string): PBRSpecularGlossinessMaterial;
  47529. /**
  47530. * Serialize the material to a parsable JSON object.
  47531. */
  47532. serialize(): any;
  47533. /**
  47534. * Parses a JSON object correponding to the serialize function.
  47535. */
  47536. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47537. }
  47538. }
  47539. declare module "babylonjs/Materials/PBR/index" {
  47540. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47541. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47542. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47543. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47544. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47545. }
  47546. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47547. import { Nullable } from "babylonjs/types";
  47548. import { Scene } from "babylonjs/scene";
  47549. import { Matrix } from "babylonjs/Maths/math";
  47550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47551. /**
  47552. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47553. * It can help converting any input color in a desired output one. This can then be used to create effects
  47554. * from sepia, black and white to sixties or futuristic rendering...
  47555. *
  47556. * The only supported format is currently 3dl.
  47557. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47558. */
  47559. export class ColorGradingTexture extends BaseTexture {
  47560. /**
  47561. * The current texture matrix. (will always be identity in color grading texture)
  47562. */
  47563. private _textureMatrix;
  47564. /**
  47565. * The texture URL.
  47566. */
  47567. url: string;
  47568. /**
  47569. * Empty line regex stored for GC.
  47570. */
  47571. private static _noneEmptyLineRegex;
  47572. private _engine;
  47573. /**
  47574. * Instantiates a ColorGradingTexture from the following parameters.
  47575. *
  47576. * @param url The location of the color gradind data (currently only supporting 3dl)
  47577. * @param scene The scene the texture will be used in
  47578. */
  47579. constructor(url: string, scene: Scene);
  47580. /**
  47581. * Returns the texture matrix used in most of the material.
  47582. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47583. */
  47584. getTextureMatrix(): Matrix;
  47585. /**
  47586. * Occurs when the file being loaded is a .3dl LUT file.
  47587. */
  47588. private load3dlTexture;
  47589. /**
  47590. * Starts the loading process of the texture.
  47591. */
  47592. private loadTexture;
  47593. /**
  47594. * Clones the color gradind texture.
  47595. */
  47596. clone(): ColorGradingTexture;
  47597. /**
  47598. * Called during delayed load for textures.
  47599. */
  47600. delayLoad(): void;
  47601. /**
  47602. * Parses a color grading texture serialized by Babylon.
  47603. * @param parsedTexture The texture information being parsedTexture
  47604. * @param scene The scene to load the texture in
  47605. * @param rootUrl The root url of the data assets to load
  47606. * @return A color gradind texture
  47607. */
  47608. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47609. /**
  47610. * Serializes the LUT texture to json format.
  47611. */
  47612. serialize(): any;
  47613. }
  47614. }
  47615. declare module "babylonjs/Misc/dds" {
  47616. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47617. import { Engine } from "babylonjs/Engines/engine";
  47618. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47619. import { Nullable } from "babylonjs/types";
  47620. import { Scene } from "babylonjs/scene";
  47621. /**
  47622. * Direct draw surface info
  47623. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47624. */
  47625. export interface DDSInfo {
  47626. /**
  47627. * Width of the texture
  47628. */
  47629. width: number;
  47630. /**
  47631. * Width of the texture
  47632. */
  47633. height: number;
  47634. /**
  47635. * Number of Mipmaps for the texture
  47636. * @see https://en.wikipedia.org/wiki/Mipmap
  47637. */
  47638. mipmapCount: number;
  47639. /**
  47640. * If the textures format is a known fourCC format
  47641. * @see https://www.fourcc.org/
  47642. */
  47643. isFourCC: boolean;
  47644. /**
  47645. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47646. */
  47647. isRGB: boolean;
  47648. /**
  47649. * If the texture is a lumincance format
  47650. */
  47651. isLuminance: boolean;
  47652. /**
  47653. * If this is a cube texture
  47654. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47655. */
  47656. isCube: boolean;
  47657. /**
  47658. * If the texture is a compressed format eg. FOURCC_DXT1
  47659. */
  47660. isCompressed: boolean;
  47661. /**
  47662. * The dxgiFormat of the texture
  47663. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47664. */
  47665. dxgiFormat: number;
  47666. /**
  47667. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47668. */
  47669. textureType: number;
  47670. /**
  47671. * Sphericle polynomial created for the dds texture
  47672. */
  47673. sphericalPolynomial?: SphericalPolynomial;
  47674. }
  47675. /**
  47676. * Class used to provide DDS decompression tools
  47677. */
  47678. export class DDSTools {
  47679. /**
  47680. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47681. */
  47682. static StoreLODInAlphaChannel: boolean;
  47683. /**
  47684. * Gets DDS information from an array buffer
  47685. * @param arrayBuffer defines the array buffer to read data from
  47686. * @returns the DDS information
  47687. */
  47688. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47689. private static _FloatView;
  47690. private static _Int32View;
  47691. private static _ToHalfFloat;
  47692. private static _FromHalfFloat;
  47693. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47694. private static _GetHalfFloatRGBAArrayBuffer;
  47695. private static _GetFloatRGBAArrayBuffer;
  47696. private static _GetFloatAsUIntRGBAArrayBuffer;
  47697. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47698. private static _GetRGBAArrayBuffer;
  47699. private static _ExtractLongWordOrder;
  47700. private static _GetRGBArrayBuffer;
  47701. private static _GetLuminanceArrayBuffer;
  47702. /**
  47703. * Uploads DDS Levels to a Babylon Texture
  47704. * @hidden
  47705. */
  47706. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47707. }
  47708. module "babylonjs/Engines/engine" {
  47709. interface Engine {
  47710. /**
  47711. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47712. * @param rootUrl defines the url where the file to load is located
  47713. * @param scene defines the current scene
  47714. * @param lodScale defines scale to apply to the mip map selection
  47715. * @param lodOffset defines offset to apply to the mip map selection
  47716. * @param onLoad defines an optional callback raised when the texture is loaded
  47717. * @param onError defines an optional callback raised if there is an issue to load the texture
  47718. * @param format defines the format of the data
  47719. * @param forcedExtension defines the extension to use to pick the right loader
  47720. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47721. * @returns the cube texture as an InternalTexture
  47722. */
  47723. 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;
  47724. }
  47725. }
  47726. }
  47727. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47728. import { Nullable } from "babylonjs/types";
  47729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47730. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47731. /**
  47732. * Implementation of the DDS Texture Loader.
  47733. * @hidden
  47734. */
  47735. export class _DDSTextureLoader implements IInternalTextureLoader {
  47736. /**
  47737. * Defines wether the loader supports cascade loading the different faces.
  47738. */
  47739. readonly supportCascades: boolean;
  47740. /**
  47741. * This returns if the loader support the current file information.
  47742. * @param extension defines the file extension of the file being loaded
  47743. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47744. * @param fallback defines the fallback internal texture if any
  47745. * @param isBase64 defines whether the texture is encoded as a base64
  47746. * @param isBuffer defines whether the texture data are stored as a buffer
  47747. * @returns true if the loader can load the specified file
  47748. */
  47749. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47750. /**
  47751. * Transform the url before loading if required.
  47752. * @param rootUrl the url of the texture
  47753. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47754. * @returns the transformed texture
  47755. */
  47756. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47757. /**
  47758. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47759. * @param rootUrl the url of the texture
  47760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47761. * @returns the fallback texture
  47762. */
  47763. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47764. /**
  47765. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47766. * @param data contains the texture data
  47767. * @param texture defines the BabylonJS internal texture
  47768. * @param createPolynomials will be true if polynomials have been requested
  47769. * @param onLoad defines the callback to trigger once the texture is ready
  47770. * @param onError defines the callback to trigger in case of error
  47771. */
  47772. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47773. /**
  47774. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47775. * @param data contains the texture data
  47776. * @param texture defines the BabylonJS internal texture
  47777. * @param callback defines the method to call once ready to upload
  47778. */
  47779. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47780. }
  47781. }
  47782. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47783. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47784. /** @hidden */
  47785. export var rgbdEncodePixelShader: {
  47786. name: string;
  47787. shader: string;
  47788. };
  47789. }
  47790. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47791. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47792. /** @hidden */
  47793. export var rgbdDecodePixelShader: {
  47794. name: string;
  47795. shader: string;
  47796. };
  47797. }
  47798. declare module "babylonjs/Misc/environmentTextureTools" {
  47799. import { Nullable } from "babylonjs/types";
  47800. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47802. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47803. import "babylonjs/Shaders/rgbdEncode.fragment";
  47804. import "babylonjs/Shaders/rgbdDecode.fragment";
  47805. /**
  47806. * Raw texture data and descriptor sufficient for WebGL texture upload
  47807. */
  47808. export interface EnvironmentTextureInfo {
  47809. /**
  47810. * Version of the environment map
  47811. */
  47812. version: number;
  47813. /**
  47814. * Width of image
  47815. */
  47816. width: number;
  47817. /**
  47818. * Irradiance information stored in the file.
  47819. */
  47820. irradiance: any;
  47821. /**
  47822. * Specular information stored in the file.
  47823. */
  47824. specular: any;
  47825. }
  47826. /**
  47827. * Sets of helpers addressing the serialization and deserialization of environment texture
  47828. * stored in a BabylonJS env file.
  47829. * Those files are usually stored as .env files.
  47830. */
  47831. export class EnvironmentTextureTools {
  47832. /**
  47833. * Magic number identifying the env file.
  47834. */
  47835. private static _MagicBytes;
  47836. /**
  47837. * Gets the environment info from an env file.
  47838. * @param data The array buffer containing the .env bytes.
  47839. * @returns the environment file info (the json header) if successfully parsed.
  47840. */
  47841. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47842. /**
  47843. * Creates an environment texture from a loaded cube texture.
  47844. * @param texture defines the cube texture to convert in env file
  47845. * @return a promise containing the environment data if succesfull.
  47846. */
  47847. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47848. /**
  47849. * Creates a JSON representation of the spherical data.
  47850. * @param texture defines the texture containing the polynomials
  47851. * @return the JSON representation of the spherical info
  47852. */
  47853. private static _CreateEnvTextureIrradiance;
  47854. /**
  47855. * Uploads the texture info contained in the env file to the GPU.
  47856. * @param texture defines the internal texture to upload to
  47857. * @param arrayBuffer defines the buffer cotaining the data to load
  47858. * @param info defines the texture info retrieved through the GetEnvInfo method
  47859. * @returns a promise
  47860. */
  47861. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47862. /**
  47863. * Uploads the levels of image data to the GPU.
  47864. * @param texture defines the internal texture to upload to
  47865. * @param imageData defines the array buffer views of image data [mipmap][face]
  47866. * @returns a promise
  47867. */
  47868. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47869. /**
  47870. * Uploads spherical polynomials information to the texture.
  47871. * @param texture defines the texture we are trying to upload the information to
  47872. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47873. */
  47874. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47875. /** @hidden */
  47876. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47877. }
  47878. }
  47879. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47880. import { Nullable } from "babylonjs/types";
  47881. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47882. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47883. /**
  47884. * Implementation of the ENV Texture Loader.
  47885. * @hidden
  47886. */
  47887. export class _ENVTextureLoader implements IInternalTextureLoader {
  47888. /**
  47889. * Defines wether the loader supports cascade loading the different faces.
  47890. */
  47891. readonly supportCascades: boolean;
  47892. /**
  47893. * This returns if the loader support the current file information.
  47894. * @param extension defines the file extension of the file being loaded
  47895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47896. * @param fallback defines the fallback internal texture if any
  47897. * @param isBase64 defines whether the texture is encoded as a base64
  47898. * @param isBuffer defines whether the texture data are stored as a buffer
  47899. * @returns true if the loader can load the specified file
  47900. */
  47901. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47902. /**
  47903. * Transform the url before loading if required.
  47904. * @param rootUrl the url of the texture
  47905. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47906. * @returns the transformed texture
  47907. */
  47908. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47909. /**
  47910. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47911. * @param rootUrl the url of the texture
  47912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47913. * @returns the fallback texture
  47914. */
  47915. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47916. /**
  47917. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47918. * @param data contains the texture data
  47919. * @param texture defines the BabylonJS internal texture
  47920. * @param createPolynomials will be true if polynomials have been requested
  47921. * @param onLoad defines the callback to trigger once the texture is ready
  47922. * @param onError defines the callback to trigger in case of error
  47923. */
  47924. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47925. /**
  47926. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47927. * @param data contains the texture data
  47928. * @param texture defines the BabylonJS internal texture
  47929. * @param callback defines the method to call once ready to upload
  47930. */
  47931. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47932. }
  47933. }
  47934. declare module "babylonjs/Misc/khronosTextureContainer" {
  47935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47936. /**
  47937. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47938. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47939. */
  47940. export class KhronosTextureContainer {
  47941. /** contents of the KTX container file */
  47942. arrayBuffer: any;
  47943. private static HEADER_LEN;
  47944. private static COMPRESSED_2D;
  47945. private static COMPRESSED_3D;
  47946. private static TEX_2D;
  47947. private static TEX_3D;
  47948. /**
  47949. * Gets the openGL type
  47950. */
  47951. glType: number;
  47952. /**
  47953. * Gets the openGL type size
  47954. */
  47955. glTypeSize: number;
  47956. /**
  47957. * Gets the openGL format
  47958. */
  47959. glFormat: number;
  47960. /**
  47961. * Gets the openGL internal format
  47962. */
  47963. glInternalFormat: number;
  47964. /**
  47965. * Gets the base internal format
  47966. */
  47967. glBaseInternalFormat: number;
  47968. /**
  47969. * Gets image width in pixel
  47970. */
  47971. pixelWidth: number;
  47972. /**
  47973. * Gets image height in pixel
  47974. */
  47975. pixelHeight: number;
  47976. /**
  47977. * Gets image depth in pixels
  47978. */
  47979. pixelDepth: number;
  47980. /**
  47981. * Gets the number of array elements
  47982. */
  47983. numberOfArrayElements: number;
  47984. /**
  47985. * Gets the number of faces
  47986. */
  47987. numberOfFaces: number;
  47988. /**
  47989. * Gets the number of mipmap levels
  47990. */
  47991. numberOfMipmapLevels: number;
  47992. /**
  47993. * Gets the bytes of key value data
  47994. */
  47995. bytesOfKeyValueData: number;
  47996. /**
  47997. * Gets the load type
  47998. */
  47999. loadType: number;
  48000. /**
  48001. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48002. */
  48003. isInvalid: boolean;
  48004. /**
  48005. * Creates a new KhronosTextureContainer
  48006. * @param arrayBuffer contents of the KTX container file
  48007. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48008. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48009. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48010. */
  48011. constructor(
  48012. /** contents of the KTX container file */
  48013. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48014. /**
  48015. * Uploads KTX content to a Babylon Texture.
  48016. * It is assumed that the texture has already been created & is currently bound
  48017. * @hidden
  48018. */
  48019. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48020. private _upload2DCompressedLevels;
  48021. }
  48022. }
  48023. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48024. import { Nullable } from "babylonjs/types";
  48025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48026. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48027. /**
  48028. * Implementation of the KTX Texture Loader.
  48029. * @hidden
  48030. */
  48031. export class _KTXTextureLoader implements IInternalTextureLoader {
  48032. /**
  48033. * Defines wether the loader supports cascade loading the different faces.
  48034. */
  48035. readonly supportCascades: boolean;
  48036. /**
  48037. * This returns if the loader support the current file information.
  48038. * @param extension defines the file extension of the file being loaded
  48039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48040. * @param fallback defines the fallback internal texture if any
  48041. * @param isBase64 defines whether the texture is encoded as a base64
  48042. * @param isBuffer defines whether the texture data are stored as a buffer
  48043. * @returns true if the loader can load the specified file
  48044. */
  48045. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48046. /**
  48047. * Transform the url before loading if required.
  48048. * @param rootUrl the url of the texture
  48049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48050. * @returns the transformed texture
  48051. */
  48052. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48053. /**
  48054. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48055. * @param rootUrl the url of the texture
  48056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48057. * @returns the fallback texture
  48058. */
  48059. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48060. /**
  48061. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48062. * @param data contains the texture data
  48063. * @param texture defines the BabylonJS internal texture
  48064. * @param createPolynomials will be true if polynomials have been requested
  48065. * @param onLoad defines the callback to trigger once the texture is ready
  48066. * @param onError defines the callback to trigger in case of error
  48067. */
  48068. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48069. /**
  48070. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48071. * @param data contains the texture data
  48072. * @param texture defines the BabylonJS internal texture
  48073. * @param callback defines the method to call once ready to upload
  48074. */
  48075. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48076. }
  48077. }
  48078. declare module "babylonjs/Misc/tga" {
  48079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48080. /**
  48081. * Based on jsTGALoader - Javascript loader for TGA file
  48082. * By Vincent Thibault
  48083. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48084. */
  48085. export class TGATools {
  48086. private static _TYPE_INDEXED;
  48087. private static _TYPE_RGB;
  48088. private static _TYPE_GREY;
  48089. private static _TYPE_RLE_INDEXED;
  48090. private static _TYPE_RLE_RGB;
  48091. private static _TYPE_RLE_GREY;
  48092. private static _ORIGIN_MASK;
  48093. private static _ORIGIN_SHIFT;
  48094. private static _ORIGIN_BL;
  48095. private static _ORIGIN_BR;
  48096. private static _ORIGIN_UL;
  48097. private static _ORIGIN_UR;
  48098. /**
  48099. * Gets the header of a TGA file
  48100. * @param data defines the TGA data
  48101. * @returns the header
  48102. */
  48103. static GetTGAHeader(data: Uint8Array): any;
  48104. /**
  48105. * Uploads TGA content to a Babylon Texture
  48106. * @hidden
  48107. */
  48108. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48109. /** @hidden */
  48110. 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;
  48111. /** @hidden */
  48112. 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;
  48113. /** @hidden */
  48114. 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;
  48115. /** @hidden */
  48116. 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;
  48117. /** @hidden */
  48118. 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;
  48119. /** @hidden */
  48120. 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;
  48121. }
  48122. }
  48123. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48124. import { Nullable } from "babylonjs/types";
  48125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48126. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48127. /**
  48128. * Implementation of the TGA Texture Loader.
  48129. * @hidden
  48130. */
  48131. export class _TGATextureLoader implements IInternalTextureLoader {
  48132. /**
  48133. * Defines wether the loader supports cascade loading the different faces.
  48134. */
  48135. readonly supportCascades: boolean;
  48136. /**
  48137. * This returns if the loader support the current file information.
  48138. * @param extension defines the file extension of the file being loaded
  48139. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48140. * @param fallback defines the fallback internal texture if any
  48141. * @param isBase64 defines whether the texture is encoded as a base64
  48142. * @param isBuffer defines whether the texture data are stored as a buffer
  48143. * @returns true if the loader can load the specified file
  48144. */
  48145. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48146. /**
  48147. * Transform the url before loading if required.
  48148. * @param rootUrl the url of the texture
  48149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48150. * @returns the transformed texture
  48151. */
  48152. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48153. /**
  48154. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48155. * @param rootUrl the url of the texture
  48156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48157. * @returns the fallback texture
  48158. */
  48159. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48160. /**
  48161. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48162. * @param data contains the texture data
  48163. * @param texture defines the BabylonJS internal texture
  48164. * @param createPolynomials will be true if polynomials have been requested
  48165. * @param onLoad defines the callback to trigger once the texture is ready
  48166. * @param onError defines the callback to trigger in case of error
  48167. */
  48168. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48169. /**
  48170. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48171. * @param data contains the texture data
  48172. * @param texture defines the BabylonJS internal texture
  48173. * @param callback defines the method to call once ready to upload
  48174. */
  48175. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48176. }
  48177. }
  48178. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48179. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48180. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48181. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48182. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48183. }
  48184. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48185. import { Scene } from "babylonjs/scene";
  48186. import { Texture } from "babylonjs/Materials/Textures/texture";
  48187. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48188. /**
  48189. * 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.
  48190. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48192. */
  48193. export class CustomProceduralTexture extends ProceduralTexture {
  48194. private _animate;
  48195. private _time;
  48196. private _config;
  48197. private _texturePath;
  48198. /**
  48199. * Instantiates a new Custom Procedural Texture.
  48200. * 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.
  48201. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48203. * @param name Define the name of the texture
  48204. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48205. * @param size Define the size of the texture to create
  48206. * @param scene Define the scene the texture belongs to
  48207. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48208. * @param generateMipMaps Define if the texture should creates mip maps or not
  48209. */
  48210. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48211. private _loadJson;
  48212. /**
  48213. * Is the texture ready to be used ? (rendered at least once)
  48214. * @returns true if ready, otherwise, false.
  48215. */
  48216. isReady(): boolean;
  48217. /**
  48218. * Render the texture to its associated render target.
  48219. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48220. */
  48221. render(useCameraPostProcess?: boolean): void;
  48222. /**
  48223. * Update the list of dependant textures samplers in the shader.
  48224. */
  48225. updateTextures(): void;
  48226. /**
  48227. * Update the uniform values of the procedural texture in the shader.
  48228. */
  48229. updateShaderUniforms(): void;
  48230. /**
  48231. * Define if the texture animates or not.
  48232. */
  48233. animate: boolean;
  48234. }
  48235. }
  48236. declare module "babylonjs/Shaders/noise.fragment" {
  48237. /** @hidden */
  48238. export var noisePixelShader: {
  48239. name: string;
  48240. shader: string;
  48241. };
  48242. }
  48243. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48244. import { Nullable } from "babylonjs/types";
  48245. import { Scene } from "babylonjs/scene";
  48246. import { Texture } from "babylonjs/Materials/Textures/texture";
  48247. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48248. import "babylonjs/Shaders/noise.fragment";
  48249. /**
  48250. * Class used to generate noise procedural textures
  48251. */
  48252. export class NoiseProceduralTexture extends ProceduralTexture {
  48253. private _time;
  48254. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48255. brightness: number;
  48256. /** Defines the number of octaves to process */
  48257. octaves: number;
  48258. /** Defines the level of persistence (0.8 by default) */
  48259. persistence: number;
  48260. /** Gets or sets animation speed factor (default is 1) */
  48261. animationSpeedFactor: number;
  48262. /**
  48263. * Creates a new NoiseProceduralTexture
  48264. * @param name defines the name fo the texture
  48265. * @param size defines the size of the texture (default is 256)
  48266. * @param scene defines the hosting scene
  48267. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48268. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48269. */
  48270. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48271. private _updateShaderUniforms;
  48272. protected _getDefines(): string;
  48273. /** Generate the current state of the procedural texture */
  48274. render(useCameraPostProcess?: boolean): void;
  48275. /**
  48276. * Serializes this noise procedural texture
  48277. * @returns a serialized noise procedural texture object
  48278. */
  48279. serialize(): any;
  48280. /**
  48281. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48282. * @param parsedTexture defines parsed texture data
  48283. * @param scene defines the current scene
  48284. * @param rootUrl defines the root URL containing noise procedural texture information
  48285. * @returns a parsed NoiseProceduralTexture
  48286. */
  48287. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48288. }
  48289. }
  48290. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48291. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48292. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48293. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48294. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48295. }
  48296. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48297. import { Nullable } from "babylonjs/types";
  48298. import { Scene } from "babylonjs/scene";
  48299. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48300. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48301. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48302. /**
  48303. * Raw cube texture where the raw buffers are passed in
  48304. */
  48305. export class RawCubeTexture extends CubeTexture {
  48306. /**
  48307. * Creates a cube texture where the raw buffers are passed in.
  48308. * @param scene defines the scene the texture is attached to
  48309. * @param data defines the array of data to use to create each face
  48310. * @param size defines the size of the textures
  48311. * @param format defines the format of the data
  48312. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48313. * @param generateMipMaps defines if the engine should generate the mip levels
  48314. * @param invertY defines if data must be stored with Y axis inverted
  48315. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48316. * @param compression defines the compression used (null by default)
  48317. */
  48318. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48319. /**
  48320. * Updates the raw cube texture.
  48321. * @param data defines the data to store
  48322. * @param format defines the data format
  48323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48324. * @param invertY defines if data must be stored with Y axis inverted
  48325. * @param compression defines the compression used (null by default)
  48326. * @param level defines which level of the texture to update
  48327. */
  48328. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48329. /**
  48330. * Updates a raw cube texture with RGBD encoded data.
  48331. * @param data defines the array of data [mipmap][face] to use to create each face
  48332. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48333. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48334. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48335. * @returns a promsie that resolves when the operation is complete
  48336. */
  48337. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48338. /**
  48339. * Clones the raw cube texture.
  48340. * @return a new cube texture
  48341. */
  48342. clone(): CubeTexture;
  48343. /** @hidden */
  48344. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48345. }
  48346. }
  48347. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48348. import { Scene } from "babylonjs/scene";
  48349. import { Texture } from "babylonjs/Materials/Textures/texture";
  48350. /**
  48351. * Class used to store 3D textures containing user data
  48352. */
  48353. export class RawTexture3D extends Texture {
  48354. /** Gets or sets the texture format to use */
  48355. format: number;
  48356. private _engine;
  48357. /**
  48358. * Create a new RawTexture3D
  48359. * @param data defines the data of the texture
  48360. * @param width defines the width of the texture
  48361. * @param height defines the height of the texture
  48362. * @param depth defines the depth of the texture
  48363. * @param format defines the texture format to use
  48364. * @param scene defines the hosting scene
  48365. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48366. * @param invertY defines if texture must be stored with Y axis inverted
  48367. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48368. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48369. */
  48370. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48371. /** Gets or sets the texture format to use */
  48372. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48373. /**
  48374. * Update the texture with new data
  48375. * @param data defines the data to store in the texture
  48376. */
  48377. update(data: ArrayBufferView): void;
  48378. }
  48379. }
  48380. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48381. import { Scene } from "babylonjs/scene";
  48382. import { Plane } from "babylonjs/Maths/math";
  48383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48384. /**
  48385. * Creates a refraction texture used by refraction channel of the standard material.
  48386. * It is like a mirror but to see through a material.
  48387. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48388. */
  48389. export class RefractionTexture extends RenderTargetTexture {
  48390. /**
  48391. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48392. * 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.
  48393. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48394. */
  48395. refractionPlane: Plane;
  48396. /**
  48397. * Define how deep under the surface we should see.
  48398. */
  48399. depth: number;
  48400. /**
  48401. * Creates a refraction texture used by refraction channel of the standard material.
  48402. * It is like a mirror but to see through a material.
  48403. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48404. * @param name Define the texture name
  48405. * @param size Define the size of the underlying texture
  48406. * @param scene Define the scene the refraction belongs to
  48407. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48408. */
  48409. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48410. /**
  48411. * Clone the refraction texture.
  48412. * @returns the cloned texture
  48413. */
  48414. clone(): RefractionTexture;
  48415. /**
  48416. * Serialize the texture to a JSON representation you could use in Parse later on
  48417. * @returns the serialized JSON representation
  48418. */
  48419. serialize(): any;
  48420. }
  48421. }
  48422. declare module "babylonjs/Materials/Textures/index" {
  48423. export * from "babylonjs/Materials/Textures/baseTexture";
  48424. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48425. export * from "babylonjs/Materials/Textures/cubeTexture";
  48426. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48427. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48428. export * from "babylonjs/Materials/Textures/internalTexture";
  48429. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48430. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48431. export * from "babylonjs/Materials/Textures/Loaders/index";
  48432. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48433. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48434. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48435. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48436. export * from "babylonjs/Materials/Textures/rawTexture";
  48437. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48438. export * from "babylonjs/Materials/Textures/refractionTexture";
  48439. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48440. export * from "babylonjs/Materials/Textures/texture";
  48441. export * from "babylonjs/Materials/Textures/videoTexture";
  48442. }
  48443. declare module "babylonjs/Materials/index" {
  48444. export * from "babylonjs/Materials/Background/index";
  48445. export * from "babylonjs/Materials/colorCurves";
  48446. export * from "babylonjs/Materials/effect";
  48447. export * from "babylonjs/Materials/fresnelParameters";
  48448. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48449. export * from "babylonjs/Materials/material";
  48450. export * from "babylonjs/Materials/materialDefines";
  48451. export * from "babylonjs/Materials/materialHelper";
  48452. export * from "babylonjs/Materials/multiMaterial";
  48453. export * from "babylonjs/Materials/PBR/index";
  48454. export * from "babylonjs/Materials/pushMaterial";
  48455. export * from "babylonjs/Materials/shaderMaterial";
  48456. export * from "babylonjs/Materials/standardMaterial";
  48457. export * from "babylonjs/Materials/Textures/index";
  48458. export * from "babylonjs/Materials/uniformBuffer";
  48459. export * from "babylonjs/Materials/materialFlags";
  48460. }
  48461. declare module "babylonjs/Maths/index" {
  48462. export * from "babylonjs/Maths/math.scalar";
  48463. export * from "babylonjs/Maths/math";
  48464. export * from "babylonjs/Maths/sphericalPolynomial";
  48465. }
  48466. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48467. import { IDisposable } from "babylonjs/scene";
  48468. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48469. /**
  48470. * Configuration for Draco compression
  48471. */
  48472. export interface IDracoCompressionConfiguration {
  48473. /**
  48474. * Configuration for the decoder.
  48475. */
  48476. decoder?: {
  48477. /**
  48478. * The url to the WebAssembly module.
  48479. */
  48480. wasmUrl?: string;
  48481. /**
  48482. * The url to the WebAssembly binary.
  48483. */
  48484. wasmBinaryUrl?: string;
  48485. /**
  48486. * The url to the fallback JavaScript module.
  48487. */
  48488. fallbackUrl?: string;
  48489. };
  48490. }
  48491. /**
  48492. * Draco compression (https://google.github.io/draco/)
  48493. *
  48494. * This class wraps the Draco module.
  48495. *
  48496. * **Encoder**
  48497. *
  48498. * The encoder is not currently implemented.
  48499. *
  48500. * **Decoder**
  48501. *
  48502. * 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.
  48503. *
  48504. * To update the configuration, use the following code:
  48505. * ```javascript
  48506. * DracoCompression.Configuration = {
  48507. * decoder: {
  48508. * wasmUrl: "<url to the WebAssembly library>",
  48509. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48510. * fallbackUrl: "<url to the fallback JavaScript library>",
  48511. * }
  48512. * };
  48513. * ```
  48514. *
  48515. * 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.
  48516. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48517. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48518. *
  48519. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48520. * ```javascript
  48521. * var dracoCompression = new DracoCompression();
  48522. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48523. * [VertexBuffer.PositionKind]: 0
  48524. * });
  48525. * ```
  48526. *
  48527. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48528. */
  48529. export class DracoCompression implements IDisposable {
  48530. private static _DecoderModulePromise;
  48531. /**
  48532. * The configuration. Defaults to the following urls:
  48533. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48534. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48535. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48536. */
  48537. static Configuration: IDracoCompressionConfiguration;
  48538. /**
  48539. * Returns true if the decoder is available.
  48540. */
  48541. static readonly DecoderAvailable: boolean;
  48542. /**
  48543. * Constructor
  48544. */
  48545. constructor();
  48546. /**
  48547. * Stop all async operations and release resources.
  48548. */
  48549. dispose(): void;
  48550. /**
  48551. * Decode Draco compressed mesh data to vertex data.
  48552. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48553. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48554. * @returns A promise that resolves with the decoded vertex data
  48555. */
  48556. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48557. [kind: string]: number;
  48558. }): Promise<VertexData>;
  48559. private static _GetDecoderModule;
  48560. private static _LoadScriptAsync;
  48561. private static _LoadFileAsync;
  48562. }
  48563. }
  48564. declare module "babylonjs/Meshes/Compression/index" {
  48565. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48566. }
  48567. declare module "babylonjs/Meshes/csg" {
  48568. import { Nullable } from "babylonjs/types";
  48569. import { Scene } from "babylonjs/scene";
  48570. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48571. import { Mesh } from "babylonjs/Meshes/mesh";
  48572. import { Material } from "babylonjs/Materials/material";
  48573. /**
  48574. * Class for building Constructive Solid Geometry
  48575. */
  48576. export class CSG {
  48577. private polygons;
  48578. /**
  48579. * The world matrix
  48580. */
  48581. matrix: Matrix;
  48582. /**
  48583. * Stores the position
  48584. */
  48585. position: Vector3;
  48586. /**
  48587. * Stores the rotation
  48588. */
  48589. rotation: Vector3;
  48590. /**
  48591. * Stores the rotation quaternion
  48592. */
  48593. rotationQuaternion: Nullable<Quaternion>;
  48594. /**
  48595. * Stores the scaling vector
  48596. */
  48597. scaling: Vector3;
  48598. /**
  48599. * Convert the Mesh to CSG
  48600. * @param mesh The Mesh to convert to CSG
  48601. * @returns A new CSG from the Mesh
  48602. */
  48603. static FromMesh(mesh: Mesh): CSG;
  48604. /**
  48605. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48606. * @param polygons Polygons used to construct a CSG solid
  48607. */
  48608. private static FromPolygons;
  48609. /**
  48610. * Clones, or makes a deep copy, of the CSG
  48611. * @returns A new CSG
  48612. */
  48613. clone(): CSG;
  48614. /**
  48615. * Unions this CSG with another CSG
  48616. * @param csg The CSG to union against this CSG
  48617. * @returns The unioned CSG
  48618. */
  48619. union(csg: CSG): CSG;
  48620. /**
  48621. * Unions this CSG with another CSG in place
  48622. * @param csg The CSG to union against this CSG
  48623. */
  48624. unionInPlace(csg: CSG): void;
  48625. /**
  48626. * Subtracts this CSG with another CSG
  48627. * @param csg The CSG to subtract against this CSG
  48628. * @returns A new CSG
  48629. */
  48630. subtract(csg: CSG): CSG;
  48631. /**
  48632. * Subtracts this CSG with another CSG in place
  48633. * @param csg The CSG to subtact against this CSG
  48634. */
  48635. subtractInPlace(csg: CSG): void;
  48636. /**
  48637. * Intersect this CSG with another CSG
  48638. * @param csg The CSG to intersect against this CSG
  48639. * @returns A new CSG
  48640. */
  48641. intersect(csg: CSG): CSG;
  48642. /**
  48643. * Intersects this CSG with another CSG in place
  48644. * @param csg The CSG to intersect against this CSG
  48645. */
  48646. intersectInPlace(csg: CSG): void;
  48647. /**
  48648. * Return a new CSG solid with solid and empty space switched. This solid is
  48649. * not modified.
  48650. * @returns A new CSG solid with solid and empty space switched
  48651. */
  48652. inverse(): CSG;
  48653. /**
  48654. * Inverses the CSG in place
  48655. */
  48656. inverseInPlace(): void;
  48657. /**
  48658. * This is used to keep meshes transformations so they can be restored
  48659. * when we build back a Babylon Mesh
  48660. * NB : All CSG operations are performed in world coordinates
  48661. * @param csg The CSG to copy the transform attributes from
  48662. * @returns This CSG
  48663. */
  48664. copyTransformAttributes(csg: CSG): CSG;
  48665. /**
  48666. * Build Raw mesh from CSG
  48667. * Coordinates here are in world space
  48668. * @param name The name of the mesh geometry
  48669. * @param scene The Scene
  48670. * @param keepSubMeshes Specifies if the submeshes should be kept
  48671. * @returns A new Mesh
  48672. */
  48673. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48674. /**
  48675. * Build Mesh from CSG taking material and transforms into account
  48676. * @param name The name of the Mesh
  48677. * @param material The material of the Mesh
  48678. * @param scene The Scene
  48679. * @param keepSubMeshes Specifies if submeshes should be kept
  48680. * @returns The new Mesh
  48681. */
  48682. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48683. }
  48684. }
  48685. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  48686. import { Nullable } from "babylonjs/types";
  48687. import { Scene } from "babylonjs/scene";
  48688. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  48689. import { Mesh } from "babylonjs/Meshes/mesh";
  48690. /**
  48691. * Class containing static functions to help procedurally build meshes
  48692. */
  48693. export class RibbonBuilder {
  48694. /**
  48695. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48696. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48697. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48698. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48699. * * 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
  48700. * * 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
  48701. * * 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
  48702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48704. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48705. * * 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
  48706. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48707. * * 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
  48708. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48710. * @param name defines the name of the mesh
  48711. * @param options defines the options used to create the mesh
  48712. * @param scene defines the hosting scene
  48713. * @returns the ribbon mesh
  48714. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48716. */
  48717. static CreateRibbon(name: string, options: {
  48718. pathArray: Vector3[][];
  48719. closeArray?: boolean;
  48720. closePath?: boolean;
  48721. offset?: number;
  48722. updatable?: boolean;
  48723. sideOrientation?: number;
  48724. frontUVs?: Vector4;
  48725. backUVs?: Vector4;
  48726. instance?: Mesh;
  48727. invertUV?: boolean;
  48728. uvs?: Vector2[];
  48729. colors?: Color4[];
  48730. }, scene?: Nullable<Scene>): Mesh;
  48731. }
  48732. }
  48733. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  48734. import { Vector4 } from "babylonjs/Maths/math";
  48735. import { Mesh } from "babylonjs/Meshes/mesh";
  48736. /**
  48737. * Class containing static functions to help procedurally build meshes
  48738. */
  48739. export class TorusKnotBuilder {
  48740. /**
  48741. * Creates a torus knot mesh
  48742. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48743. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48744. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48745. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48749. * @param name defines the name of the mesh
  48750. * @param options defines the options used to create the mesh
  48751. * @param scene defines the hosting scene
  48752. * @returns the torus knot mesh
  48753. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48754. */
  48755. static CreateTorusKnot(name: string, options: {
  48756. radius?: number;
  48757. tube?: number;
  48758. radialSegments?: number;
  48759. tubularSegments?: number;
  48760. p?: number;
  48761. q?: number;
  48762. updatable?: boolean;
  48763. sideOrientation?: number;
  48764. frontUVs?: Vector4;
  48765. backUVs?: Vector4;
  48766. }, scene: any): Mesh;
  48767. }
  48768. }
  48769. declare module "babylonjs/Meshes/polygonMesh" {
  48770. import { Scene } from "babylonjs/scene";
  48771. import { Vector2, Path2 } from "babylonjs/Maths/math";
  48772. import { Mesh } from "babylonjs/Meshes/mesh";
  48773. /**
  48774. * Polygon
  48775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48776. */
  48777. export class Polygon {
  48778. /**
  48779. * Creates a rectangle
  48780. * @param xmin bottom X coord
  48781. * @param ymin bottom Y coord
  48782. * @param xmax top X coord
  48783. * @param ymax top Y coord
  48784. * @returns points that make the resulting rectation
  48785. */
  48786. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48787. /**
  48788. * Creates a circle
  48789. * @param radius radius of circle
  48790. * @param cx scale in x
  48791. * @param cy scale in y
  48792. * @param numberOfSides number of sides that make up the circle
  48793. * @returns points that make the resulting circle
  48794. */
  48795. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48796. /**
  48797. * Creates a polygon from input string
  48798. * @param input Input polygon data
  48799. * @returns the parsed points
  48800. */
  48801. static Parse(input: string): Vector2[];
  48802. /**
  48803. * Starts building a polygon from x and y coordinates
  48804. * @param x x coordinate
  48805. * @param y y coordinate
  48806. * @returns the started path2
  48807. */
  48808. static StartingAt(x: number, y: number): Path2;
  48809. }
  48810. /**
  48811. * Builds a polygon
  48812. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48813. */
  48814. export class PolygonMeshBuilder {
  48815. private _points;
  48816. private _outlinepoints;
  48817. private _holes;
  48818. private _name;
  48819. private _scene;
  48820. private _epoints;
  48821. private _eholes;
  48822. private _addToepoint;
  48823. /**
  48824. * Babylon reference to the earcut plugin.
  48825. */
  48826. bjsEarcut: any;
  48827. /**
  48828. * Creates a PolygonMeshBuilder
  48829. * @param name name of the builder
  48830. * @param contours Path of the polygon
  48831. * @param scene scene to add to
  48832. * @param earcutInjection can be used to inject your own earcut reference
  48833. */
  48834. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  48835. /**
  48836. * Adds a whole within the polygon
  48837. * @param hole Array of points defining the hole
  48838. * @returns this
  48839. */
  48840. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48841. /**
  48842. * Creates the polygon
  48843. * @param updatable If the mesh should be updatable
  48844. * @param depth The depth of the mesh created
  48845. * @returns the created mesh
  48846. */
  48847. build(updatable?: boolean, depth?: number): Mesh;
  48848. /**
  48849. * Adds a side to the polygon
  48850. * @param positions points that make the polygon
  48851. * @param normals normals of the polygon
  48852. * @param uvs uvs of the polygon
  48853. * @param indices indices of the polygon
  48854. * @param bounds bounds of the polygon
  48855. * @param points points of the polygon
  48856. * @param depth depth of the polygon
  48857. * @param flip flip of the polygon
  48858. */
  48859. private addSide;
  48860. }
  48861. }
  48862. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  48863. import { Scene } from "babylonjs/scene";
  48864. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  48865. import { Mesh } from "babylonjs/Meshes/mesh";
  48866. /**
  48867. * Class containing static functions to help procedurally build meshes
  48868. */
  48869. export class PolygonBuilder {
  48870. /**
  48871. * Creates a polygon mesh
  48872. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48873. * * 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
  48874. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48877. * * Remember you can only change the shape positions, not their number when updating a polygon
  48878. * @param name defines the name of the mesh
  48879. * @param options defines the options used to create the mesh
  48880. * @param scene defines the hosting scene
  48881. * @param earcutInjection can be used to inject your own earcut reference
  48882. * @returns the polygon mesh
  48883. */
  48884. static CreatePolygon(name: string, options: {
  48885. shape: Vector3[];
  48886. holes?: Vector3[][];
  48887. depth?: number;
  48888. faceUV?: Vector4[];
  48889. faceColors?: Color4[];
  48890. updatable?: boolean;
  48891. sideOrientation?: number;
  48892. frontUVs?: Vector4;
  48893. backUVs?: Vector4;
  48894. }, scene: Scene, earcutInjection?: any): Mesh;
  48895. /**
  48896. * Creates an extruded polygon mesh, with depth in the Y direction.
  48897. * * 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)
  48898. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48899. * @param name defines the name of the mesh
  48900. * @param options defines the options used to create the mesh
  48901. * @param scene defines the hosting scene
  48902. * @param earcutInjection can be used to inject your own earcut reference
  48903. * @returns the polygon mesh
  48904. */
  48905. static ExtrudePolygon(name: string, options: {
  48906. shape: Vector3[];
  48907. holes?: Vector3[][];
  48908. depth?: number;
  48909. faceUV?: Vector4[];
  48910. faceColors?: Color4[];
  48911. updatable?: boolean;
  48912. sideOrientation?: number;
  48913. frontUVs?: Vector4;
  48914. backUVs?: Vector4;
  48915. }, scene: Scene, earcutInjection?: any): Mesh;
  48916. }
  48917. }
  48918. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  48919. import { Nullable } from "babylonjs/types";
  48920. import { Scene } from "babylonjs/scene";
  48921. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48922. import { Mesh } from "babylonjs/Meshes/mesh";
  48923. /**
  48924. * Class containing static functions to help procedurally build meshes
  48925. */
  48926. export class ShapeBuilder {
  48927. /**
  48928. * 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.
  48929. * * 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.
  48930. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48931. * * 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.
  48932. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48933. * * 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
  48934. * * 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
  48935. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48940. * @param name defines the name of the mesh
  48941. * @param options defines the options used to create the mesh
  48942. * @param scene defines the hosting scene
  48943. * @returns the extruded shape mesh
  48944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48946. */
  48947. static ExtrudeShape(name: string, options: {
  48948. shape: Vector3[];
  48949. path: Vector3[];
  48950. scale?: number;
  48951. rotation?: number;
  48952. cap?: number;
  48953. updatable?: boolean;
  48954. sideOrientation?: number;
  48955. frontUVs?: Vector4;
  48956. backUVs?: Vector4;
  48957. instance?: Mesh;
  48958. invertUV?: boolean;
  48959. }, scene?: Nullable<Scene>): Mesh;
  48960. /**
  48961. * Creates an custom extruded shape mesh.
  48962. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48963. * * 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.
  48964. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48965. * * 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
  48966. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48967. * * 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
  48968. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48969. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48970. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48971. * * 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
  48972. * * 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
  48973. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48976. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48978. * @param name defines the name of the mesh
  48979. * @param options defines the options used to create the mesh
  48980. * @param scene defines the hosting scene
  48981. * @returns the custom extruded shape mesh
  48982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48984. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48985. */
  48986. static ExtrudeShapeCustom(name: string, options: {
  48987. shape: Vector3[];
  48988. path: Vector3[];
  48989. scaleFunction?: any;
  48990. rotationFunction?: any;
  48991. ribbonCloseArray?: boolean;
  48992. ribbonClosePath?: boolean;
  48993. cap?: number;
  48994. updatable?: boolean;
  48995. sideOrientation?: number;
  48996. frontUVs?: Vector4;
  48997. backUVs?: Vector4;
  48998. instance?: Mesh;
  48999. invertUV?: boolean;
  49000. }, scene: Scene): Mesh;
  49001. private static _ExtrudeShapeGeneric;
  49002. }
  49003. }
  49004. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49005. import { Scene } from "babylonjs/scene";
  49006. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49007. import { Mesh } from "babylonjs/Meshes/mesh";
  49008. /**
  49009. * Class containing static functions to help procedurally build meshes
  49010. */
  49011. export class LatheBuilder {
  49012. /**
  49013. * Creates lathe mesh.
  49014. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49015. * * 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
  49016. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49017. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49018. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49019. * * 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
  49020. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49021. * * 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
  49022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49026. * @param name defines the name of the mesh
  49027. * @param options defines the options used to create the mesh
  49028. * @param scene defines the hosting scene
  49029. * @returns the lathe mesh
  49030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49031. */
  49032. static CreateLathe(name: string, options: {
  49033. shape: Vector3[];
  49034. radius?: number;
  49035. tessellation?: number;
  49036. clip?: number;
  49037. arc?: number;
  49038. closed?: boolean;
  49039. updatable?: boolean;
  49040. sideOrientation?: number;
  49041. frontUVs?: Vector4;
  49042. backUVs?: Vector4;
  49043. cap?: number;
  49044. invertUV?: boolean;
  49045. }, scene: Scene): Mesh;
  49046. }
  49047. }
  49048. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49049. import { Scene } from "babylonjs/scene";
  49050. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49051. import { Mesh } from "babylonjs/Meshes/mesh";
  49052. /**
  49053. * Class containing static functions to help procedurally build meshes
  49054. */
  49055. export class TubeBuilder {
  49056. /**
  49057. * Creates a tube mesh.
  49058. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49059. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49060. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49061. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49062. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49063. * * 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)
  49064. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49065. * * 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
  49066. * * 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
  49067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49069. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49071. * @param name defines the name of the mesh
  49072. * @param options defines the options used to create the mesh
  49073. * @param scene defines the hosting scene
  49074. * @returns the tube mesh
  49075. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49076. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49077. */
  49078. static CreateTube(name: string, options: {
  49079. path: Vector3[];
  49080. radius?: number;
  49081. tessellation?: number;
  49082. radiusFunction?: {
  49083. (i: number, distance: number): number;
  49084. };
  49085. cap?: number;
  49086. arc?: number;
  49087. updatable?: boolean;
  49088. sideOrientation?: number;
  49089. frontUVs?: Vector4;
  49090. backUVs?: Vector4;
  49091. instance?: Mesh;
  49092. invertUV?: boolean;
  49093. }, scene: Scene): Mesh;
  49094. }
  49095. }
  49096. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49097. import { Scene } from "babylonjs/scene";
  49098. import { Vector4 } from "babylonjs/Maths/math";
  49099. import { Mesh } from "babylonjs/Meshes/mesh";
  49100. /**
  49101. * Class containing static functions to help procedurally build meshes
  49102. */
  49103. export class IcoSphereBuilder {
  49104. /**
  49105. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49106. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49107. * * 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`)
  49108. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49109. * * 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
  49110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49113. * @param name defines the name of the mesh
  49114. * @param options defines the options used to create the mesh
  49115. * @param scene defines the hosting scene
  49116. * @returns the icosahedron mesh
  49117. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49118. */
  49119. static CreateIcoSphere(name: string, options: {
  49120. radius?: number;
  49121. radiusX?: number;
  49122. radiusY?: number;
  49123. radiusZ?: number;
  49124. flat?: boolean;
  49125. subdivisions?: number;
  49126. sideOrientation?: number;
  49127. frontUVs?: Vector4;
  49128. backUVs?: Vector4;
  49129. updatable?: boolean;
  49130. }, scene: Scene): Mesh;
  49131. }
  49132. }
  49133. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49134. import { Vector3 } from "babylonjs/Maths/math";
  49135. import { Mesh } from "babylonjs/Meshes/mesh";
  49136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49137. /**
  49138. * Class containing static functions to help procedurally build meshes
  49139. */
  49140. export class DecalBuilder {
  49141. /**
  49142. * Creates a decal mesh.
  49143. * 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
  49144. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49145. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49146. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49147. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49148. * @param name defines the name of the mesh
  49149. * @param sourceMesh defines the mesh where the decal must be applied
  49150. * @param options defines the options used to create the mesh
  49151. * @param scene defines the hosting scene
  49152. * @returns the decal mesh
  49153. * @see https://doc.babylonjs.com/how_to/decals
  49154. */
  49155. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49156. position?: Vector3;
  49157. normal?: Vector3;
  49158. size?: Vector3;
  49159. angle?: number;
  49160. }): Mesh;
  49161. }
  49162. }
  49163. declare module "babylonjs/Meshes/meshBuilder" {
  49164. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49165. import { Nullable } from "babylonjs/types";
  49166. import { Scene } from "babylonjs/scene";
  49167. import { Mesh } from "babylonjs/Meshes/mesh";
  49168. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49169. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49171. /**
  49172. * Class containing static functions to help procedurally build meshes
  49173. */
  49174. export class MeshBuilder {
  49175. /**
  49176. * Creates a box mesh
  49177. * * The parameter `size` sets the size (float) of each box side (default 1)
  49178. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49179. * * 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)
  49180. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49184. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49185. * @param name defines the name of the mesh
  49186. * @param options defines the options used to create the mesh
  49187. * @param scene defines the hosting scene
  49188. * @returns the box mesh
  49189. */
  49190. static CreateBox(name: string, options: {
  49191. size?: number;
  49192. width?: number;
  49193. height?: number;
  49194. depth?: number;
  49195. faceUV?: Vector4[];
  49196. faceColors?: Color4[];
  49197. sideOrientation?: number;
  49198. frontUVs?: Vector4;
  49199. backUVs?: Vector4;
  49200. updatable?: boolean;
  49201. }, scene?: Nullable<Scene>): Mesh;
  49202. /**
  49203. * Creates a sphere mesh
  49204. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49205. * * 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`)
  49206. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49207. * * 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
  49208. * * 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)
  49209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49212. * @param name defines the name of the mesh
  49213. * @param options defines the options used to create the mesh
  49214. * @param scene defines the hosting scene
  49215. * @returns the sphere mesh
  49216. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49217. */
  49218. static CreateSphere(name: string, options: {
  49219. segments?: number;
  49220. diameter?: number;
  49221. diameterX?: number;
  49222. diameterY?: number;
  49223. diameterZ?: number;
  49224. arc?: number;
  49225. slice?: number;
  49226. sideOrientation?: number;
  49227. frontUVs?: Vector4;
  49228. backUVs?: Vector4;
  49229. updatable?: boolean;
  49230. }, scene: any): Mesh;
  49231. /**
  49232. * Creates a plane polygonal mesh. By default, this is a disc
  49233. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49234. * * 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
  49235. * * 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
  49236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49239. * @param name defines the name of the mesh
  49240. * @param options defines the options used to create the mesh
  49241. * @param scene defines the hosting scene
  49242. * @returns the plane polygonal mesh
  49243. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49244. */
  49245. static CreateDisc(name: string, options: {
  49246. radius?: number;
  49247. tessellation?: number;
  49248. arc?: number;
  49249. updatable?: boolean;
  49250. sideOrientation?: number;
  49251. frontUVs?: Vector4;
  49252. backUVs?: Vector4;
  49253. }, scene?: Nullable<Scene>): Mesh;
  49254. /**
  49255. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49256. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49257. * * 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`)
  49258. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49259. * * 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
  49260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49263. * @param name defines the name of the mesh
  49264. * @param options defines the options used to create the mesh
  49265. * @param scene defines the hosting scene
  49266. * @returns the icosahedron mesh
  49267. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49268. */
  49269. static CreateIcoSphere(name: string, options: {
  49270. radius?: number;
  49271. radiusX?: number;
  49272. radiusY?: number;
  49273. radiusZ?: number;
  49274. flat?: boolean;
  49275. subdivisions?: number;
  49276. sideOrientation?: number;
  49277. frontUVs?: Vector4;
  49278. backUVs?: Vector4;
  49279. updatable?: boolean;
  49280. }, scene: Scene): Mesh;
  49281. /**
  49282. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49283. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49284. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49285. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49286. * * 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
  49287. * * 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
  49288. * * 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
  49289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49292. * * 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
  49293. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49294. * * 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
  49295. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49297. * @param name defines the name of the mesh
  49298. * @param options defines the options used to create the mesh
  49299. * @param scene defines the hosting scene
  49300. * @returns the ribbon mesh
  49301. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49303. */
  49304. static CreateRibbon(name: string, options: {
  49305. pathArray: Vector3[][];
  49306. closeArray?: boolean;
  49307. closePath?: boolean;
  49308. offset?: number;
  49309. updatable?: boolean;
  49310. sideOrientation?: number;
  49311. frontUVs?: Vector4;
  49312. backUVs?: Vector4;
  49313. instance?: Mesh;
  49314. invertUV?: boolean;
  49315. uvs?: Vector2[];
  49316. colors?: Color4[];
  49317. }, scene?: Nullable<Scene>): Mesh;
  49318. /**
  49319. * Creates a cylinder or a cone mesh
  49320. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49321. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49322. * * 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.
  49323. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49324. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49325. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49326. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49327. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49328. * * 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).
  49329. * * 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
  49330. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49331. * * 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
  49332. * * 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.
  49333. * * If `enclose` is false, a ring surface is one element.
  49334. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49335. * * 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
  49336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49339. * @param name defines the name of the mesh
  49340. * @param options defines the options used to create the mesh
  49341. * @param scene defines the hosting scene
  49342. * @returns the cylinder mesh
  49343. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49344. */
  49345. static CreateCylinder(name: string, options: {
  49346. height?: number;
  49347. diameterTop?: number;
  49348. diameterBottom?: number;
  49349. diameter?: number;
  49350. tessellation?: number;
  49351. subdivisions?: number;
  49352. arc?: number;
  49353. faceColors?: Color4[];
  49354. faceUV?: Vector4[];
  49355. updatable?: boolean;
  49356. hasRings?: boolean;
  49357. enclose?: boolean;
  49358. sideOrientation?: number;
  49359. frontUVs?: Vector4;
  49360. backUVs?: Vector4;
  49361. }, scene: any): Mesh;
  49362. /**
  49363. * Creates a torus mesh
  49364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49370. * @param name defines the name of the mesh
  49371. * @param options defines the options used to create the mesh
  49372. * @param scene defines the hosting scene
  49373. * @returns the torus mesh
  49374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49375. */
  49376. static CreateTorus(name: string, options: {
  49377. diameter?: number;
  49378. thickness?: number;
  49379. tessellation?: number;
  49380. updatable?: boolean;
  49381. sideOrientation?: number;
  49382. frontUVs?: Vector4;
  49383. backUVs?: Vector4;
  49384. }, scene: any): Mesh;
  49385. /**
  49386. * Creates a torus knot mesh
  49387. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49388. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49389. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49390. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49394. * @param name defines the name of the mesh
  49395. * @param options defines the options used to create the mesh
  49396. * @param scene defines the hosting scene
  49397. * @returns the torus knot mesh
  49398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49399. */
  49400. static CreateTorusKnot(name: string, options: {
  49401. radius?: number;
  49402. tube?: number;
  49403. radialSegments?: number;
  49404. tubularSegments?: number;
  49405. p?: number;
  49406. q?: number;
  49407. updatable?: boolean;
  49408. sideOrientation?: number;
  49409. frontUVs?: Vector4;
  49410. backUVs?: Vector4;
  49411. }, scene: any): Mesh;
  49412. /**
  49413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49414. * * 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
  49415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49420. * * 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
  49421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49424. * @param name defines the name of the new line system
  49425. * @param options defines the options used to create the line system
  49426. * @param scene defines the hosting scene
  49427. * @returns a new line system mesh
  49428. */
  49429. static CreateLineSystem(name: string, options: {
  49430. lines: Vector3[][];
  49431. updatable?: boolean;
  49432. instance?: Nullable<LinesMesh>;
  49433. colors?: Nullable<Color4[][]>;
  49434. useVertexAlpha?: boolean;
  49435. }, scene: Nullable<Scene>): LinesMesh;
  49436. /**
  49437. * Creates a line mesh
  49438. * 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
  49439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49440. * * The parameter `points` is an array successive Vector3
  49441. * * 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
  49442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49444. * * When updating an instance, remember that only point positions can change, not the number of points
  49445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49447. * @param name defines the name of the new line system
  49448. * @param options defines the options used to create the line system
  49449. * @param scene defines the hosting scene
  49450. * @returns a new line mesh
  49451. */
  49452. static CreateLines(name: string, options: {
  49453. points: Vector3[];
  49454. updatable?: boolean;
  49455. instance?: Nullable<LinesMesh>;
  49456. colors?: Color4[];
  49457. useVertexAlpha?: boolean;
  49458. }, scene?: Nullable<Scene>): LinesMesh;
  49459. /**
  49460. * Creates a dashed line mesh
  49461. * * 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
  49462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49463. * * The parameter `points` is an array successive Vector3
  49464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49467. * * 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
  49468. * * When updating an instance, remember that only point positions can change, not the number of points
  49469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49470. * @param name defines the name of the mesh
  49471. * @param options defines the options used to create the mesh
  49472. * @param scene defines the hosting scene
  49473. * @returns the dashed line mesh
  49474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49475. */
  49476. static CreateDashedLines(name: string, options: {
  49477. points: Vector3[];
  49478. dashSize?: number;
  49479. gapSize?: number;
  49480. dashNb?: number;
  49481. updatable?: boolean;
  49482. instance?: LinesMesh;
  49483. }, scene?: Nullable<Scene>): LinesMesh;
  49484. /**
  49485. * 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.
  49486. * * 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.
  49487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49488. * * 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.
  49489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49490. * * 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
  49491. * * 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
  49492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49494. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49497. * @param name defines the name of the mesh
  49498. * @param options defines the options used to create the mesh
  49499. * @param scene defines the hosting scene
  49500. * @returns the extruded shape mesh
  49501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49503. */
  49504. static ExtrudeShape(name: string, options: {
  49505. shape: Vector3[];
  49506. path: Vector3[];
  49507. scale?: number;
  49508. rotation?: number;
  49509. cap?: number;
  49510. updatable?: boolean;
  49511. sideOrientation?: number;
  49512. frontUVs?: Vector4;
  49513. backUVs?: Vector4;
  49514. instance?: Mesh;
  49515. invertUV?: boolean;
  49516. }, scene?: Nullable<Scene>): Mesh;
  49517. /**
  49518. * Creates an custom extruded shape mesh.
  49519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49520. * * 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.
  49521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49522. * * 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
  49523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49524. * * 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
  49525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49528. * * 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
  49529. * * 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
  49530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49535. * @param name defines the name of the mesh
  49536. * @param options defines the options used to create the mesh
  49537. * @param scene defines the hosting scene
  49538. * @returns the custom extruded shape mesh
  49539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49542. */
  49543. static ExtrudeShapeCustom(name: string, options: {
  49544. shape: Vector3[];
  49545. path: Vector3[];
  49546. scaleFunction?: any;
  49547. rotationFunction?: any;
  49548. ribbonCloseArray?: boolean;
  49549. ribbonClosePath?: boolean;
  49550. cap?: number;
  49551. updatable?: boolean;
  49552. sideOrientation?: number;
  49553. frontUVs?: Vector4;
  49554. backUVs?: Vector4;
  49555. instance?: Mesh;
  49556. invertUV?: boolean;
  49557. }, scene: Scene): Mesh;
  49558. /**
  49559. * Creates lathe mesh.
  49560. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49561. * * 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
  49562. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49563. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49564. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49565. * * 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
  49566. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49567. * * 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
  49568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49572. * @param name defines the name of the mesh
  49573. * @param options defines the options used to create the mesh
  49574. * @param scene defines the hosting scene
  49575. * @returns the lathe mesh
  49576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49577. */
  49578. static CreateLathe(name: string, options: {
  49579. shape: Vector3[];
  49580. radius?: number;
  49581. tessellation?: number;
  49582. clip?: number;
  49583. arc?: number;
  49584. closed?: boolean;
  49585. updatable?: boolean;
  49586. sideOrientation?: number;
  49587. frontUVs?: Vector4;
  49588. backUVs?: Vector4;
  49589. cap?: number;
  49590. invertUV?: boolean;
  49591. }, scene: Scene): Mesh;
  49592. /**
  49593. * Creates a plane mesh
  49594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49600. * @param name defines the name of the mesh
  49601. * @param options defines the options used to create the mesh
  49602. * @param scene defines the hosting scene
  49603. * @returns the plane mesh
  49604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49605. */
  49606. static CreatePlane(name: string, options: {
  49607. size?: number;
  49608. width?: number;
  49609. height?: number;
  49610. sideOrientation?: number;
  49611. frontUVs?: Vector4;
  49612. backUVs?: Vector4;
  49613. updatable?: boolean;
  49614. sourcePlane?: Plane;
  49615. }, scene: Scene): Mesh;
  49616. /**
  49617. * Creates a ground mesh
  49618. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49619. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49621. * @param name defines the name of the mesh
  49622. * @param options defines the options used to create the mesh
  49623. * @param scene defines the hosting scene
  49624. * @returns the ground mesh
  49625. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49626. */
  49627. static CreateGround(name: string, options: {
  49628. width?: number;
  49629. height?: number;
  49630. subdivisions?: number;
  49631. subdivisionsX?: number;
  49632. subdivisionsY?: number;
  49633. updatable?: boolean;
  49634. }, scene: any): Mesh;
  49635. /**
  49636. * Creates a tiled ground mesh
  49637. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49638. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49639. * * 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
  49640. * * 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
  49641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49642. * @param name defines the name of the mesh
  49643. * @param options defines the options used to create the mesh
  49644. * @param scene defines the hosting scene
  49645. * @returns the tiled ground mesh
  49646. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49647. */
  49648. static CreateTiledGround(name: string, options: {
  49649. xmin: number;
  49650. zmin: number;
  49651. xmax: number;
  49652. zmax: number;
  49653. subdivisions?: {
  49654. w: number;
  49655. h: number;
  49656. };
  49657. precision?: {
  49658. w: number;
  49659. h: number;
  49660. };
  49661. updatable?: boolean;
  49662. }, scene: Scene): Mesh;
  49663. /**
  49664. * Creates a ground mesh from a height map
  49665. * * The parameter `url` sets the URL of the height map image resource.
  49666. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49667. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49668. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49669. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49670. * * 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.
  49671. * * 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).
  49672. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49674. * @param name defines the name of the mesh
  49675. * @param url defines the url to the height map
  49676. * @param options defines the options used to create the mesh
  49677. * @param scene defines the hosting scene
  49678. * @returns the ground mesh
  49679. * @see https://doc.babylonjs.com/babylon101/height_map
  49680. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49681. */
  49682. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49683. width?: number;
  49684. height?: number;
  49685. subdivisions?: number;
  49686. minHeight?: number;
  49687. maxHeight?: number;
  49688. colorFilter?: Color3;
  49689. alphaFilter?: number;
  49690. updatable?: boolean;
  49691. onReady?: (mesh: GroundMesh) => void;
  49692. }, scene: Scene): GroundMesh;
  49693. /**
  49694. * Creates a polygon mesh
  49695. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49696. * * 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
  49697. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49700. * * Remember you can only change the shape positions, not their number when updating a polygon
  49701. * @param name defines the name of the mesh
  49702. * @param options defines the options used to create the mesh
  49703. * @param scene defines the hosting scene
  49704. * @param earcutInjection can be used to inject your own earcut reference
  49705. * @returns the polygon mesh
  49706. */
  49707. static CreatePolygon(name: string, options: {
  49708. shape: Vector3[];
  49709. holes?: Vector3[][];
  49710. depth?: number;
  49711. faceUV?: Vector4[];
  49712. faceColors?: Color4[];
  49713. updatable?: boolean;
  49714. sideOrientation?: number;
  49715. frontUVs?: Vector4;
  49716. backUVs?: Vector4;
  49717. }, scene: Scene, earcutInjection?: any): Mesh;
  49718. /**
  49719. * Creates an extruded polygon mesh, with depth in the Y direction.
  49720. * * 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)
  49721. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49722. * @param name defines the name of the mesh
  49723. * @param options defines the options used to create the mesh
  49724. * @param scene defines the hosting scene
  49725. * @param earcutInjection can be used to inject your own earcut reference
  49726. * @returns the polygon mesh
  49727. */
  49728. static ExtrudePolygon(name: string, options: {
  49729. shape: Vector3[];
  49730. holes?: Vector3[][];
  49731. depth?: number;
  49732. faceUV?: Vector4[];
  49733. faceColors?: Color4[];
  49734. updatable?: boolean;
  49735. sideOrientation?: number;
  49736. frontUVs?: Vector4;
  49737. backUVs?: Vector4;
  49738. }, scene: Scene, earcutInjection?: any): Mesh;
  49739. /**
  49740. * Creates a tube mesh.
  49741. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49742. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49743. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49744. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49745. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49746. * * 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)
  49747. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49748. * * 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
  49749. * * 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
  49750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49754. * @param name defines the name of the mesh
  49755. * @param options defines the options used to create the mesh
  49756. * @param scene defines the hosting scene
  49757. * @returns the tube mesh
  49758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49759. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49760. */
  49761. static CreateTube(name: string, options: {
  49762. path: Vector3[];
  49763. radius?: number;
  49764. tessellation?: number;
  49765. radiusFunction?: {
  49766. (i: number, distance: number): number;
  49767. };
  49768. cap?: number;
  49769. arc?: number;
  49770. updatable?: boolean;
  49771. sideOrientation?: number;
  49772. frontUVs?: Vector4;
  49773. backUVs?: Vector4;
  49774. instance?: Mesh;
  49775. invertUV?: boolean;
  49776. }, scene: Scene): Mesh;
  49777. /**
  49778. * Creates a polyhedron mesh
  49779. * * 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
  49780. * * The parameter `size` (positive float, default 1) sets the polygon size
  49781. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49782. * * 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`
  49783. * * 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
  49784. * * 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)`)
  49785. * * 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
  49786. * * 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
  49787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49790. * @param name defines the name of the mesh
  49791. * @param options defines the options used to create the mesh
  49792. * @param scene defines the hosting scene
  49793. * @returns the polyhedron mesh
  49794. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49795. */
  49796. static CreatePolyhedron(name: string, options: {
  49797. type?: number;
  49798. size?: number;
  49799. sizeX?: number;
  49800. sizeY?: number;
  49801. sizeZ?: number;
  49802. custom?: any;
  49803. faceUV?: Vector4[];
  49804. faceColors?: Color4[];
  49805. flat?: boolean;
  49806. updatable?: boolean;
  49807. sideOrientation?: number;
  49808. frontUVs?: Vector4;
  49809. backUVs?: Vector4;
  49810. }, scene: Scene): Mesh;
  49811. /**
  49812. * Creates a decal mesh.
  49813. * 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
  49814. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49815. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49816. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49817. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49818. * @param name defines the name of the mesh
  49819. * @param sourceMesh defines the mesh where the decal must be applied
  49820. * @param options defines the options used to create the mesh
  49821. * @param scene defines the hosting scene
  49822. * @returns the decal mesh
  49823. * @see https://doc.babylonjs.com/how_to/decals
  49824. */
  49825. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49826. position?: Vector3;
  49827. normal?: Vector3;
  49828. size?: Vector3;
  49829. angle?: number;
  49830. }): Mesh;
  49831. }
  49832. }
  49833. declare module "babylonjs/Meshes/meshSimplification" {
  49834. import { Mesh } from "babylonjs/Meshes/mesh";
  49835. /**
  49836. * A simplifier interface for future simplification implementations
  49837. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49838. */
  49839. export interface ISimplifier {
  49840. /**
  49841. * Simplification of a given mesh according to the given settings.
  49842. * Since this requires computation, it is assumed that the function runs async.
  49843. * @param settings The settings of the simplification, including quality and distance
  49844. * @param successCallback A callback that will be called after the mesh was simplified.
  49845. * @param errorCallback in case of an error, this callback will be called. optional.
  49846. */
  49847. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49848. }
  49849. /**
  49850. * Expected simplification settings.
  49851. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49852. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49853. */
  49854. export interface ISimplificationSettings {
  49855. /**
  49856. * Gets or sets the expected quality
  49857. */
  49858. quality: number;
  49859. /**
  49860. * Gets or sets the distance when this optimized version should be used
  49861. */
  49862. distance: number;
  49863. /**
  49864. * Gets an already optimized mesh
  49865. */
  49866. optimizeMesh?: boolean;
  49867. }
  49868. /**
  49869. * Class used to specify simplification options
  49870. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49871. */
  49872. export class SimplificationSettings implements ISimplificationSettings {
  49873. /** expected quality */
  49874. quality: number;
  49875. /** distance when this optimized version should be used */
  49876. distance: number;
  49877. /** already optimized mesh */
  49878. optimizeMesh?: boolean | undefined;
  49879. /**
  49880. * Creates a SimplificationSettings
  49881. * @param quality expected quality
  49882. * @param distance distance when this optimized version should be used
  49883. * @param optimizeMesh already optimized mesh
  49884. */
  49885. constructor(
  49886. /** expected quality */
  49887. quality: number,
  49888. /** distance when this optimized version should be used */
  49889. distance: number,
  49890. /** already optimized mesh */
  49891. optimizeMesh?: boolean | undefined);
  49892. }
  49893. /**
  49894. * Interface used to define a simplification task
  49895. */
  49896. export interface ISimplificationTask {
  49897. /**
  49898. * Array of settings
  49899. */
  49900. settings: Array<ISimplificationSettings>;
  49901. /**
  49902. * Simplification type
  49903. */
  49904. simplificationType: SimplificationType;
  49905. /**
  49906. * Mesh to simplify
  49907. */
  49908. mesh: Mesh;
  49909. /**
  49910. * Callback called on success
  49911. */
  49912. successCallback?: () => void;
  49913. /**
  49914. * Defines if parallel processing can be used
  49915. */
  49916. parallelProcessing: boolean;
  49917. }
  49918. /**
  49919. * Queue used to order the simplification tasks
  49920. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49921. */
  49922. export class SimplificationQueue {
  49923. private _simplificationArray;
  49924. /**
  49925. * Gets a boolean indicating that the process is still running
  49926. */
  49927. running: boolean;
  49928. /**
  49929. * Creates a new queue
  49930. */
  49931. constructor();
  49932. /**
  49933. * Adds a new simplification task
  49934. * @param task defines a task to add
  49935. */
  49936. addTask(task: ISimplificationTask): void;
  49937. /**
  49938. * Execute next task
  49939. */
  49940. executeNext(): void;
  49941. /**
  49942. * Execute a simplification task
  49943. * @param task defines the task to run
  49944. */
  49945. runSimplification(task: ISimplificationTask): void;
  49946. private getSimplifier;
  49947. }
  49948. /**
  49949. * The implemented types of simplification
  49950. * At the moment only Quadratic Error Decimation is implemented
  49951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49952. */
  49953. export enum SimplificationType {
  49954. /** Quadratic error decimation */
  49955. QUADRATIC = 0
  49956. }
  49957. }
  49958. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49959. import { Scene } from "babylonjs/scene";
  49960. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49961. import { ISceneComponent } from "babylonjs/sceneComponent";
  49962. module "babylonjs/scene" {
  49963. interface Scene {
  49964. /** @hidden (Backing field) */
  49965. _simplificationQueue: SimplificationQueue;
  49966. /**
  49967. * Gets or sets the simplification queue attached to the scene
  49968. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49969. */
  49970. simplificationQueue: SimplificationQueue;
  49971. }
  49972. }
  49973. module "babylonjs/Meshes/mesh" {
  49974. interface Mesh {
  49975. /**
  49976. * Simplify the mesh according to the given array of settings.
  49977. * Function will return immediately and will simplify async
  49978. * @param settings a collection of simplification settings
  49979. * @param parallelProcessing should all levels calculate parallel or one after the other
  49980. * @param simplificationType the type of simplification to run
  49981. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49982. * @returns the current mesh
  49983. */
  49984. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49985. }
  49986. }
  49987. /**
  49988. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49989. * created in a scene
  49990. */
  49991. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49992. /**
  49993. * The component name helpfull to identify the component in the list of scene components.
  49994. */
  49995. readonly name: string;
  49996. /**
  49997. * The scene the component belongs to.
  49998. */
  49999. scene: Scene;
  50000. /**
  50001. * Creates a new instance of the component for the given scene
  50002. * @param scene Defines the scene to register the component in
  50003. */
  50004. constructor(scene: Scene);
  50005. /**
  50006. * Registers the component in a given scene
  50007. */
  50008. register(): void;
  50009. /**
  50010. * Rebuilds the elements related to this component in case of
  50011. * context lost for instance.
  50012. */
  50013. rebuild(): void;
  50014. /**
  50015. * Disposes the component and the associated ressources
  50016. */
  50017. dispose(): void;
  50018. private _beforeCameraUpdate;
  50019. }
  50020. }
  50021. declare module "babylonjs/Meshes/Builders/index" {
  50022. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50023. export * from "babylonjs/Meshes/Builders/discBuilder";
  50024. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50025. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50026. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50027. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50028. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50029. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50030. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50031. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50032. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50033. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50034. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50035. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50036. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50037. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50038. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50039. }
  50040. declare module "babylonjs/Meshes/index" {
  50041. export * from "babylonjs/Meshes/abstractMesh";
  50042. export * from "babylonjs/Meshes/buffer";
  50043. export * from "babylonjs/Meshes/Compression/index";
  50044. export * from "babylonjs/Meshes/csg";
  50045. export * from "babylonjs/Meshes/geometry";
  50046. export * from "babylonjs/Meshes/groundMesh";
  50047. export * from "babylonjs/Meshes/instancedMesh";
  50048. export * from "babylonjs/Meshes/linesMesh";
  50049. export * from "babylonjs/Meshes/mesh";
  50050. export * from "babylonjs/Meshes/mesh.vertexData";
  50051. export * from "babylonjs/Meshes/meshBuilder";
  50052. export * from "babylonjs/Meshes/meshSimplification";
  50053. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50054. export * from "babylonjs/Meshes/polygonMesh";
  50055. export * from "babylonjs/Meshes/subMesh";
  50056. export * from "babylonjs/Meshes/transformNode";
  50057. export * from "babylonjs/Meshes/Builders/index";
  50058. }
  50059. declare module "babylonjs/Morph/index" {
  50060. export * from "babylonjs/Morph/morphTarget";
  50061. export * from "babylonjs/Morph/morphTargetManager";
  50062. }
  50063. declare module "babylonjs/Offline/database" {
  50064. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50065. /**
  50066. * Class used to enable access to IndexedDB
  50067. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50068. */
  50069. export class Database implements IOfflineProvider {
  50070. private _callbackManifestChecked;
  50071. private _currentSceneUrl;
  50072. private _db;
  50073. private _enableSceneOffline;
  50074. private _enableTexturesOffline;
  50075. private _manifestVersionFound;
  50076. private _mustUpdateRessources;
  50077. private _hasReachedQuota;
  50078. private _isSupported;
  50079. private _idbFactory;
  50080. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50081. private static IsUASupportingBlobStorage;
  50082. /**
  50083. * Gets a boolean indicating if Database storate is enabled (off by default)
  50084. */
  50085. static IDBStorageEnabled: boolean;
  50086. /**
  50087. * Gets a boolean indicating if scene must be saved in the database
  50088. */
  50089. readonly enableSceneOffline: boolean;
  50090. /**
  50091. * Gets a boolean indicating if textures must be saved in the database
  50092. */
  50093. readonly enableTexturesOffline: boolean;
  50094. /**
  50095. * Creates a new Database
  50096. * @param urlToScene defines the url to load the scene
  50097. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50098. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50099. */
  50100. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50101. private static _ParseURL;
  50102. private static _ReturnFullUrlLocation;
  50103. private _checkManifestFile;
  50104. /**
  50105. * Open the database and make it available
  50106. * @param successCallback defines the callback to call on success
  50107. * @param errorCallback defines the callback to call on error
  50108. */
  50109. open(successCallback: () => void, errorCallback: () => void): void;
  50110. /**
  50111. * Loads an image from the database
  50112. * @param url defines the url to load from
  50113. * @param image defines the target DOM image
  50114. */
  50115. loadImage(url: string, image: HTMLImageElement): void;
  50116. private _loadImageFromDBAsync;
  50117. private _saveImageIntoDBAsync;
  50118. private _checkVersionFromDB;
  50119. private _loadVersionFromDBAsync;
  50120. private _saveVersionIntoDBAsync;
  50121. /**
  50122. * Loads a file from database
  50123. * @param url defines the URL to load from
  50124. * @param sceneLoaded defines a callback to call on success
  50125. * @param progressCallBack defines a callback to call when progress changed
  50126. * @param errorCallback defines a callback to call on error
  50127. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50128. */
  50129. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50130. private _loadFileAsync;
  50131. private _saveFileAsync;
  50132. /**
  50133. * Validates if xhr data is correct
  50134. * @param xhr defines the request to validate
  50135. * @param dataType defines the expected data type
  50136. * @returns true if data is correct
  50137. */
  50138. private static _ValidateXHRData;
  50139. }
  50140. }
  50141. declare module "babylonjs/Offline/index" {
  50142. export * from "babylonjs/Offline/database";
  50143. export * from "babylonjs/Offline/IOfflineProvider";
  50144. }
  50145. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50146. /** @hidden */
  50147. export var gpuUpdateParticlesPixelShader: {
  50148. name: string;
  50149. shader: string;
  50150. };
  50151. }
  50152. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50153. /** @hidden */
  50154. export var gpuUpdateParticlesVertexShader: {
  50155. name: string;
  50156. shader: string;
  50157. };
  50158. }
  50159. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50160. /** @hidden */
  50161. export var clipPlaneFragmentDeclaration2: {
  50162. name: string;
  50163. shader: string;
  50164. };
  50165. }
  50166. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50167. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50168. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50169. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50170. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50171. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50172. /** @hidden */
  50173. export var gpuRenderParticlesPixelShader: {
  50174. name: string;
  50175. shader: string;
  50176. };
  50177. }
  50178. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50179. /** @hidden */
  50180. export var clipPlaneVertexDeclaration2: {
  50181. name: string;
  50182. shader: string;
  50183. };
  50184. }
  50185. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50186. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50187. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50188. /** @hidden */
  50189. export var gpuRenderParticlesVertexShader: {
  50190. name: string;
  50191. shader: string;
  50192. };
  50193. }
  50194. declare module "babylonjs/Particles/gpuParticleSystem" {
  50195. import { Nullable } from "babylonjs/types";
  50196. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50197. import { Observable } from "babylonjs/Misc/observable";
  50198. import { Color4, Color3 } from "babylonjs/Maths/math";
  50199. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50200. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50201. import { Scene, IDisposable } from "babylonjs/scene";
  50202. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50203. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50204. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50205. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50206. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50207. /**
  50208. * This represents a GPU particle system in Babylon
  50209. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50210. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50211. */
  50212. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50213. /**
  50214. * The layer mask we are rendering the particles through.
  50215. */
  50216. layerMask: number;
  50217. private _capacity;
  50218. private _activeCount;
  50219. private _currentActiveCount;
  50220. private _accumulatedCount;
  50221. private _renderEffect;
  50222. private _updateEffect;
  50223. private _buffer0;
  50224. private _buffer1;
  50225. private _spriteBuffer;
  50226. private _updateVAO;
  50227. private _renderVAO;
  50228. private _targetIndex;
  50229. private _sourceBuffer;
  50230. private _targetBuffer;
  50231. private _engine;
  50232. private _currentRenderId;
  50233. private _started;
  50234. private _stopped;
  50235. private _timeDelta;
  50236. private _randomTexture;
  50237. private _randomTexture2;
  50238. private _attributesStrideSize;
  50239. private _updateEffectOptions;
  50240. private _randomTextureSize;
  50241. private _actualFrame;
  50242. private readonly _rawTextureWidth;
  50243. /**
  50244. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50245. */
  50246. static readonly IsSupported: boolean;
  50247. /**
  50248. * An event triggered when the system is disposed.
  50249. */
  50250. onDisposeObservable: Observable<GPUParticleSystem>;
  50251. /**
  50252. * Gets the maximum number of particles active at the same time.
  50253. * @returns The max number of active particles.
  50254. */
  50255. getCapacity(): number;
  50256. /**
  50257. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50258. * to override the particles.
  50259. */
  50260. forceDepthWrite: boolean;
  50261. /**
  50262. * Gets or set the number of active particles
  50263. */
  50264. activeParticleCount: number;
  50265. private _preWarmDone;
  50266. /**
  50267. * Is this system ready to be used/rendered
  50268. * @return true if the system is ready
  50269. */
  50270. isReady(): boolean;
  50271. /**
  50272. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50273. * @returns True if it has been started, otherwise false.
  50274. */
  50275. isStarted(): boolean;
  50276. /**
  50277. * Starts the particle system and begins to emit
  50278. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50279. */
  50280. start(delay?: number): void;
  50281. /**
  50282. * Stops the particle system.
  50283. */
  50284. stop(): void;
  50285. /**
  50286. * Remove all active particles
  50287. */
  50288. reset(): void;
  50289. /**
  50290. * Returns the string "GPUParticleSystem"
  50291. * @returns a string containing the class name
  50292. */
  50293. getClassName(): string;
  50294. private _colorGradientsTexture;
  50295. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50296. /**
  50297. * Adds a new color gradient
  50298. * @param gradient defines the gradient to use (between 0 and 1)
  50299. * @param color1 defines the color to affect to the specified gradient
  50300. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50301. * @returns the current particle system
  50302. */
  50303. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50304. /**
  50305. * Remove a specific color gradient
  50306. * @param gradient defines the gradient to remove
  50307. * @returns the current particle system
  50308. */
  50309. removeColorGradient(gradient: number): GPUParticleSystem;
  50310. private _angularSpeedGradientsTexture;
  50311. private _sizeGradientsTexture;
  50312. private _velocityGradientsTexture;
  50313. private _limitVelocityGradientsTexture;
  50314. private _dragGradientsTexture;
  50315. private _addFactorGradient;
  50316. /**
  50317. * Adds a new size gradient
  50318. * @param gradient defines the gradient to use (between 0 and 1)
  50319. * @param factor defines the size factor to affect to the specified gradient
  50320. * @returns the current particle system
  50321. */
  50322. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50323. /**
  50324. * Remove a specific size gradient
  50325. * @param gradient defines the gradient to remove
  50326. * @returns the current particle system
  50327. */
  50328. removeSizeGradient(gradient: number): GPUParticleSystem;
  50329. /**
  50330. * Adds a new angular speed gradient
  50331. * @param gradient defines the gradient to use (between 0 and 1)
  50332. * @param factor defines the angular speed to affect to the specified gradient
  50333. * @returns the current particle system
  50334. */
  50335. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50336. /**
  50337. * Remove a specific angular speed gradient
  50338. * @param gradient defines the gradient to remove
  50339. * @returns the current particle system
  50340. */
  50341. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50342. /**
  50343. * Adds a new velocity gradient
  50344. * @param gradient defines the gradient to use (between 0 and 1)
  50345. * @param factor defines the velocity to affect to the specified gradient
  50346. * @returns the current particle system
  50347. */
  50348. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50349. /**
  50350. * Remove a specific velocity gradient
  50351. * @param gradient defines the gradient to remove
  50352. * @returns the current particle system
  50353. */
  50354. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50355. /**
  50356. * Adds a new limit velocity gradient
  50357. * @param gradient defines the gradient to use (between 0 and 1)
  50358. * @param factor defines the limit velocity value to affect to the specified gradient
  50359. * @returns the current particle system
  50360. */
  50361. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50362. /**
  50363. * Remove a specific limit velocity gradient
  50364. * @param gradient defines the gradient to remove
  50365. * @returns the current particle system
  50366. */
  50367. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50368. /**
  50369. * Adds a new drag gradient
  50370. * @param gradient defines the gradient to use (between 0 and 1)
  50371. * @param factor defines the drag value to affect to the specified gradient
  50372. * @returns the current particle system
  50373. */
  50374. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50375. /**
  50376. * Remove a specific drag gradient
  50377. * @param gradient defines the gradient to remove
  50378. * @returns the current particle system
  50379. */
  50380. removeDragGradient(gradient: number): GPUParticleSystem;
  50381. /**
  50382. * Not supported by GPUParticleSystem
  50383. * @param gradient defines the gradient to use (between 0 and 1)
  50384. * @param factor defines the emit rate value to affect to the specified gradient
  50385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50386. * @returns the current particle system
  50387. */
  50388. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50389. /**
  50390. * Not supported by GPUParticleSystem
  50391. * @param gradient defines the gradient to remove
  50392. * @returns the current particle system
  50393. */
  50394. removeEmitRateGradient(gradient: number): IParticleSystem;
  50395. /**
  50396. * Not supported by GPUParticleSystem
  50397. * @param gradient defines the gradient to use (between 0 and 1)
  50398. * @param factor defines the start size value to affect to the specified gradient
  50399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50400. * @returns the current particle system
  50401. */
  50402. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50403. /**
  50404. * Not supported by GPUParticleSystem
  50405. * @param gradient defines the gradient to remove
  50406. * @returns the current particle system
  50407. */
  50408. removeStartSizeGradient(gradient: number): IParticleSystem;
  50409. /**
  50410. * Not supported by GPUParticleSystem
  50411. * @param gradient defines the gradient to use (between 0 and 1)
  50412. * @param min defines the color remap minimal range
  50413. * @param max defines the color remap maximal range
  50414. * @returns the current particle system
  50415. */
  50416. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50417. /**
  50418. * Not supported by GPUParticleSystem
  50419. * @param gradient defines the gradient to remove
  50420. * @returns the current particle system
  50421. */
  50422. removeColorRemapGradient(): IParticleSystem;
  50423. /**
  50424. * Not supported by GPUParticleSystem
  50425. * @param gradient defines the gradient to use (between 0 and 1)
  50426. * @param min defines the alpha remap minimal range
  50427. * @param max defines the alpha remap maximal range
  50428. * @returns the current particle system
  50429. */
  50430. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50431. /**
  50432. * Not supported by GPUParticleSystem
  50433. * @param gradient defines the gradient to remove
  50434. * @returns the current particle system
  50435. */
  50436. removeAlphaRemapGradient(): IParticleSystem;
  50437. /**
  50438. * Not supported by GPUParticleSystem
  50439. * @param gradient defines the gradient to use (between 0 and 1)
  50440. * @param color defines the color to affect to the specified gradient
  50441. * @returns the current particle system
  50442. */
  50443. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50444. /**
  50445. * Not supported by GPUParticleSystem
  50446. * @param gradient defines the gradient to remove
  50447. * @returns the current particle system
  50448. */
  50449. removeRampGradient(): IParticleSystem;
  50450. /**
  50451. * Not supported by GPUParticleSystem
  50452. * @returns the list of ramp gradients
  50453. */
  50454. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50455. /**
  50456. * Not supported by GPUParticleSystem
  50457. * Gets or sets a boolean indicating that ramp gradients must be used
  50458. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50459. */
  50460. useRampGradients: boolean;
  50461. /**
  50462. * Not supported by GPUParticleSystem
  50463. * @param gradient defines the gradient to use (between 0 and 1)
  50464. * @param factor defines the life time factor to affect to the specified gradient
  50465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50466. * @returns the current particle system
  50467. */
  50468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50469. /**
  50470. * Not supported by GPUParticleSystem
  50471. * @param gradient defines the gradient to remove
  50472. * @returns the current particle system
  50473. */
  50474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50475. /**
  50476. * Instantiates a GPU particle system.
  50477. * 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.
  50478. * @param name The name of the particle system
  50479. * @param options The options used to create the system
  50480. * @param scene The scene the particle system belongs to
  50481. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50482. */
  50483. constructor(name: string, options: Partial<{
  50484. capacity: number;
  50485. randomTextureSize: number;
  50486. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50487. protected _reset(): void;
  50488. private _createUpdateVAO;
  50489. private _createRenderVAO;
  50490. private _initialize;
  50491. /** @hidden */
  50492. _recreateUpdateEffect(): void;
  50493. /** @hidden */
  50494. _recreateRenderEffect(): void;
  50495. /**
  50496. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50497. * @param preWarm defines if we are in the pre-warmimg phase
  50498. */
  50499. animate(preWarm?: boolean): void;
  50500. private _createFactorGradientTexture;
  50501. private _createSizeGradientTexture;
  50502. private _createAngularSpeedGradientTexture;
  50503. private _createVelocityGradientTexture;
  50504. private _createLimitVelocityGradientTexture;
  50505. private _createDragGradientTexture;
  50506. private _createColorGradientTexture;
  50507. /**
  50508. * Renders the particle system in its current state
  50509. * @param preWarm defines if the system should only update the particles but not render them
  50510. * @returns the current number of particles
  50511. */
  50512. render(preWarm?: boolean): number;
  50513. /**
  50514. * Rebuilds the particle system
  50515. */
  50516. rebuild(): void;
  50517. private _releaseBuffers;
  50518. private _releaseVAOs;
  50519. /**
  50520. * Disposes the particle system and free the associated resources
  50521. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50522. */
  50523. dispose(disposeTexture?: boolean): void;
  50524. /**
  50525. * Clones the particle system.
  50526. * @param name The name of the cloned object
  50527. * @param newEmitter The new emitter to use
  50528. * @returns the cloned particle system
  50529. */
  50530. clone(name: string, newEmitter: any): GPUParticleSystem;
  50531. /**
  50532. * Serializes the particle system to a JSON object.
  50533. * @returns the JSON object
  50534. */
  50535. serialize(): any;
  50536. /**
  50537. * Parses a JSON object to create a GPU particle system.
  50538. * @param parsedParticleSystem The JSON object to parse
  50539. * @param scene The scene to create the particle system in
  50540. * @param rootUrl The root url to use to load external dependencies like texture
  50541. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50542. * @returns the parsed GPU particle system
  50543. */
  50544. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50545. }
  50546. }
  50547. declare module "babylonjs/Particles/particleSystemSet" {
  50548. import { Nullable } from "babylonjs/types";
  50549. import { Color3 } from "babylonjs/Maths/math";
  50550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50552. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50553. import { Scene, IDisposable } from "babylonjs/scene";
  50554. /**
  50555. * Represents a set of particle systems working together to create a specific effect
  50556. */
  50557. export class ParticleSystemSet implements IDisposable {
  50558. private _emitterCreationOptions;
  50559. private _emitterNode;
  50560. /**
  50561. * Gets the particle system list
  50562. */
  50563. systems: IParticleSystem[];
  50564. /**
  50565. * Gets the emitter node used with this set
  50566. */
  50567. readonly emitterNode: Nullable<TransformNode>;
  50568. /**
  50569. * Creates a new emitter mesh as a sphere
  50570. * @param options defines the options used to create the sphere
  50571. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50572. * @param scene defines the hosting scene
  50573. */
  50574. setEmitterAsSphere(options: {
  50575. diameter: number;
  50576. segments: number;
  50577. color: Color3;
  50578. }, renderingGroupId: number, scene: Scene): void;
  50579. /**
  50580. * Starts all particle systems of the set
  50581. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50582. */
  50583. start(emitter?: AbstractMesh): void;
  50584. /**
  50585. * Release all associated resources
  50586. */
  50587. dispose(): void;
  50588. /**
  50589. * Serialize the set into a JSON compatible object
  50590. * @returns a JSON compatible representation of the set
  50591. */
  50592. serialize(): any;
  50593. /**
  50594. * Parse a new ParticleSystemSet from a serialized source
  50595. * @param data defines a JSON compatible representation of the set
  50596. * @param scene defines the hosting scene
  50597. * @param gpu defines if we want GPU particles or CPU particles
  50598. * @returns a new ParticleSystemSet
  50599. */
  50600. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50601. }
  50602. }
  50603. declare module "babylonjs/Particles/particleHelper" {
  50604. import { Nullable } from "babylonjs/types";
  50605. import { Scene } from "babylonjs/scene";
  50606. import { Vector3 } from "babylonjs/Maths/math";
  50607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50608. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50609. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50610. /**
  50611. * This class is made for on one-liner static method to help creating particle system set.
  50612. */
  50613. export class ParticleHelper {
  50614. /**
  50615. * Gets or sets base Assets URL
  50616. */
  50617. static BaseAssetsUrl: string;
  50618. /**
  50619. * Create a default particle system that you can tweak
  50620. * @param emitter defines the emitter to use
  50621. * @param capacity defines the system capacity (default is 500 particles)
  50622. * @param scene defines the hosting scene
  50623. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50624. * @returns the new Particle system
  50625. */
  50626. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50627. /**
  50628. * This is the main static method (one-liner) of this helper to create different particle systems
  50629. * @param type This string represents the type to the particle system to create
  50630. * @param scene The scene where the particle system should live
  50631. * @param gpu If the system will use gpu
  50632. * @returns the ParticleSystemSet created
  50633. */
  50634. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50635. /**
  50636. * Static function used to export a particle system to a ParticleSystemSet variable.
  50637. * Please note that the emitter shape is not exported
  50638. * @param systems defines the particle systems to export
  50639. * @returns the created particle system set
  50640. */
  50641. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50642. }
  50643. }
  50644. declare module "babylonjs/Particles/particleSystemComponent" {
  50645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50646. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50647. import "babylonjs/Shaders/particles.vertex";
  50648. module "babylonjs/Engines/engine" {
  50649. interface Engine {
  50650. /**
  50651. * Create an effect to use with particle systems.
  50652. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50653. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50654. * @param uniformsNames defines a list of attribute names
  50655. * @param samplers defines an array of string used to represent textures
  50656. * @param defines defines the string containing the defines to use to compile the shaders
  50657. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50658. * @param onCompiled defines a function to call when the effect creation is successful
  50659. * @param onError defines a function to call when the effect creation has failed
  50660. * @returns the new Effect
  50661. */
  50662. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50663. }
  50664. }
  50665. module "babylonjs/Meshes/mesh" {
  50666. interface Mesh {
  50667. /**
  50668. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50669. * @returns an array of IParticleSystem
  50670. */
  50671. getEmittedParticleSystems(): IParticleSystem[];
  50672. /**
  50673. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50674. * @returns an array of IParticleSystem
  50675. */
  50676. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50677. }
  50678. }
  50679. /**
  50680. * @hidden
  50681. */
  50682. export var _IDoNeedToBeInTheBuild: number;
  50683. }
  50684. declare module "babylonjs/Particles/index" {
  50685. export * from "babylonjs/Particles/baseParticleSystem";
  50686. export * from "babylonjs/Particles/EmitterTypes/index";
  50687. export * from "babylonjs/Particles/gpuParticleSystem";
  50688. export * from "babylonjs/Particles/IParticleSystem";
  50689. export * from "babylonjs/Particles/particle";
  50690. export * from "babylonjs/Particles/particleHelper";
  50691. export * from "babylonjs/Particles/particleSystem";
  50692. export * from "babylonjs/Particles/particleSystemComponent";
  50693. export * from "babylonjs/Particles/particleSystemSet";
  50694. export * from "babylonjs/Particles/solidParticle";
  50695. export * from "babylonjs/Particles/solidParticleSystem";
  50696. export * from "babylonjs/Particles/subEmitter";
  50697. }
  50698. declare module "babylonjs/Physics/physicsEngineComponent" {
  50699. import { Nullable } from "babylonjs/types";
  50700. import { Observable, Observer } from "babylonjs/Misc/observable";
  50701. import { Vector3 } from "babylonjs/Maths/math";
  50702. import { Mesh } from "babylonjs/Meshes/mesh";
  50703. import { ISceneComponent } from "babylonjs/sceneComponent";
  50704. import { Scene } from "babylonjs/scene";
  50705. import { Node } from "babylonjs/node";
  50706. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50707. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50708. module "babylonjs/scene" {
  50709. interface Scene {
  50710. /** @hidden (Backing field) */
  50711. _physicsEngine: Nullable<IPhysicsEngine>;
  50712. /**
  50713. * Gets the current physics engine
  50714. * @returns a IPhysicsEngine or null if none attached
  50715. */
  50716. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50717. /**
  50718. * Enables physics to the current scene
  50719. * @param gravity defines the scene's gravity for the physics engine
  50720. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50721. * @return a boolean indicating if the physics engine was initialized
  50722. */
  50723. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50724. /**
  50725. * Disables and disposes the physics engine associated with the scene
  50726. */
  50727. disablePhysicsEngine(): void;
  50728. /**
  50729. * Gets a boolean indicating if there is an active physics engine
  50730. * @returns a boolean indicating if there is an active physics engine
  50731. */
  50732. isPhysicsEnabled(): boolean;
  50733. /**
  50734. * Deletes a physics compound impostor
  50735. * @param compound defines the compound to delete
  50736. */
  50737. deleteCompoundImpostor(compound: any): void;
  50738. /**
  50739. * An event triggered when physic simulation is about to be run
  50740. */
  50741. onBeforePhysicsObservable: Observable<Scene>;
  50742. /**
  50743. * An event triggered when physic simulation has been done
  50744. */
  50745. onAfterPhysicsObservable: Observable<Scene>;
  50746. }
  50747. }
  50748. module "babylonjs/Meshes/abstractMesh" {
  50749. interface AbstractMesh {
  50750. /** @hidden */
  50751. _physicsImpostor: Nullable<PhysicsImpostor>;
  50752. /**
  50753. * Gets or sets impostor used for physic simulation
  50754. * @see http://doc.babylonjs.com/features/physics_engine
  50755. */
  50756. physicsImpostor: Nullable<PhysicsImpostor>;
  50757. /**
  50758. * Gets the current physics impostor
  50759. * @see http://doc.babylonjs.com/features/physics_engine
  50760. * @returns a physics impostor or null
  50761. */
  50762. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50763. /** Apply a physic impulse to the mesh
  50764. * @param force defines the force to apply
  50765. * @param contactPoint defines where to apply the force
  50766. * @returns the current mesh
  50767. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50768. */
  50769. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50770. /**
  50771. * Creates a physic joint between two meshes
  50772. * @param otherMesh defines the other mesh to use
  50773. * @param pivot1 defines the pivot to use on this mesh
  50774. * @param pivot2 defines the pivot to use on the other mesh
  50775. * @param options defines additional options (can be plugin dependent)
  50776. * @returns the current mesh
  50777. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50778. */
  50779. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50780. /** @hidden */
  50781. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50782. }
  50783. }
  50784. /**
  50785. * Defines the physics engine scene component responsible to manage a physics engine
  50786. */
  50787. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50788. /**
  50789. * The component name helpful to identify the component in the list of scene components.
  50790. */
  50791. readonly name: string;
  50792. /**
  50793. * The scene the component belongs to.
  50794. */
  50795. scene: Scene;
  50796. /**
  50797. * Creates a new instance of the component for the given scene
  50798. * @param scene Defines the scene to register the component in
  50799. */
  50800. constructor(scene: Scene);
  50801. /**
  50802. * Registers the component in a given scene
  50803. */
  50804. register(): void;
  50805. /**
  50806. * Rebuilds the elements related to this component in case of
  50807. * context lost for instance.
  50808. */
  50809. rebuild(): void;
  50810. /**
  50811. * Disposes the component and the associated ressources
  50812. */
  50813. dispose(): void;
  50814. }
  50815. }
  50816. declare module "babylonjs/Physics/physicsHelper" {
  50817. import { Nullable } from "babylonjs/types";
  50818. import { Vector3 } from "babylonjs/Maths/math";
  50819. import { Mesh } from "babylonjs/Meshes/mesh";
  50820. import { Ray } from "babylonjs/Culling/ray";
  50821. import { Scene } from "babylonjs/scene";
  50822. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50823. /**
  50824. * A helper for physics simulations
  50825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50826. */
  50827. export class PhysicsHelper {
  50828. private _scene;
  50829. private _physicsEngine;
  50830. /**
  50831. * Initializes the Physics helper
  50832. * @param scene Babylon.js scene
  50833. */
  50834. constructor(scene: Scene);
  50835. /**
  50836. * Applies a radial explosion impulse
  50837. * @param origin the origin of the explosion
  50838. * @param radius the explosion radius
  50839. * @param strength the explosion strength
  50840. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50841. * @returns A physics radial explosion event, or null
  50842. */
  50843. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50844. /**
  50845. * Applies a radial explosion force
  50846. * @param origin the origin of the explosion
  50847. * @param radius the explosion radius
  50848. * @param strength the explosion strength
  50849. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50850. * @returns A physics radial explosion event, or null
  50851. */
  50852. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50853. /**
  50854. * Creates a gravitational field
  50855. * @param origin the origin of the explosion
  50856. * @param radius the explosion radius
  50857. * @param strength the explosion strength
  50858. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50859. * @returns A physics gravitational field event, or null
  50860. */
  50861. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50862. /**
  50863. * Creates a physics updraft event
  50864. * @param origin the origin of the updraft
  50865. * @param radius the radius of the updraft
  50866. * @param strength the strength of the updraft
  50867. * @param height the height of the updraft
  50868. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50869. * @returns A physics updraft event, or null
  50870. */
  50871. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50872. /**
  50873. * Creates a physics vortex event
  50874. * @param origin the of the vortex
  50875. * @param radius the radius of the vortex
  50876. * @param strength the strength of the vortex
  50877. * @param height the height of the vortex
  50878. * @returns a Physics vortex event, or null
  50879. * A physics vortex event or null
  50880. */
  50881. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50882. }
  50883. /**
  50884. * Represents a physics radial explosion event
  50885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50886. */
  50887. export class PhysicsRadialExplosionEvent {
  50888. private _scene;
  50889. private _sphere;
  50890. private _sphereOptions;
  50891. private _rays;
  50892. private _dataFetched;
  50893. /**
  50894. * Initializes a radial explosioin event
  50895. * @param scene BabylonJS scene
  50896. */
  50897. constructor(scene: Scene);
  50898. /**
  50899. * Returns the data related to the radial explosion event (sphere & rays).
  50900. * @returns The radial explosion event data
  50901. */
  50902. getData(): PhysicsRadialExplosionEventData;
  50903. /**
  50904. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50905. * @param impostor A physics imposter
  50906. * @param origin the origin of the explosion
  50907. * @param radius the explosion radius
  50908. * @param strength the explosion strength
  50909. * @param falloff possible options: Constant & Linear
  50910. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50911. */
  50912. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50913. /**
  50914. * Disposes the sphere.
  50915. * @param force Specifies if the sphere should be disposed by force
  50916. */
  50917. dispose(force?: boolean): void;
  50918. /*** Helpers ***/
  50919. private _prepareSphere;
  50920. private _intersectsWithSphere;
  50921. }
  50922. /**
  50923. * Represents a gravitational field event
  50924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50925. */
  50926. export class PhysicsGravitationalFieldEvent {
  50927. private _physicsHelper;
  50928. private _scene;
  50929. private _origin;
  50930. private _radius;
  50931. private _strength;
  50932. private _falloff;
  50933. private _tickCallback;
  50934. private _sphere;
  50935. private _dataFetched;
  50936. /**
  50937. * Initializes the physics gravitational field event
  50938. * @param physicsHelper A physics helper
  50939. * @param scene BabylonJS scene
  50940. * @param origin The origin position of the gravitational field event
  50941. * @param radius The radius of the gravitational field event
  50942. * @param strength The strength of the gravitational field event
  50943. * @param falloff The falloff for the gravitational field event
  50944. */
  50945. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50946. /**
  50947. * Returns the data related to the gravitational field event (sphere).
  50948. * @returns A gravitational field event
  50949. */
  50950. getData(): PhysicsGravitationalFieldEventData;
  50951. /**
  50952. * Enables the gravitational field.
  50953. */
  50954. enable(): void;
  50955. /**
  50956. * Disables the gravitational field.
  50957. */
  50958. disable(): void;
  50959. /**
  50960. * Disposes the sphere.
  50961. * @param force The force to dispose from the gravitational field event
  50962. */
  50963. dispose(force?: boolean): void;
  50964. private _tick;
  50965. }
  50966. /**
  50967. * Represents a physics updraft event
  50968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50969. */
  50970. export class PhysicsUpdraftEvent {
  50971. private _scene;
  50972. private _origin;
  50973. private _radius;
  50974. private _strength;
  50975. private _height;
  50976. private _updraftMode;
  50977. private _physicsEngine;
  50978. private _originTop;
  50979. private _originDirection;
  50980. private _tickCallback;
  50981. private _cylinder;
  50982. private _cylinderPosition;
  50983. private _dataFetched;
  50984. /**
  50985. * Initializes the physics updraft event
  50986. * @param _scene BabylonJS scene
  50987. * @param _origin The origin position of the updraft
  50988. * @param _radius The radius of the updraft
  50989. * @param _strength The strength of the updraft
  50990. * @param _height The height of the updraft
  50991. * @param _updraftMode The mode of the updraft
  50992. */
  50993. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50994. /**
  50995. * Returns the data related to the updraft event (cylinder).
  50996. * @returns A physics updraft event
  50997. */
  50998. getData(): PhysicsUpdraftEventData;
  50999. /**
  51000. * Enables the updraft.
  51001. */
  51002. enable(): void;
  51003. /**
  51004. * Disables the cortex.
  51005. */
  51006. disable(): void;
  51007. /**
  51008. * Disposes the sphere.
  51009. * @param force Specifies if the updraft should be disposed by force
  51010. */
  51011. dispose(force?: boolean): void;
  51012. private getImpostorForceAndContactPoint;
  51013. private _tick;
  51014. /*** Helpers ***/
  51015. private _prepareCylinder;
  51016. private _intersectsWithCylinder;
  51017. }
  51018. /**
  51019. * Represents a physics vortex event
  51020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51021. */
  51022. export class PhysicsVortexEvent {
  51023. private _scene;
  51024. private _origin;
  51025. private _radius;
  51026. private _strength;
  51027. private _height;
  51028. private _physicsEngine;
  51029. private _originTop;
  51030. private _centripetalForceThreshold;
  51031. private _updraftMultiplier;
  51032. private _tickCallback;
  51033. private _cylinder;
  51034. private _cylinderPosition;
  51035. private _dataFetched;
  51036. /**
  51037. * Initializes the physics vortex event
  51038. * @param _scene The BabylonJS scene
  51039. * @param _origin The origin position of the vortex
  51040. * @param _radius The radius of the vortex
  51041. * @param _strength The strength of the vortex
  51042. * @param _height The height of the vortex
  51043. */
  51044. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51045. /**
  51046. * Returns the data related to the vortex event (cylinder).
  51047. * @returns The physics vortex event data
  51048. */
  51049. getData(): PhysicsVortexEventData;
  51050. /**
  51051. * Enables the vortex.
  51052. */
  51053. enable(): void;
  51054. /**
  51055. * Disables the cortex.
  51056. */
  51057. disable(): void;
  51058. /**
  51059. * Disposes the sphere.
  51060. * @param force
  51061. */
  51062. dispose(force?: boolean): void;
  51063. private getImpostorForceAndContactPoint;
  51064. private _tick;
  51065. /*** Helpers ***/
  51066. private _prepareCylinder;
  51067. private _intersectsWithCylinder;
  51068. }
  51069. /**
  51070. * The strenght of the force in correspondence to the distance of the affected object
  51071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51072. */
  51073. export enum PhysicsRadialImpulseFalloff {
  51074. /** Defines that impulse is constant in strength across it's whole radius */
  51075. Constant = 0,
  51076. /** DEfines that impulse gets weaker if it's further from the origin */
  51077. Linear = 1
  51078. }
  51079. /**
  51080. * The strength of the force in correspondence to the distance of the affected object
  51081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51082. */
  51083. export enum PhysicsUpdraftMode {
  51084. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51085. Center = 0,
  51086. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51087. Perpendicular = 1
  51088. }
  51089. /**
  51090. * Interface for a physics force and contact point
  51091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51092. */
  51093. export interface PhysicsForceAndContactPoint {
  51094. /**
  51095. * The force applied at the contact point
  51096. */
  51097. force: Vector3;
  51098. /**
  51099. * The contact point
  51100. */
  51101. contactPoint: Vector3;
  51102. }
  51103. /**
  51104. * Interface for radial explosion event data
  51105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51106. */
  51107. export interface PhysicsRadialExplosionEventData {
  51108. /**
  51109. * A sphere used for the radial explosion event
  51110. */
  51111. sphere: Mesh;
  51112. /**
  51113. * An array of rays for the radial explosion event
  51114. */
  51115. rays: Array<Ray>;
  51116. }
  51117. /**
  51118. * Interface for gravitational field event data
  51119. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51120. */
  51121. export interface PhysicsGravitationalFieldEventData {
  51122. /**
  51123. * A sphere mesh used for the gravitational field event
  51124. */
  51125. sphere: Mesh;
  51126. }
  51127. /**
  51128. * Interface for updraft event data
  51129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51130. */
  51131. export interface PhysicsUpdraftEventData {
  51132. /**
  51133. * A cylinder used for the updraft event
  51134. */
  51135. cylinder: Mesh;
  51136. }
  51137. /**
  51138. * Interface for vortex event data
  51139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51140. */
  51141. export interface PhysicsVortexEventData {
  51142. /**
  51143. * A cylinder used for the vortex event
  51144. */
  51145. cylinder: Mesh;
  51146. }
  51147. }
  51148. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51149. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51150. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51151. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51152. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51153. import { Nullable } from "babylonjs/types";
  51154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51155. /**
  51156. * AmmoJS Physics plugin
  51157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51158. * @see https://github.com/kripken/ammo.js/
  51159. */
  51160. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51161. private _useDeltaForWorldStep;
  51162. /**
  51163. * Reference to the Ammo library
  51164. */
  51165. bjsAMMO: any;
  51166. /**
  51167. * Created ammoJS world which physics bodies are added to
  51168. */
  51169. world: any;
  51170. /**
  51171. * Name of the plugin
  51172. */
  51173. name: string;
  51174. private _timeStep;
  51175. private _fixedTimeStep;
  51176. private _maxSteps;
  51177. private _tmpQuaternion;
  51178. private _tmpAmmoTransform;
  51179. private _tmpAmmoQuaternion;
  51180. private _tmpAmmoConcreteContactResultCallback;
  51181. private _collisionConfiguration;
  51182. private _dispatcher;
  51183. private _overlappingPairCache;
  51184. private _solver;
  51185. private _tmpAmmoVectorA;
  51186. private _tmpAmmoVectorB;
  51187. private _tmpAmmoVectorC;
  51188. private _tmpContactCallbackResult;
  51189. private static readonly DISABLE_COLLISION_FLAG;
  51190. private static readonly KINEMATIC_FLAG;
  51191. private static readonly DISABLE_DEACTIVATION_FLAG;
  51192. /**
  51193. * Initializes the ammoJS plugin
  51194. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51195. * @param ammoInjection can be used to inject your own ammo reference
  51196. */
  51197. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51198. /**
  51199. * Sets the gravity of the physics world (m/(s^2))
  51200. * @param gravity Gravity to set
  51201. */
  51202. setGravity(gravity: Vector3): void;
  51203. /**
  51204. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51205. * @param timeStep timestep to use in seconds
  51206. */
  51207. setTimeStep(timeStep: number): void;
  51208. /**
  51209. * 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)
  51210. * @param fixedTimeStep fixedTimeStep to use in seconds
  51211. */
  51212. setFixedTimeStep(fixedTimeStep: number): void;
  51213. /**
  51214. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51215. * @param maxSteps the maximum number of steps by the physics engine per frame
  51216. */
  51217. setMaxSteps(maxSteps: number): void;
  51218. /**
  51219. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51220. * @returns the current timestep in seconds
  51221. */
  51222. getTimeStep(): number;
  51223. private _isImpostorInContact;
  51224. private _isImpostorPairInContact;
  51225. private _stepSimulation;
  51226. /**
  51227. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51228. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51229. * After the step the babylon meshes are set to the position of the physics imposters
  51230. * @param delta amount of time to step forward
  51231. * @param impostors array of imposters to update before/after the step
  51232. */
  51233. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51234. private _tmpVector;
  51235. private _tmpMatrix;
  51236. /**
  51237. * Applies an implulse on the imposter
  51238. * @param impostor imposter to apply impulse
  51239. * @param force amount of force to be applied to the imposter
  51240. * @param contactPoint the location to apply the impulse on the imposter
  51241. */
  51242. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51243. /**
  51244. * Applies a force on the imposter
  51245. * @param impostor imposter to apply force
  51246. * @param force amount of force to be applied to the imposter
  51247. * @param contactPoint the location to apply the force on the imposter
  51248. */
  51249. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51250. /**
  51251. * Creates a physics body using the plugin
  51252. * @param impostor the imposter to create the physics body on
  51253. */
  51254. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51255. /**
  51256. * Removes the physics body from the imposter and disposes of the body's memory
  51257. * @param impostor imposter to remove the physics body from
  51258. */
  51259. removePhysicsBody(impostor: PhysicsImpostor): void;
  51260. /**
  51261. * Generates a joint
  51262. * @param impostorJoint the imposter joint to create the joint with
  51263. */
  51264. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51265. /**
  51266. * Removes a joint
  51267. * @param impostorJoint the imposter joint to remove the joint from
  51268. */
  51269. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51270. private _addMeshVerts;
  51271. private _createShape;
  51272. /**
  51273. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51274. * @param impostor imposter containing the physics body and babylon object
  51275. */
  51276. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51277. /**
  51278. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51279. * @param impostor imposter containing the physics body and babylon object
  51280. * @param newPosition new position
  51281. * @param newRotation new rotation
  51282. */
  51283. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51284. /**
  51285. * If this plugin is supported
  51286. * @returns true if its supported
  51287. */
  51288. isSupported(): boolean;
  51289. /**
  51290. * Sets the linear velocity of the physics body
  51291. * @param impostor imposter to set the velocity on
  51292. * @param velocity velocity to set
  51293. */
  51294. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51295. /**
  51296. * Sets the angular velocity of the physics body
  51297. * @param impostor imposter to set the velocity on
  51298. * @param velocity velocity to set
  51299. */
  51300. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51301. /**
  51302. * gets the linear velocity
  51303. * @param impostor imposter to get linear velocity from
  51304. * @returns linear velocity
  51305. */
  51306. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51307. /**
  51308. * gets the angular velocity
  51309. * @param impostor imposter to get angular velocity from
  51310. * @returns angular velocity
  51311. */
  51312. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51313. /**
  51314. * Sets the mass of physics body
  51315. * @param impostor imposter to set the mass on
  51316. * @param mass mass to set
  51317. */
  51318. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51319. /**
  51320. * Gets the mass of the physics body
  51321. * @param impostor imposter to get the mass from
  51322. * @returns mass
  51323. */
  51324. getBodyMass(impostor: PhysicsImpostor): number;
  51325. /**
  51326. * Gets friction of the impostor
  51327. * @param impostor impostor to get friction from
  51328. * @returns friction value
  51329. */
  51330. getBodyFriction(impostor: PhysicsImpostor): number;
  51331. /**
  51332. * Sets friction of the impostor
  51333. * @param impostor impostor to set friction on
  51334. * @param friction friction value
  51335. */
  51336. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51337. /**
  51338. * Gets restitution of the impostor
  51339. * @param impostor impostor to get restitution from
  51340. * @returns restitution value
  51341. */
  51342. getBodyRestitution(impostor: PhysicsImpostor): number;
  51343. /**
  51344. * Sets resitution of the impostor
  51345. * @param impostor impostor to set resitution on
  51346. * @param restitution resitution value
  51347. */
  51348. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51349. /**
  51350. * Sleeps the physics body and stops it from being active
  51351. * @param impostor impostor to sleep
  51352. */
  51353. sleepBody(impostor: PhysicsImpostor): void;
  51354. /**
  51355. * Activates the physics body
  51356. * @param impostor impostor to activate
  51357. */
  51358. wakeUpBody(impostor: PhysicsImpostor): void;
  51359. /**
  51360. * Updates the distance parameters of the joint
  51361. * @param joint joint to update
  51362. * @param maxDistance maximum distance of the joint
  51363. * @param minDistance minimum distance of the joint
  51364. */
  51365. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51366. /**
  51367. * Sets a motor on the joint
  51368. * @param joint joint to set motor on
  51369. * @param speed speed of the motor
  51370. * @param maxForce maximum force of the motor
  51371. * @param motorIndex index of the motor
  51372. */
  51373. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51374. /**
  51375. * Sets the motors limit
  51376. * @param joint joint to set limit on
  51377. * @param upperLimit upper limit
  51378. * @param lowerLimit lower limit
  51379. */
  51380. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51381. /**
  51382. * Syncs the position and rotation of a mesh with the impostor
  51383. * @param mesh mesh to sync
  51384. * @param impostor impostor to update the mesh with
  51385. */
  51386. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51387. /**
  51388. * Gets the radius of the impostor
  51389. * @param impostor impostor to get radius from
  51390. * @returns the radius
  51391. */
  51392. getRadius(impostor: PhysicsImpostor): number;
  51393. /**
  51394. * Gets the box size of the impostor
  51395. * @param impostor impostor to get box size from
  51396. * @param result the resulting box size
  51397. */
  51398. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51399. /**
  51400. * Disposes of the impostor
  51401. */
  51402. dispose(): void;
  51403. }
  51404. }
  51405. declare module "babylonjs/Physics/Plugins/index" {
  51406. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51407. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51408. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51409. }
  51410. declare module "babylonjs/Physics/index" {
  51411. export * from "babylonjs/Physics/IPhysicsEngine";
  51412. export * from "babylonjs/Physics/physicsEngine";
  51413. export * from "babylonjs/Physics/physicsEngineComponent";
  51414. export * from "babylonjs/Physics/physicsHelper";
  51415. export * from "babylonjs/Physics/physicsImpostor";
  51416. export * from "babylonjs/Physics/physicsJoint";
  51417. export * from "babylonjs/Physics/Plugins/index";
  51418. }
  51419. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51420. /** @hidden */
  51421. export var blackAndWhitePixelShader: {
  51422. name: string;
  51423. shader: string;
  51424. };
  51425. }
  51426. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51428. import { Camera } from "babylonjs/Cameras/camera";
  51429. import { Engine } from "babylonjs/Engines/engine";
  51430. import "babylonjs/Shaders/blackAndWhite.fragment";
  51431. /**
  51432. * Post process used to render in black and white
  51433. */
  51434. export class BlackAndWhitePostProcess extends PostProcess {
  51435. /**
  51436. * Linear about to convert he result to black and white (default: 1)
  51437. */
  51438. degree: number;
  51439. /**
  51440. * Creates a black and white post process
  51441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51442. * @param name The name of the effect.
  51443. * @param options The required width/height ratio to downsize to before computing the render pass.
  51444. * @param camera The camera to apply the render pass to.
  51445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51446. * @param engine The engine which the post process will be applied. (default: current engine)
  51447. * @param reusable If the post process can be reused on the same frame. (default: false)
  51448. */
  51449. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51450. }
  51451. }
  51452. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51453. import { Nullable } from "babylonjs/types";
  51454. import { Camera } from "babylonjs/Cameras/camera";
  51455. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51456. import { Engine } from "babylonjs/Engines/engine";
  51457. /**
  51458. * This represents a set of one or more post processes in Babylon.
  51459. * A post process can be used to apply a shader to a texture after it is rendered.
  51460. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51461. */
  51462. export class PostProcessRenderEffect {
  51463. private _postProcesses;
  51464. private _getPostProcesses;
  51465. private _singleInstance;
  51466. private _cameras;
  51467. private _indicesForCamera;
  51468. /**
  51469. * Name of the effect
  51470. * @hidden
  51471. */
  51472. _name: string;
  51473. /**
  51474. * Instantiates a post process render effect.
  51475. * A post process can be used to apply a shader to a texture after it is rendered.
  51476. * @param engine The engine the effect is tied to
  51477. * @param name The name of the effect
  51478. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51479. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51480. */
  51481. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51482. /**
  51483. * Checks if all the post processes in the effect are supported.
  51484. */
  51485. readonly isSupported: boolean;
  51486. /**
  51487. * Updates the current state of the effect
  51488. * @hidden
  51489. */
  51490. _update(): void;
  51491. /**
  51492. * Attaches the effect on cameras
  51493. * @param cameras The camera to attach to.
  51494. * @hidden
  51495. */
  51496. _attachCameras(cameras: Camera): void;
  51497. /**
  51498. * Attaches the effect on cameras
  51499. * @param cameras The camera to attach to.
  51500. * @hidden
  51501. */
  51502. _attachCameras(cameras: Camera[]): void;
  51503. /**
  51504. * Detatches the effect on cameras
  51505. * @param cameras The camera to detatch from.
  51506. * @hidden
  51507. */
  51508. _detachCameras(cameras: Camera): void;
  51509. /**
  51510. * Detatches the effect on cameras
  51511. * @param cameras The camera to detatch from.
  51512. * @hidden
  51513. */
  51514. _detachCameras(cameras: Camera[]): void;
  51515. /**
  51516. * Enables the effect on given cameras
  51517. * @param cameras The camera to enable.
  51518. * @hidden
  51519. */
  51520. _enable(cameras: Camera): void;
  51521. /**
  51522. * Enables the effect on given cameras
  51523. * @param cameras The camera to enable.
  51524. * @hidden
  51525. */
  51526. _enable(cameras: Nullable<Camera[]>): void;
  51527. /**
  51528. * Disables the effect on the given cameras
  51529. * @param cameras The camera to disable.
  51530. * @hidden
  51531. */
  51532. _disable(cameras: Camera): void;
  51533. /**
  51534. * Disables the effect on the given cameras
  51535. * @param cameras The camera to disable.
  51536. * @hidden
  51537. */
  51538. _disable(cameras: Nullable<Camera[]>): void;
  51539. /**
  51540. * Gets a list of the post processes contained in the effect.
  51541. * @param camera The camera to get the post processes on.
  51542. * @returns The list of the post processes in the effect.
  51543. */
  51544. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51545. }
  51546. }
  51547. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51548. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51549. /** @hidden */
  51550. export var extractHighlightsPixelShader: {
  51551. name: string;
  51552. shader: string;
  51553. };
  51554. }
  51555. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51556. import { Nullable } from "babylonjs/types";
  51557. import { Camera } from "babylonjs/Cameras/camera";
  51558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51559. import { Engine } from "babylonjs/Engines/engine";
  51560. import "babylonjs/Shaders/extractHighlights.fragment";
  51561. /**
  51562. * 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.
  51563. */
  51564. export class ExtractHighlightsPostProcess extends PostProcess {
  51565. /**
  51566. * The luminance threshold, pixels below this value will be set to black.
  51567. */
  51568. threshold: number;
  51569. /** @hidden */
  51570. _exposure: number;
  51571. /**
  51572. * Post process which has the input texture to be used when performing highlight extraction
  51573. * @hidden
  51574. */
  51575. _inputPostProcess: Nullable<PostProcess>;
  51576. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51577. }
  51578. }
  51579. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51580. /** @hidden */
  51581. export var bloomMergePixelShader: {
  51582. name: string;
  51583. shader: string;
  51584. };
  51585. }
  51586. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51587. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51588. import { Nullable } from "babylonjs/types";
  51589. import { Engine } from "babylonjs/Engines/engine";
  51590. import { Camera } from "babylonjs/Cameras/camera";
  51591. import "babylonjs/Shaders/bloomMerge.fragment";
  51592. /**
  51593. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51594. */
  51595. export class BloomMergePostProcess extends PostProcess {
  51596. /** Weight of the bloom to be added to the original input. */
  51597. weight: number;
  51598. /**
  51599. * Creates a new instance of @see BloomMergePostProcess
  51600. * @param name The name of the effect.
  51601. * @param originalFromInput Post process which's input will be used for the merge.
  51602. * @param blurred Blurred highlights post process which's output will be used.
  51603. * @param weight Weight of the bloom to be added to the original input.
  51604. * @param options The required width/height ratio to downsize to before computing the render pass.
  51605. * @param camera The camera to apply the render pass to.
  51606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51607. * @param engine The engine which the post process will be applied. (default: current engine)
  51608. * @param reusable If the post process can be reused on the same frame. (default: false)
  51609. * @param textureType Type of textures used when performing the post process. (default: 0)
  51610. * @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)
  51611. */
  51612. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51613. /** Weight of the bloom to be added to the original input. */
  51614. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51615. }
  51616. }
  51617. declare module "babylonjs/PostProcesses/bloomEffect" {
  51618. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51619. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51620. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51621. import { Camera } from "babylonjs/Cameras/camera";
  51622. import { Scene } from "babylonjs/scene";
  51623. /**
  51624. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51625. */
  51626. export class BloomEffect extends PostProcessRenderEffect {
  51627. private bloomScale;
  51628. /**
  51629. * @hidden Internal
  51630. */
  51631. _effects: Array<PostProcess>;
  51632. /**
  51633. * @hidden Internal
  51634. */
  51635. _downscale: ExtractHighlightsPostProcess;
  51636. private _blurX;
  51637. private _blurY;
  51638. private _merge;
  51639. /**
  51640. * The luminance threshold to find bright areas of the image to bloom.
  51641. */
  51642. threshold: number;
  51643. /**
  51644. * The strength of the bloom.
  51645. */
  51646. weight: number;
  51647. /**
  51648. * Specifies the size of the bloom blur kernel, relative to the final output size
  51649. */
  51650. kernel: number;
  51651. /**
  51652. * Creates a new instance of @see BloomEffect
  51653. * @param scene The scene the effect belongs to.
  51654. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51655. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51656. * @param bloomWeight The the strength of bloom.
  51657. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51658. * @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)
  51659. */
  51660. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51661. /**
  51662. * Disposes each of the internal effects for a given camera.
  51663. * @param camera The camera to dispose the effect on.
  51664. */
  51665. disposeEffects(camera: Camera): void;
  51666. /**
  51667. * @hidden Internal
  51668. */
  51669. _updateEffects(): void;
  51670. /**
  51671. * Internal
  51672. * @returns if all the contained post processes are ready.
  51673. * @hidden
  51674. */
  51675. _isReady(): boolean;
  51676. }
  51677. }
  51678. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51679. /** @hidden */
  51680. export var chromaticAberrationPixelShader: {
  51681. name: string;
  51682. shader: string;
  51683. };
  51684. }
  51685. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51686. import { Vector2 } from "babylonjs/Maths/math";
  51687. import { Nullable } from "babylonjs/types";
  51688. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51689. import { Camera } from "babylonjs/Cameras/camera";
  51690. import { Engine } from "babylonjs/Engines/engine";
  51691. import "babylonjs/Shaders/chromaticAberration.fragment";
  51692. /**
  51693. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51694. */
  51695. export class ChromaticAberrationPostProcess extends PostProcess {
  51696. /**
  51697. * The amount of seperation of rgb channels (default: 30)
  51698. */
  51699. aberrationAmount: number;
  51700. /**
  51701. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51702. */
  51703. radialIntensity: number;
  51704. /**
  51705. * 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))
  51706. */
  51707. direction: Vector2;
  51708. /**
  51709. * 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))
  51710. */
  51711. centerPosition: Vector2;
  51712. /**
  51713. * Creates a new instance ChromaticAberrationPostProcess
  51714. * @param name The name of the effect.
  51715. * @param screenWidth The width of the screen to apply the effect on.
  51716. * @param screenHeight The height of the screen to apply the effect on.
  51717. * @param options The required width/height ratio to downsize to before computing the render pass.
  51718. * @param camera The camera to apply the render pass to.
  51719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51720. * @param engine The engine which the post process will be applied. (default: current engine)
  51721. * @param reusable If the post process can be reused on the same frame. (default: false)
  51722. * @param textureType Type of textures used when performing the post process. (default: 0)
  51723. * @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)
  51724. */
  51725. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51726. }
  51727. }
  51728. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51729. /** @hidden */
  51730. export var circleOfConfusionPixelShader: {
  51731. name: string;
  51732. shader: string;
  51733. };
  51734. }
  51735. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51736. import { Nullable } from "babylonjs/types";
  51737. import { Engine } from "babylonjs/Engines/engine";
  51738. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51740. import { Camera } from "babylonjs/Cameras/camera";
  51741. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51742. /**
  51743. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51744. */
  51745. export class CircleOfConfusionPostProcess extends PostProcess {
  51746. /**
  51747. * 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.
  51748. */
  51749. lensSize: number;
  51750. /**
  51751. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51752. */
  51753. fStop: number;
  51754. /**
  51755. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51756. */
  51757. focusDistance: number;
  51758. /**
  51759. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51760. */
  51761. focalLength: number;
  51762. private _depthTexture;
  51763. /**
  51764. * Creates a new instance CircleOfConfusionPostProcess
  51765. * @param name The name of the effect.
  51766. * @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.
  51767. * @param options The required width/height ratio to downsize to before computing the render pass.
  51768. * @param camera The camera to apply the render pass to.
  51769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51770. * @param engine The engine which the post process will be applied. (default: current engine)
  51771. * @param reusable If the post process can be reused on the same frame. (default: false)
  51772. * @param textureType Type of textures used when performing the post process. (default: 0)
  51773. * @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)
  51774. */
  51775. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51776. /**
  51777. * 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.
  51778. */
  51779. depthTexture: RenderTargetTexture;
  51780. }
  51781. }
  51782. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51783. /** @hidden */
  51784. export var colorCorrectionPixelShader: {
  51785. name: string;
  51786. shader: string;
  51787. };
  51788. }
  51789. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51790. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51791. import { Engine } from "babylonjs/Engines/engine";
  51792. import { Camera } from "babylonjs/Cameras/camera";
  51793. import "babylonjs/Shaders/colorCorrection.fragment";
  51794. /**
  51795. *
  51796. * This post-process allows the modification of rendered colors by using
  51797. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51798. *
  51799. * The object needs to be provided an url to a texture containing the color
  51800. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51801. * Use an image editing software to tweak the LUT to match your needs.
  51802. *
  51803. * For an example of a color LUT, see here:
  51804. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51805. * For explanations on color grading, see here:
  51806. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51807. *
  51808. */
  51809. export class ColorCorrectionPostProcess extends PostProcess {
  51810. private _colorTableTexture;
  51811. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51812. }
  51813. }
  51814. declare module "babylonjs/Shaders/convolution.fragment" {
  51815. /** @hidden */
  51816. export var convolutionPixelShader: {
  51817. name: string;
  51818. shader: string;
  51819. };
  51820. }
  51821. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51823. import { Nullable } from "babylonjs/types";
  51824. import { Camera } from "babylonjs/Cameras/camera";
  51825. import { Engine } from "babylonjs/Engines/engine";
  51826. import "babylonjs/Shaders/convolution.fragment";
  51827. /**
  51828. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51829. * input texture to perform effects such as edge detection or sharpening
  51830. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51831. */
  51832. export class ConvolutionPostProcess extends PostProcess {
  51833. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51834. kernel: number[];
  51835. /**
  51836. * Creates a new instance ConvolutionPostProcess
  51837. * @param name The name of the effect.
  51838. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51839. * @param options The required width/height ratio to downsize to before computing the render pass.
  51840. * @param camera The camera to apply the render pass to.
  51841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51842. * @param engine The engine which the post process will be applied. (default: current engine)
  51843. * @param reusable If the post process can be reused on the same frame. (default: false)
  51844. * @param textureType Type of textures used when performing the post process. (default: 0)
  51845. */
  51846. constructor(name: string,
  51847. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51848. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51849. /**
  51850. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51851. */
  51852. static EdgeDetect0Kernel: number[];
  51853. /**
  51854. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51855. */
  51856. static EdgeDetect1Kernel: number[];
  51857. /**
  51858. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51859. */
  51860. static EdgeDetect2Kernel: number[];
  51861. /**
  51862. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51863. */
  51864. static SharpenKernel: number[];
  51865. /**
  51866. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51867. */
  51868. static EmbossKernel: number[];
  51869. /**
  51870. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51871. */
  51872. static GaussianKernel: number[];
  51873. }
  51874. }
  51875. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51876. import { Nullable } from "babylonjs/types";
  51877. import { Vector2 } from "babylonjs/Maths/math";
  51878. import { Camera } from "babylonjs/Cameras/camera";
  51879. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51880. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51881. import { Engine } from "babylonjs/Engines/engine";
  51882. import { Scene } from "babylonjs/scene";
  51883. /**
  51884. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51885. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51886. * based on samples that have a large difference in distance than the center pixel.
  51887. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51888. */
  51889. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51890. direction: Vector2;
  51891. /**
  51892. * Creates a new instance CircleOfConfusionPostProcess
  51893. * @param name The name of the effect.
  51894. * @param scene The scene the effect belongs to.
  51895. * @param direction The direction the blur should be applied.
  51896. * @param kernel The size of the kernel used to blur.
  51897. * @param options The required width/height ratio to downsize to before computing the render pass.
  51898. * @param camera The camera to apply the render pass to.
  51899. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51900. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51902. * @param engine The engine which the post process will be applied. (default: current engine)
  51903. * @param reusable If the post process can be reused on the same frame. (default: false)
  51904. * @param textureType Type of textures used when performing the post process. (default: 0)
  51905. * @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)
  51906. */
  51907. 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);
  51908. }
  51909. }
  51910. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51911. /** @hidden */
  51912. export var depthOfFieldMergePixelShader: {
  51913. name: string;
  51914. shader: string;
  51915. };
  51916. }
  51917. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51918. import { Nullable } from "babylonjs/types";
  51919. import { Camera } from "babylonjs/Cameras/camera";
  51920. import { Effect } from "babylonjs/Materials/effect";
  51921. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51922. import { Engine } from "babylonjs/Engines/engine";
  51923. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51924. /**
  51925. * Options to be set when merging outputs from the default pipeline.
  51926. */
  51927. export class DepthOfFieldMergePostProcessOptions {
  51928. /**
  51929. * The original image to merge on top of
  51930. */
  51931. originalFromInput: PostProcess;
  51932. /**
  51933. * Parameters to perform the merge of the depth of field effect
  51934. */
  51935. depthOfField?: {
  51936. circleOfConfusion: PostProcess;
  51937. blurSteps: Array<PostProcess>;
  51938. };
  51939. /**
  51940. * Parameters to perform the merge of bloom effect
  51941. */
  51942. bloom?: {
  51943. blurred: PostProcess;
  51944. weight: number;
  51945. };
  51946. }
  51947. /**
  51948. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51949. */
  51950. export class DepthOfFieldMergePostProcess extends PostProcess {
  51951. private blurSteps;
  51952. /**
  51953. * Creates a new instance of DepthOfFieldMergePostProcess
  51954. * @param name The name of the effect.
  51955. * @param originalFromInput Post process which's input will be used for the merge.
  51956. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51957. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51958. * @param options The required width/height ratio to downsize to before computing the render pass.
  51959. * @param camera The camera to apply the render pass to.
  51960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51961. * @param engine The engine which the post process will be applied. (default: current engine)
  51962. * @param reusable If the post process can be reused on the same frame. (default: false)
  51963. * @param textureType Type of textures used when performing the post process. (default: 0)
  51964. * @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)
  51965. */
  51966. 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);
  51967. /**
  51968. * Updates the effect with the current post process compile time values and recompiles the shader.
  51969. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51970. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51971. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51972. * @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
  51973. * @param onCompiled Called when the shader has been compiled.
  51974. * @param onError Called if there is an error when compiling a shader.
  51975. */
  51976. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51977. }
  51978. }
  51979. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51980. import { Nullable } from "babylonjs/types";
  51981. import { Camera } from "babylonjs/Cameras/camera";
  51982. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51984. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51985. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51986. import { Scene } from "babylonjs/scene";
  51987. /**
  51988. * Specifies the level of max blur that should be applied when using the depth of field effect
  51989. */
  51990. export enum DepthOfFieldEffectBlurLevel {
  51991. /**
  51992. * Subtle blur
  51993. */
  51994. Low = 0,
  51995. /**
  51996. * Medium blur
  51997. */
  51998. Medium = 1,
  51999. /**
  52000. * Large blur
  52001. */
  52002. High = 2
  52003. }
  52004. /**
  52005. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52006. */
  52007. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52008. private _circleOfConfusion;
  52009. /**
  52010. * @hidden Internal, blurs from high to low
  52011. */
  52012. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52013. private _depthOfFieldBlurY;
  52014. private _dofMerge;
  52015. /**
  52016. * @hidden Internal post processes in depth of field effect
  52017. */
  52018. _effects: Array<PostProcess>;
  52019. /**
  52020. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52021. */
  52022. focalLength: number;
  52023. /**
  52024. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52025. */
  52026. fStop: number;
  52027. /**
  52028. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52029. */
  52030. focusDistance: number;
  52031. /**
  52032. * 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.
  52033. */
  52034. lensSize: number;
  52035. /**
  52036. * Creates a new instance DepthOfFieldEffect
  52037. * @param scene The scene the effect belongs to.
  52038. * @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.
  52039. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52040. * @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)
  52041. */
  52042. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52043. /**
  52044. * 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.
  52045. */
  52046. depthTexture: RenderTargetTexture;
  52047. /**
  52048. * Disposes each of the internal effects for a given camera.
  52049. * @param camera The camera to dispose the effect on.
  52050. */
  52051. disposeEffects(camera: Camera): void;
  52052. /**
  52053. * @hidden Internal
  52054. */
  52055. _updateEffects(): void;
  52056. /**
  52057. * Internal
  52058. * @returns if all the contained post processes are ready.
  52059. * @hidden
  52060. */
  52061. _isReady(): boolean;
  52062. }
  52063. }
  52064. declare module "babylonjs/Shaders/displayPass.fragment" {
  52065. /** @hidden */
  52066. export var displayPassPixelShader: {
  52067. name: string;
  52068. shader: string;
  52069. };
  52070. }
  52071. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52072. import { Nullable } from "babylonjs/types";
  52073. import { Camera } from "babylonjs/Cameras/camera";
  52074. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52075. import { Engine } from "babylonjs/Engines/engine";
  52076. import "babylonjs/Shaders/displayPass.fragment";
  52077. /**
  52078. * DisplayPassPostProcess which produces an output the same as it's input
  52079. */
  52080. export class DisplayPassPostProcess extends PostProcess {
  52081. /**
  52082. * Creates the DisplayPassPostProcess
  52083. * @param name The name of the effect.
  52084. * @param options The required width/height ratio to downsize to before computing the render pass.
  52085. * @param camera The camera to apply the render pass to.
  52086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52087. * @param engine The engine which the post process will be applied. (default: current engine)
  52088. * @param reusable If the post process can be reused on the same frame. (default: false)
  52089. */
  52090. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52091. }
  52092. }
  52093. declare module "babylonjs/Shaders/filter.fragment" {
  52094. /** @hidden */
  52095. export var filterPixelShader: {
  52096. name: string;
  52097. shader: string;
  52098. };
  52099. }
  52100. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52101. import { Nullable } from "babylonjs/types";
  52102. import { Matrix } from "babylonjs/Maths/math";
  52103. import { Camera } from "babylonjs/Cameras/camera";
  52104. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52105. import { Engine } from "babylonjs/Engines/engine";
  52106. import "babylonjs/Shaders/filter.fragment";
  52107. /**
  52108. * Applies a kernel filter to the image
  52109. */
  52110. export class FilterPostProcess extends PostProcess {
  52111. /** The matrix to be applied to the image */
  52112. kernelMatrix: Matrix;
  52113. /**
  52114. *
  52115. * @param name The name of the effect.
  52116. * @param kernelMatrix The matrix to be applied to the image
  52117. * @param options The required width/height ratio to downsize to before computing the render pass.
  52118. * @param camera The camera to apply the render pass to.
  52119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52120. * @param engine The engine which the post process will be applied. (default: current engine)
  52121. * @param reusable If the post process can be reused on the same frame. (default: false)
  52122. */
  52123. constructor(name: string,
  52124. /** The matrix to be applied to the image */
  52125. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52126. }
  52127. }
  52128. declare module "babylonjs/Shaders/fxaa.fragment" {
  52129. /** @hidden */
  52130. export var fxaaPixelShader: {
  52131. name: string;
  52132. shader: string;
  52133. };
  52134. }
  52135. declare module "babylonjs/Shaders/fxaa.vertex" {
  52136. /** @hidden */
  52137. export var fxaaVertexShader: {
  52138. name: string;
  52139. shader: string;
  52140. };
  52141. }
  52142. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52143. import { Nullable } from "babylonjs/types";
  52144. import { Camera } from "babylonjs/Cameras/camera";
  52145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52146. import { Engine } from "babylonjs/Engines/engine";
  52147. import "babylonjs/Shaders/fxaa.fragment";
  52148. import "babylonjs/Shaders/fxaa.vertex";
  52149. /**
  52150. * Fxaa post process
  52151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52152. */
  52153. export class FxaaPostProcess extends PostProcess {
  52154. /** @hidden */
  52155. texelWidth: number;
  52156. /** @hidden */
  52157. texelHeight: number;
  52158. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52159. private _getDefines;
  52160. }
  52161. }
  52162. declare module "babylonjs/Shaders/grain.fragment" {
  52163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52164. /** @hidden */
  52165. export var grainPixelShader: {
  52166. name: string;
  52167. shader: string;
  52168. };
  52169. }
  52170. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52171. import { Nullable } from "babylonjs/types";
  52172. import { Camera } from "babylonjs/Cameras/camera";
  52173. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52174. import { Engine } from "babylonjs/Engines/engine";
  52175. import "babylonjs/Shaders/grain.fragment";
  52176. /**
  52177. * The GrainPostProcess adds noise to the image at mid luminance levels
  52178. */
  52179. export class GrainPostProcess extends PostProcess {
  52180. /**
  52181. * The intensity of the grain added (default: 30)
  52182. */
  52183. intensity: number;
  52184. /**
  52185. * If the grain should be randomized on every frame
  52186. */
  52187. animated: boolean;
  52188. /**
  52189. * Creates a new instance of @see GrainPostProcess
  52190. * @param name The name of the effect.
  52191. * @param options The required width/height ratio to downsize to before computing the render pass.
  52192. * @param camera The camera to apply the render pass to.
  52193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52194. * @param engine The engine which the post process will be applied. (default: current engine)
  52195. * @param reusable If the post process can be reused on the same frame. (default: false)
  52196. * @param textureType Type of textures used when performing the post process. (default: 0)
  52197. * @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)
  52198. */
  52199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52200. }
  52201. }
  52202. declare module "babylonjs/Shaders/highlights.fragment" {
  52203. /** @hidden */
  52204. export var highlightsPixelShader: {
  52205. name: string;
  52206. shader: string;
  52207. };
  52208. }
  52209. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52210. import { Nullable } from "babylonjs/types";
  52211. import { Camera } from "babylonjs/Cameras/camera";
  52212. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52213. import { Engine } from "babylonjs/Engines/engine";
  52214. import "babylonjs/Shaders/highlights.fragment";
  52215. /**
  52216. * Extracts highlights from the image
  52217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52218. */
  52219. export class HighlightsPostProcess extends PostProcess {
  52220. /**
  52221. * Extracts highlights from the image
  52222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52223. * @param name The name of the effect.
  52224. * @param options The required width/height ratio to downsize to before computing the render pass.
  52225. * @param camera The camera to apply the render pass to.
  52226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52227. * @param engine The engine which the post process will be applied. (default: current engine)
  52228. * @param reusable If the post process can be reused on the same frame. (default: false)
  52229. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52230. */
  52231. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52232. }
  52233. }
  52234. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52235. /** @hidden */
  52236. export var mrtFragmentDeclaration: {
  52237. name: string;
  52238. shader: string;
  52239. };
  52240. }
  52241. declare module "babylonjs/Shaders/geometry.fragment" {
  52242. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52243. /** @hidden */
  52244. export var geometryPixelShader: {
  52245. name: string;
  52246. shader: string;
  52247. };
  52248. }
  52249. declare module "babylonjs/Shaders/geometry.vertex" {
  52250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52251. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52252. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52253. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52254. /** @hidden */
  52255. export var geometryVertexShader: {
  52256. name: string;
  52257. shader: string;
  52258. };
  52259. }
  52260. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52261. import { Matrix } from "babylonjs/Maths/math";
  52262. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52263. import { Mesh } from "babylonjs/Meshes/mesh";
  52264. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52265. import { Effect } from "babylonjs/Materials/effect";
  52266. import { Scene } from "babylonjs/scene";
  52267. import "babylonjs/Shaders/geometry.fragment";
  52268. import "babylonjs/Shaders/geometry.vertex";
  52269. /**
  52270. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52271. */
  52272. export class GeometryBufferRenderer {
  52273. /**
  52274. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52275. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52276. */
  52277. static readonly POSITION_TEXTURE_TYPE: number;
  52278. /**
  52279. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52280. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52281. */
  52282. static readonly VELOCITY_TEXTURE_TYPE: number;
  52283. /**
  52284. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52285. * in order to compute objects velocities when enableVelocity is set to "true"
  52286. * @hidden
  52287. */
  52288. _previousTransformationMatrices: {
  52289. [index: number]: Matrix;
  52290. };
  52291. private _scene;
  52292. private _multiRenderTarget;
  52293. private _ratio;
  52294. private _enablePosition;
  52295. private _enableVelocity;
  52296. private _positionIndex;
  52297. private _velocityIndex;
  52298. protected _effect: Effect;
  52299. protected _cachedDefines: string;
  52300. /**
  52301. * Set the render list (meshes to be rendered) used in the G buffer.
  52302. */
  52303. renderList: Mesh[];
  52304. /**
  52305. * Gets wether or not G buffer are supported by the running hardware.
  52306. * This requires draw buffer supports
  52307. */
  52308. readonly isSupported: boolean;
  52309. /**
  52310. * Returns the index of the given texture type in the G-Buffer textures array
  52311. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52312. * @returns the index of the given texture type in the G-Buffer textures array
  52313. */
  52314. getTextureIndex(textureType: number): number;
  52315. /**
  52316. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52317. */
  52318. /**
  52319. * Sets whether or not objects positions are enabled for the G buffer.
  52320. */
  52321. enablePosition: boolean;
  52322. /**
  52323. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52324. */
  52325. /**
  52326. * Sets wether or not objects velocities are enabled for the G buffer.
  52327. */
  52328. enableVelocity: boolean;
  52329. /**
  52330. * Gets the scene associated with the buffer.
  52331. */
  52332. readonly scene: Scene;
  52333. /**
  52334. * Gets the ratio used by the buffer during its creation.
  52335. * How big is the buffer related to the main canvas.
  52336. */
  52337. readonly ratio: number;
  52338. /** @hidden */
  52339. static _SceneComponentInitialization: (scene: Scene) => void;
  52340. /**
  52341. * Creates a new G Buffer for the scene
  52342. * @param scene The scene the buffer belongs to
  52343. * @param ratio How big is the buffer related to the main canvas.
  52344. */
  52345. constructor(scene: Scene, ratio?: number);
  52346. /**
  52347. * Checks wether everything is ready to render a submesh to the G buffer.
  52348. * @param subMesh the submesh to check readiness for
  52349. * @param useInstances is the mesh drawn using instance or not
  52350. * @returns true if ready otherwise false
  52351. */
  52352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52353. /**
  52354. * Gets the current underlying G Buffer.
  52355. * @returns the buffer
  52356. */
  52357. getGBuffer(): MultiRenderTarget;
  52358. /**
  52359. * Gets the number of samples used to render the buffer (anti aliasing).
  52360. */
  52361. /**
  52362. * Sets the number of samples used to render the buffer (anti aliasing).
  52363. */
  52364. samples: number;
  52365. /**
  52366. * Disposes the renderer and frees up associated resources.
  52367. */
  52368. dispose(): void;
  52369. protected _createRenderTargets(): void;
  52370. }
  52371. }
  52372. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52373. /** @hidden */
  52374. export var motionBlurPixelShader: {
  52375. name: string;
  52376. shader: string;
  52377. };
  52378. }
  52379. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52380. import { Nullable } from "babylonjs/types";
  52381. import { Camera } from "babylonjs/Cameras/camera";
  52382. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52383. import { Scene } from "babylonjs/scene";
  52384. import "babylonjs/Shaders/motionBlur.fragment";
  52385. import { Engine } from "babylonjs/Engines/engine";
  52386. /**
  52387. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52388. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52389. * As an example, all you have to do is to create the post-process:
  52390. * var mb = new BABYLON.MotionBlurPostProcess(
  52391. * 'mb', // The name of the effect.
  52392. * scene, // The scene containing the objects to blur according to their velocity.
  52393. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52394. * camera // The camera to apply the render pass to.
  52395. * );
  52396. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52397. */
  52398. export class MotionBlurPostProcess extends PostProcess {
  52399. /**
  52400. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52401. */
  52402. motionStrength: number;
  52403. /**
  52404. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52405. */
  52406. /**
  52407. * Sets the number of iterations to be used for motion blur quality
  52408. */
  52409. motionBlurSamples: number;
  52410. private _motionBlurSamples;
  52411. private _geometryBufferRenderer;
  52412. /**
  52413. * Creates a new instance MotionBlurPostProcess
  52414. * @param name The name of the effect.
  52415. * @param scene The scene containing the objects to blur according to their velocity.
  52416. * @param options The required width/height ratio to downsize to before computing the render pass.
  52417. * @param camera The camera to apply the render pass to.
  52418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52419. * @param engine The engine which the post process will be applied. (default: current engine)
  52420. * @param reusable If the post process can be reused on the same frame. (default: false)
  52421. * @param textureType Type of textures used when performing the post process. (default: 0)
  52422. * @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)
  52423. */
  52424. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52425. /**
  52426. * Disposes the post process.
  52427. * @param camera The camera to dispose the post process on.
  52428. */
  52429. dispose(camera?: Camera): void;
  52430. }
  52431. }
  52432. declare module "babylonjs/Shaders/refraction.fragment" {
  52433. /** @hidden */
  52434. export var refractionPixelShader: {
  52435. name: string;
  52436. shader: string;
  52437. };
  52438. }
  52439. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52440. import { Color3 } from "babylonjs/Maths/math";
  52441. import { Camera } from "babylonjs/Cameras/camera";
  52442. import { Texture } from "babylonjs/Materials/Textures/texture";
  52443. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52444. import { Engine } from "babylonjs/Engines/engine";
  52445. import "babylonjs/Shaders/refraction.fragment";
  52446. /**
  52447. * Post process which applies a refractin texture
  52448. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52449. */
  52450. export class RefractionPostProcess extends PostProcess {
  52451. /** the base color of the refraction (used to taint the rendering) */
  52452. color: Color3;
  52453. /** simulated refraction depth */
  52454. depth: number;
  52455. /** the coefficient of the base color (0 to remove base color tainting) */
  52456. colorLevel: number;
  52457. private _refTexture;
  52458. private _ownRefractionTexture;
  52459. /**
  52460. * Gets or sets the refraction texture
  52461. * Please note that you are responsible for disposing the texture if you set it manually
  52462. */
  52463. refractionTexture: Texture;
  52464. /**
  52465. * Initializes the RefractionPostProcess
  52466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52467. * @param name The name of the effect.
  52468. * @param refractionTextureUrl Url of the refraction texture to use
  52469. * @param color the base color of the refraction (used to taint the rendering)
  52470. * @param depth simulated refraction depth
  52471. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52472. * @param camera The camera to apply the render pass to.
  52473. * @param options The required width/height ratio to downsize to before computing the render pass.
  52474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52475. * @param engine The engine which the post process will be applied. (default: current engine)
  52476. * @param reusable If the post process can be reused on the same frame. (default: false)
  52477. */
  52478. constructor(name: string, refractionTextureUrl: string,
  52479. /** the base color of the refraction (used to taint the rendering) */
  52480. color: Color3,
  52481. /** simulated refraction depth */
  52482. depth: number,
  52483. /** the coefficient of the base color (0 to remove base color tainting) */
  52484. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52485. /**
  52486. * Disposes of the post process
  52487. * @param camera Camera to dispose post process on
  52488. */
  52489. dispose(camera: Camera): void;
  52490. }
  52491. }
  52492. declare module "babylonjs/Shaders/sharpen.fragment" {
  52493. /** @hidden */
  52494. export var sharpenPixelShader: {
  52495. name: string;
  52496. shader: string;
  52497. };
  52498. }
  52499. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52500. import { Nullable } from "babylonjs/types";
  52501. import { Camera } from "babylonjs/Cameras/camera";
  52502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52503. import "babylonjs/Shaders/sharpen.fragment";
  52504. import { Engine } from "babylonjs/Engines/engine";
  52505. /**
  52506. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52507. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52508. */
  52509. export class SharpenPostProcess extends PostProcess {
  52510. /**
  52511. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52512. */
  52513. colorAmount: number;
  52514. /**
  52515. * How much sharpness should be applied (default: 0.3)
  52516. */
  52517. edgeAmount: number;
  52518. /**
  52519. * Creates a new instance ConvolutionPostProcess
  52520. * @param name The name of the effect.
  52521. * @param options The required width/height ratio to downsize to before computing the render pass.
  52522. * @param camera The camera to apply the render pass to.
  52523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52524. * @param engine The engine which the post process will be applied. (default: current engine)
  52525. * @param reusable If the post process can be reused on the same frame. (default: false)
  52526. * @param textureType Type of textures used when performing the post process. (default: 0)
  52527. * @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)
  52528. */
  52529. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52530. }
  52531. }
  52532. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52533. import { Nullable } from "babylonjs/types";
  52534. import { Camera } from "babylonjs/Cameras/camera";
  52535. import { Engine } from "babylonjs/Engines/engine";
  52536. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52537. /**
  52538. * PostProcessRenderPipeline
  52539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52540. */
  52541. export class PostProcessRenderPipeline {
  52542. private engine;
  52543. private _renderEffects;
  52544. private _renderEffectsForIsolatedPass;
  52545. /**
  52546. * @hidden
  52547. */
  52548. protected _cameras: Camera[];
  52549. /** @hidden */
  52550. _name: string;
  52551. /**
  52552. * Initializes a PostProcessRenderPipeline
  52553. * @param engine engine to add the pipeline to
  52554. * @param name name of the pipeline
  52555. */
  52556. constructor(engine: Engine, name: string);
  52557. /**
  52558. * "PostProcessRenderPipeline"
  52559. * @returns "PostProcessRenderPipeline"
  52560. */
  52561. getClassName(): string;
  52562. /**
  52563. * If all the render effects in the pipeline are support
  52564. */
  52565. readonly isSupported: boolean;
  52566. /**
  52567. * Adds an effect to the pipeline
  52568. * @param renderEffect the effect to add
  52569. */
  52570. addEffect(renderEffect: PostProcessRenderEffect): void;
  52571. /** @hidden */
  52572. _rebuild(): void;
  52573. /** @hidden */
  52574. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52575. /** @hidden */
  52576. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52577. /** @hidden */
  52578. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52579. /** @hidden */
  52580. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52581. /** @hidden */
  52582. _attachCameras(cameras: Camera, unique: boolean): void;
  52583. /** @hidden */
  52584. _attachCameras(cameras: Camera[], unique: boolean): void;
  52585. /** @hidden */
  52586. _detachCameras(cameras: Camera): void;
  52587. /** @hidden */
  52588. _detachCameras(cameras: Nullable<Camera[]>): void;
  52589. /** @hidden */
  52590. _update(): void;
  52591. /** @hidden */
  52592. _reset(): void;
  52593. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52594. /**
  52595. * Disposes of the pipeline
  52596. */
  52597. dispose(): void;
  52598. }
  52599. }
  52600. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52601. import { IAnimatable } from "babylonjs/Misc/tools";
  52602. import { Camera } from "babylonjs/Cameras/camera";
  52603. import { IDisposable } from "babylonjs/scene";
  52604. import { Scene } from "babylonjs/scene";
  52605. import { Animation } from "babylonjs/Animations/animation";
  52606. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52607. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52608. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52609. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52610. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52611. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52612. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52613. /**
  52614. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52615. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52616. */
  52617. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52618. private _scene;
  52619. private _camerasToBeAttached;
  52620. /**
  52621. * ID of the sharpen post process,
  52622. */
  52623. private readonly SharpenPostProcessId;
  52624. /**
  52625. * @ignore
  52626. * ID of the image processing post process;
  52627. */
  52628. readonly ImageProcessingPostProcessId: string;
  52629. /**
  52630. * @ignore
  52631. * ID of the Fast Approximate Anti-Aliasing post process;
  52632. */
  52633. readonly FxaaPostProcessId: string;
  52634. /**
  52635. * ID of the chromatic aberration post process,
  52636. */
  52637. private readonly ChromaticAberrationPostProcessId;
  52638. /**
  52639. * ID of the grain post process
  52640. */
  52641. private readonly GrainPostProcessId;
  52642. /**
  52643. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52644. */
  52645. sharpen: SharpenPostProcess;
  52646. private _sharpenEffect;
  52647. private bloom;
  52648. /**
  52649. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52650. */
  52651. depthOfField: DepthOfFieldEffect;
  52652. /**
  52653. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52654. */
  52655. fxaa: FxaaPostProcess;
  52656. /**
  52657. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52658. */
  52659. imageProcessing: ImageProcessingPostProcess;
  52660. /**
  52661. * Chromatic aberration post process which will shift rgb colors in the image
  52662. */
  52663. chromaticAberration: ChromaticAberrationPostProcess;
  52664. private _chromaticAberrationEffect;
  52665. /**
  52666. * Grain post process which add noise to the image
  52667. */
  52668. grain: GrainPostProcess;
  52669. private _grainEffect;
  52670. /**
  52671. * Glow post process which adds a glow to emmisive areas of the image
  52672. */
  52673. private _glowLayer;
  52674. /**
  52675. * Animations which can be used to tweak settings over a period of time
  52676. */
  52677. animations: Animation[];
  52678. private _imageProcessingConfigurationObserver;
  52679. private _sharpenEnabled;
  52680. private _bloomEnabled;
  52681. private _depthOfFieldEnabled;
  52682. private _depthOfFieldBlurLevel;
  52683. private _fxaaEnabled;
  52684. private _imageProcessingEnabled;
  52685. private _defaultPipelineTextureType;
  52686. private _bloomScale;
  52687. private _chromaticAberrationEnabled;
  52688. private _grainEnabled;
  52689. private _buildAllowed;
  52690. /**
  52691. * Enable or disable the sharpen process from the pipeline
  52692. */
  52693. sharpenEnabled: boolean;
  52694. private _resizeObserver;
  52695. private _hardwareScaleLevel;
  52696. private _bloomKernel;
  52697. /**
  52698. * Specifies the size of the bloom blur kernel, relative to the final output size
  52699. */
  52700. bloomKernel: number;
  52701. /**
  52702. * Specifies the weight of the bloom in the final rendering
  52703. */
  52704. private _bloomWeight;
  52705. /**
  52706. * Specifies the luma threshold for the area that will be blurred by the bloom
  52707. */
  52708. private _bloomThreshold;
  52709. private _hdr;
  52710. /**
  52711. * The strength of the bloom.
  52712. */
  52713. bloomWeight: number;
  52714. /**
  52715. * The strength of the bloom.
  52716. */
  52717. bloomThreshold: number;
  52718. /**
  52719. * The scale of the bloom, lower value will provide better performance.
  52720. */
  52721. bloomScale: number;
  52722. /**
  52723. * Enable or disable the bloom from the pipeline
  52724. */
  52725. bloomEnabled: boolean;
  52726. private _rebuildBloom;
  52727. /**
  52728. * If the depth of field is enabled.
  52729. */
  52730. depthOfFieldEnabled: boolean;
  52731. /**
  52732. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52733. */
  52734. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52735. /**
  52736. * If the anti aliasing is enabled.
  52737. */
  52738. fxaaEnabled: boolean;
  52739. private _samples;
  52740. /**
  52741. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52742. */
  52743. samples: number;
  52744. /**
  52745. * If image processing is enabled.
  52746. */
  52747. imageProcessingEnabled: boolean;
  52748. /**
  52749. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52750. */
  52751. glowLayerEnabled: boolean;
  52752. /**
  52753. * Enable or disable the chromaticAberration process from the pipeline
  52754. */
  52755. chromaticAberrationEnabled: boolean;
  52756. /**
  52757. * Enable or disable the grain process from the pipeline
  52758. */
  52759. grainEnabled: boolean;
  52760. /**
  52761. * @constructor
  52762. * @param name - The rendering pipeline name (default: "")
  52763. * @param hdr - If high dynamic range textures should be used (default: true)
  52764. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52765. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52766. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52767. */
  52768. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52769. /**
  52770. * Force the compilation of the entire pipeline.
  52771. */
  52772. prepare(): void;
  52773. private _hasCleared;
  52774. private _prevPostProcess;
  52775. private _prevPrevPostProcess;
  52776. private _setAutoClearAndTextureSharing;
  52777. private _depthOfFieldSceneObserver;
  52778. private _buildPipeline;
  52779. private _disposePostProcesses;
  52780. /**
  52781. * Adds a camera to the pipeline
  52782. * @param camera the camera to be added
  52783. */
  52784. addCamera(camera: Camera): void;
  52785. /**
  52786. * Removes a camera from the pipeline
  52787. * @param camera the camera to remove
  52788. */
  52789. removeCamera(camera: Camera): void;
  52790. /**
  52791. * Dispose of the pipeline and stop all post processes
  52792. */
  52793. dispose(): void;
  52794. /**
  52795. * Serialize the rendering pipeline (Used when exporting)
  52796. * @returns the serialized object
  52797. */
  52798. serialize(): any;
  52799. /**
  52800. * Parse the serialized pipeline
  52801. * @param source Source pipeline.
  52802. * @param scene The scene to load the pipeline to.
  52803. * @param rootUrl The URL of the serialized pipeline.
  52804. * @returns An instantiated pipeline from the serialized object.
  52805. */
  52806. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52807. }
  52808. }
  52809. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52810. /** @hidden */
  52811. export var lensHighlightsPixelShader: {
  52812. name: string;
  52813. shader: string;
  52814. };
  52815. }
  52816. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52817. /** @hidden */
  52818. export var depthOfFieldPixelShader: {
  52819. name: string;
  52820. shader: string;
  52821. };
  52822. }
  52823. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52824. import { Camera } from "babylonjs/Cameras/camera";
  52825. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52826. import { Scene } from "babylonjs/scene";
  52827. import "babylonjs/Shaders/chromaticAberration.fragment";
  52828. import "babylonjs/Shaders/lensHighlights.fragment";
  52829. import "babylonjs/Shaders/depthOfField.fragment";
  52830. /**
  52831. * BABYLON.JS Chromatic Aberration GLSL Shader
  52832. * Author: Olivier Guyot
  52833. * Separates very slightly R, G and B colors on the edges of the screen
  52834. * Inspired by Francois Tarlier & Martins Upitis
  52835. */
  52836. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52837. /**
  52838. * @ignore
  52839. * The chromatic aberration PostProcess id in the pipeline
  52840. */
  52841. LensChromaticAberrationEffect: string;
  52842. /**
  52843. * @ignore
  52844. * The highlights enhancing PostProcess id in the pipeline
  52845. */
  52846. HighlightsEnhancingEffect: string;
  52847. /**
  52848. * @ignore
  52849. * The depth-of-field PostProcess id in the pipeline
  52850. */
  52851. LensDepthOfFieldEffect: string;
  52852. private _scene;
  52853. private _depthTexture;
  52854. private _grainTexture;
  52855. private _chromaticAberrationPostProcess;
  52856. private _highlightsPostProcess;
  52857. private _depthOfFieldPostProcess;
  52858. private _edgeBlur;
  52859. private _grainAmount;
  52860. private _chromaticAberration;
  52861. private _distortion;
  52862. private _highlightsGain;
  52863. private _highlightsThreshold;
  52864. private _dofDistance;
  52865. private _dofAperture;
  52866. private _dofDarken;
  52867. private _dofPentagon;
  52868. private _blurNoise;
  52869. /**
  52870. * @constructor
  52871. *
  52872. * Effect parameters are as follow:
  52873. * {
  52874. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52875. * edge_blur: number; // from 0 to x (1 for realism)
  52876. * distortion: number; // from 0 to x (1 for realism)
  52877. * grain_amount: number; // from 0 to 1
  52878. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52879. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52880. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52881. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52882. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52883. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52884. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52885. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52886. * }
  52887. * Note: if an effect parameter is unset, effect is disabled
  52888. *
  52889. * @param name The rendering pipeline name
  52890. * @param parameters - An object containing all parameters (see above)
  52891. * @param scene The scene linked to this pipeline
  52892. * @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)
  52893. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52894. */
  52895. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52896. /**
  52897. * Sets the amount of blur at the edges
  52898. * @param amount blur amount
  52899. */
  52900. setEdgeBlur(amount: number): void;
  52901. /**
  52902. * Sets edge blur to 0
  52903. */
  52904. disableEdgeBlur(): void;
  52905. /**
  52906. * Sets the amout of grain
  52907. * @param amount Amount of grain
  52908. */
  52909. setGrainAmount(amount: number): void;
  52910. /**
  52911. * Set grain amount to 0
  52912. */
  52913. disableGrain(): void;
  52914. /**
  52915. * Sets the chromatic aberration amount
  52916. * @param amount amount of chromatic aberration
  52917. */
  52918. setChromaticAberration(amount: number): void;
  52919. /**
  52920. * Sets chromatic aberration amount to 0
  52921. */
  52922. disableChromaticAberration(): void;
  52923. /**
  52924. * Sets the EdgeDistortion amount
  52925. * @param amount amount of EdgeDistortion
  52926. */
  52927. setEdgeDistortion(amount: number): void;
  52928. /**
  52929. * Sets edge distortion to 0
  52930. */
  52931. disableEdgeDistortion(): void;
  52932. /**
  52933. * Sets the FocusDistance amount
  52934. * @param amount amount of FocusDistance
  52935. */
  52936. setFocusDistance(amount: number): void;
  52937. /**
  52938. * Disables depth of field
  52939. */
  52940. disableDepthOfField(): void;
  52941. /**
  52942. * Sets the Aperture amount
  52943. * @param amount amount of Aperture
  52944. */
  52945. setAperture(amount: number): void;
  52946. /**
  52947. * Sets the DarkenOutOfFocus amount
  52948. * @param amount amount of DarkenOutOfFocus
  52949. */
  52950. setDarkenOutOfFocus(amount: number): void;
  52951. /**
  52952. * Creates a pentagon bokeh effect
  52953. */
  52954. enablePentagonBokeh(): void;
  52955. /**
  52956. * Disables the pentagon bokeh effect
  52957. */
  52958. disablePentagonBokeh(): void;
  52959. /**
  52960. * Enables noise blur
  52961. */
  52962. enableNoiseBlur(): void;
  52963. /**
  52964. * Disables noise blur
  52965. */
  52966. disableNoiseBlur(): void;
  52967. /**
  52968. * Sets the HighlightsGain amount
  52969. * @param amount amount of HighlightsGain
  52970. */
  52971. setHighlightsGain(amount: number): void;
  52972. /**
  52973. * Sets the HighlightsThreshold amount
  52974. * @param amount amount of HighlightsThreshold
  52975. */
  52976. setHighlightsThreshold(amount: number): void;
  52977. /**
  52978. * Disables highlights
  52979. */
  52980. disableHighlights(): void;
  52981. /**
  52982. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52983. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52984. */
  52985. dispose(disableDepthRender?: boolean): void;
  52986. private _createChromaticAberrationPostProcess;
  52987. private _createHighlightsPostProcess;
  52988. private _createDepthOfFieldPostProcess;
  52989. private _createGrainTexture;
  52990. }
  52991. }
  52992. declare module "babylonjs/Shaders/ssao2.fragment" {
  52993. /** @hidden */
  52994. export var ssao2PixelShader: {
  52995. name: string;
  52996. shader: string;
  52997. };
  52998. }
  52999. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53000. /** @hidden */
  53001. export var ssaoCombinePixelShader: {
  53002. name: string;
  53003. shader: string;
  53004. };
  53005. }
  53006. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53007. import { Camera } from "babylonjs/Cameras/camera";
  53008. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53009. import { Scene } from "babylonjs/scene";
  53010. import "babylonjs/Shaders/ssao2.fragment";
  53011. import "babylonjs/Shaders/ssaoCombine.fragment";
  53012. /**
  53013. * Render pipeline to produce ssao effect
  53014. */
  53015. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53016. /**
  53017. * @ignore
  53018. * The PassPostProcess id in the pipeline that contains the original scene color
  53019. */
  53020. SSAOOriginalSceneColorEffect: string;
  53021. /**
  53022. * @ignore
  53023. * The SSAO PostProcess id in the pipeline
  53024. */
  53025. SSAORenderEffect: string;
  53026. /**
  53027. * @ignore
  53028. * The horizontal blur PostProcess id in the pipeline
  53029. */
  53030. SSAOBlurHRenderEffect: string;
  53031. /**
  53032. * @ignore
  53033. * The vertical blur PostProcess id in the pipeline
  53034. */
  53035. SSAOBlurVRenderEffect: string;
  53036. /**
  53037. * @ignore
  53038. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53039. */
  53040. SSAOCombineRenderEffect: string;
  53041. /**
  53042. * The output strength of the SSAO post-process. Default value is 1.0.
  53043. */
  53044. totalStrength: number;
  53045. /**
  53046. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53047. */
  53048. maxZ: number;
  53049. /**
  53050. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53051. */
  53052. minZAspect: number;
  53053. private _samples;
  53054. /**
  53055. * Number of samples used for the SSAO calculations. Default value is 8
  53056. */
  53057. samples: number;
  53058. private _textureSamples;
  53059. /**
  53060. * Number of samples to use for antialiasing
  53061. */
  53062. textureSamples: number;
  53063. /**
  53064. * Ratio object used for SSAO ratio and blur ratio
  53065. */
  53066. private _ratio;
  53067. /**
  53068. * Dynamically generated sphere sampler.
  53069. */
  53070. private _sampleSphere;
  53071. /**
  53072. * Blur filter offsets
  53073. */
  53074. private _samplerOffsets;
  53075. private _expensiveBlur;
  53076. /**
  53077. * If bilateral blur should be used
  53078. */
  53079. expensiveBlur: boolean;
  53080. /**
  53081. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53082. */
  53083. radius: number;
  53084. /**
  53085. * The base color of the SSAO post-process
  53086. * The final result is "base + ssao" between [0, 1]
  53087. */
  53088. base: number;
  53089. /**
  53090. * Support test.
  53091. */
  53092. static readonly IsSupported: boolean;
  53093. private _scene;
  53094. private _depthTexture;
  53095. private _normalTexture;
  53096. private _randomTexture;
  53097. private _originalColorPostProcess;
  53098. private _ssaoPostProcess;
  53099. private _blurHPostProcess;
  53100. private _blurVPostProcess;
  53101. private _ssaoCombinePostProcess;
  53102. private _firstUpdate;
  53103. /**
  53104. * @constructor
  53105. * @param name The rendering pipeline name
  53106. * @param scene The scene linked to this pipeline
  53107. * @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 }
  53108. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53109. */
  53110. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53111. /**
  53112. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53113. */
  53114. dispose(disableGeometryBufferRenderer?: boolean): void;
  53115. private _createBlurPostProcess;
  53116. /** @hidden */
  53117. _rebuild(): void;
  53118. private _bits;
  53119. private _radicalInverse_VdC;
  53120. private _hammersley;
  53121. private _hemisphereSample_uniform;
  53122. private _generateHemisphere;
  53123. private _createSSAOPostProcess;
  53124. private _createSSAOCombinePostProcess;
  53125. private _createRandomTexture;
  53126. /**
  53127. * Serialize the rendering pipeline (Used when exporting)
  53128. * @returns the serialized object
  53129. */
  53130. serialize(): any;
  53131. /**
  53132. * Parse the serialized pipeline
  53133. * @param source Source pipeline.
  53134. * @param scene The scene to load the pipeline to.
  53135. * @param rootUrl The URL of the serialized pipeline.
  53136. * @returns An instantiated pipeline from the serialized object.
  53137. */
  53138. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53139. }
  53140. }
  53141. declare module "babylonjs/Shaders/ssao.fragment" {
  53142. /** @hidden */
  53143. export var ssaoPixelShader: {
  53144. name: string;
  53145. shader: string;
  53146. };
  53147. }
  53148. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53149. import { Camera } from "babylonjs/Cameras/camera";
  53150. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53151. import { Scene } from "babylonjs/scene";
  53152. import "babylonjs/Shaders/ssao.fragment";
  53153. import "babylonjs/Shaders/ssaoCombine.fragment";
  53154. /**
  53155. * Render pipeline to produce ssao effect
  53156. */
  53157. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53158. /**
  53159. * @ignore
  53160. * The PassPostProcess id in the pipeline that contains the original scene color
  53161. */
  53162. SSAOOriginalSceneColorEffect: string;
  53163. /**
  53164. * @ignore
  53165. * The SSAO PostProcess id in the pipeline
  53166. */
  53167. SSAORenderEffect: string;
  53168. /**
  53169. * @ignore
  53170. * The horizontal blur PostProcess id in the pipeline
  53171. */
  53172. SSAOBlurHRenderEffect: string;
  53173. /**
  53174. * @ignore
  53175. * The vertical blur PostProcess id in the pipeline
  53176. */
  53177. SSAOBlurVRenderEffect: string;
  53178. /**
  53179. * @ignore
  53180. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53181. */
  53182. SSAOCombineRenderEffect: string;
  53183. /**
  53184. * The output strength of the SSAO post-process. Default value is 1.0.
  53185. */
  53186. totalStrength: number;
  53187. /**
  53188. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53189. */
  53190. radius: number;
  53191. /**
  53192. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53193. * Must not be equal to fallOff and superior to fallOff.
  53194. * Default value is 0.975
  53195. */
  53196. area: number;
  53197. /**
  53198. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53199. * Must not be equal to area and inferior to area.
  53200. * Default value is 0.0
  53201. */
  53202. fallOff: number;
  53203. /**
  53204. * The base color of the SSAO post-process
  53205. * The final result is "base + ssao" between [0, 1]
  53206. */
  53207. base: number;
  53208. private _scene;
  53209. private _depthTexture;
  53210. private _randomTexture;
  53211. private _originalColorPostProcess;
  53212. private _ssaoPostProcess;
  53213. private _blurHPostProcess;
  53214. private _blurVPostProcess;
  53215. private _ssaoCombinePostProcess;
  53216. private _firstUpdate;
  53217. /**
  53218. * @constructor
  53219. * @param name - The rendering pipeline name
  53220. * @param scene - The scene linked to this pipeline
  53221. * @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 }
  53222. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53223. */
  53224. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53225. /**
  53226. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53227. */
  53228. dispose(disableDepthRender?: boolean): void;
  53229. private _createBlurPostProcess;
  53230. /** @hidden */
  53231. _rebuild(): void;
  53232. private _createSSAOPostProcess;
  53233. private _createSSAOCombinePostProcess;
  53234. private _createRandomTexture;
  53235. }
  53236. }
  53237. declare module "babylonjs/Shaders/standard.fragment" {
  53238. /** @hidden */
  53239. export var standardPixelShader: {
  53240. name: string;
  53241. shader: string;
  53242. };
  53243. }
  53244. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53245. import { Nullable } from "babylonjs/types";
  53246. import { IAnimatable } from "babylonjs/Misc/tools";
  53247. import { Camera } from "babylonjs/Cameras/camera";
  53248. import { Texture } from "babylonjs/Materials/Textures/texture";
  53249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53250. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53251. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53252. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53253. import { IDisposable } from "babylonjs/scene";
  53254. import { SpotLight } from "babylonjs/Lights/spotLight";
  53255. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53256. import { Scene } from "babylonjs/scene";
  53257. import { Animation } from "babylonjs/Animations/animation";
  53258. import "babylonjs/Shaders/standard.fragment";
  53259. /**
  53260. * Standard rendering pipeline
  53261. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53262. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53263. */
  53264. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53265. /**
  53266. * Public members
  53267. */
  53268. /**
  53269. * Post-process which contains the original scene color before the pipeline applies all the effects
  53270. */
  53271. originalPostProcess: Nullable<PostProcess>;
  53272. /**
  53273. * Post-process used to down scale an image x4
  53274. */
  53275. downSampleX4PostProcess: Nullable<PostProcess>;
  53276. /**
  53277. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53278. */
  53279. brightPassPostProcess: Nullable<PostProcess>;
  53280. /**
  53281. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53282. */
  53283. blurHPostProcesses: PostProcess[];
  53284. /**
  53285. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53286. */
  53287. blurVPostProcesses: PostProcess[];
  53288. /**
  53289. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53290. */
  53291. textureAdderPostProcess: Nullable<PostProcess>;
  53292. /**
  53293. * Post-process used to create volumetric lighting effect
  53294. */
  53295. volumetricLightPostProcess: Nullable<PostProcess>;
  53296. /**
  53297. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53298. */
  53299. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53300. /**
  53301. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53302. */
  53303. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53304. /**
  53305. * Post-process used to merge the volumetric light effect and the real scene color
  53306. */
  53307. volumetricLightMergePostProces: Nullable<PostProcess>;
  53308. /**
  53309. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53310. */
  53311. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53312. /**
  53313. * Base post-process used to calculate the average luminance of the final image for HDR
  53314. */
  53315. luminancePostProcess: Nullable<PostProcess>;
  53316. /**
  53317. * Post-processes used to create down sample post-processes in order to get
  53318. * the average luminance of the final image for HDR
  53319. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53320. */
  53321. luminanceDownSamplePostProcesses: PostProcess[];
  53322. /**
  53323. * Post-process used to create a HDR effect (light adaptation)
  53324. */
  53325. hdrPostProcess: Nullable<PostProcess>;
  53326. /**
  53327. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53328. */
  53329. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53330. /**
  53331. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53332. */
  53333. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53334. /**
  53335. * Post-process used to merge the final HDR post-process and the real scene color
  53336. */
  53337. hdrFinalPostProcess: Nullable<PostProcess>;
  53338. /**
  53339. * Post-process used to create a lens flare effect
  53340. */
  53341. lensFlarePostProcess: Nullable<PostProcess>;
  53342. /**
  53343. * Post-process that merges the result of the lens flare post-process and the real scene color
  53344. */
  53345. lensFlareComposePostProcess: Nullable<PostProcess>;
  53346. /**
  53347. * Post-process used to create a motion blur effect
  53348. */
  53349. motionBlurPostProcess: Nullable<PostProcess>;
  53350. /**
  53351. * Post-process used to create a depth of field effect
  53352. */
  53353. depthOfFieldPostProcess: Nullable<PostProcess>;
  53354. /**
  53355. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53356. */
  53357. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53358. /**
  53359. * Represents the brightness threshold in order to configure the illuminated surfaces
  53360. */
  53361. brightThreshold: number;
  53362. /**
  53363. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53364. */
  53365. blurWidth: number;
  53366. /**
  53367. * Sets if the blur for highlighted surfaces must be only horizontal
  53368. */
  53369. horizontalBlur: boolean;
  53370. /**
  53371. * Sets the overall exposure used by the pipeline
  53372. */
  53373. exposure: number;
  53374. /**
  53375. * Texture used typically to simulate "dirty" on camera lens
  53376. */
  53377. lensTexture: Nullable<Texture>;
  53378. /**
  53379. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53380. */
  53381. volumetricLightCoefficient: number;
  53382. /**
  53383. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53384. */
  53385. volumetricLightPower: number;
  53386. /**
  53387. * Used the set the blur intensity to smooth the volumetric lights
  53388. */
  53389. volumetricLightBlurScale: number;
  53390. /**
  53391. * Light (spot or directional) used to generate the volumetric lights rays
  53392. * The source light must have a shadow generate so the pipeline can get its
  53393. * depth map
  53394. */
  53395. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53396. /**
  53397. * For eye adaptation, represents the minimum luminance the eye can see
  53398. */
  53399. hdrMinimumLuminance: number;
  53400. /**
  53401. * For eye adaptation, represents the decrease luminance speed
  53402. */
  53403. hdrDecreaseRate: number;
  53404. /**
  53405. * For eye adaptation, represents the increase luminance speed
  53406. */
  53407. hdrIncreaseRate: number;
  53408. /**
  53409. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53410. */
  53411. lensColorTexture: Nullable<Texture>;
  53412. /**
  53413. * The overall strengh for the lens flare effect
  53414. */
  53415. lensFlareStrength: number;
  53416. /**
  53417. * Dispersion coefficient for lens flare ghosts
  53418. */
  53419. lensFlareGhostDispersal: number;
  53420. /**
  53421. * Main lens flare halo width
  53422. */
  53423. lensFlareHaloWidth: number;
  53424. /**
  53425. * Based on the lens distortion effect, defines how much the lens flare result
  53426. * is distorted
  53427. */
  53428. lensFlareDistortionStrength: number;
  53429. /**
  53430. * Lens star texture must be used to simulate rays on the flares and is available
  53431. * in the documentation
  53432. */
  53433. lensStarTexture: Nullable<Texture>;
  53434. /**
  53435. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53436. * flare effect by taking account of the dirt texture
  53437. */
  53438. lensFlareDirtTexture: Nullable<Texture>;
  53439. /**
  53440. * Represents the focal length for the depth of field effect
  53441. */
  53442. depthOfFieldDistance: number;
  53443. /**
  53444. * Represents the blur intensity for the blurred part of the depth of field effect
  53445. */
  53446. depthOfFieldBlurWidth: number;
  53447. /**
  53448. * For motion blur, defines how much the image is blurred by the movement
  53449. */
  53450. motionStrength: number;
  53451. /**
  53452. * List of animations for the pipeline (IAnimatable implementation)
  53453. */
  53454. animations: Animation[];
  53455. /**
  53456. * Private members
  53457. */
  53458. private _scene;
  53459. private _currentDepthOfFieldSource;
  53460. private _basePostProcess;
  53461. private _hdrCurrentLuminance;
  53462. private _floatTextureType;
  53463. private _ratio;
  53464. private _bloomEnabled;
  53465. private _depthOfFieldEnabled;
  53466. private _vlsEnabled;
  53467. private _lensFlareEnabled;
  53468. private _hdrEnabled;
  53469. private _motionBlurEnabled;
  53470. private _fxaaEnabled;
  53471. private _motionBlurSamples;
  53472. private _volumetricLightStepsCount;
  53473. private _samples;
  53474. /**
  53475. * @ignore
  53476. * Specifies if the bloom pipeline is enabled
  53477. */
  53478. BloomEnabled: boolean;
  53479. /**
  53480. * @ignore
  53481. * Specifies if the depth of field pipeline is enabed
  53482. */
  53483. DepthOfFieldEnabled: boolean;
  53484. /**
  53485. * @ignore
  53486. * Specifies if the lens flare pipeline is enabed
  53487. */
  53488. LensFlareEnabled: boolean;
  53489. /**
  53490. * @ignore
  53491. * Specifies if the HDR pipeline is enabled
  53492. */
  53493. HDREnabled: boolean;
  53494. /**
  53495. * @ignore
  53496. * Specifies if the volumetric lights scattering effect is enabled
  53497. */
  53498. VLSEnabled: boolean;
  53499. /**
  53500. * @ignore
  53501. * Specifies if the motion blur effect is enabled
  53502. */
  53503. MotionBlurEnabled: boolean;
  53504. /**
  53505. * Specifies if anti-aliasing is enabled
  53506. */
  53507. fxaaEnabled: boolean;
  53508. /**
  53509. * Specifies the number of steps used to calculate the volumetric lights
  53510. * Typically in interval [50, 200]
  53511. */
  53512. volumetricLightStepsCount: number;
  53513. /**
  53514. * Specifies the number of samples used for the motion blur effect
  53515. * Typically in interval [16, 64]
  53516. */
  53517. motionBlurSamples: number;
  53518. /**
  53519. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53520. */
  53521. samples: number;
  53522. /**
  53523. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53524. * @constructor
  53525. * @param name The rendering pipeline name
  53526. * @param scene The scene linked to this pipeline
  53527. * @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)
  53528. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53529. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53530. */
  53531. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53532. private _buildPipeline;
  53533. private _createDownSampleX4PostProcess;
  53534. private _createBrightPassPostProcess;
  53535. private _createBlurPostProcesses;
  53536. private _createTextureAdderPostProcess;
  53537. private _createVolumetricLightPostProcess;
  53538. private _createLuminancePostProcesses;
  53539. private _createHdrPostProcess;
  53540. private _createLensFlarePostProcess;
  53541. private _createDepthOfFieldPostProcess;
  53542. private _createMotionBlurPostProcess;
  53543. private _getDepthTexture;
  53544. private _disposePostProcesses;
  53545. /**
  53546. * Dispose of the pipeline and stop all post processes
  53547. */
  53548. dispose(): void;
  53549. /**
  53550. * Serialize the rendering pipeline (Used when exporting)
  53551. * @returns the serialized object
  53552. */
  53553. serialize(): any;
  53554. /**
  53555. * Parse the serialized pipeline
  53556. * @param source Source pipeline.
  53557. * @param scene The scene to load the pipeline to.
  53558. * @param rootUrl The URL of the serialized pipeline.
  53559. * @returns An instantiated pipeline from the serialized object.
  53560. */
  53561. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53562. /**
  53563. * Luminance steps
  53564. */
  53565. static LuminanceSteps: number;
  53566. }
  53567. }
  53568. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53569. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53570. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53571. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53573. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53574. }
  53575. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53576. import { Camera } from "babylonjs/Cameras/camera";
  53577. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53578. /**
  53579. * PostProcessRenderPipelineManager class
  53580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53581. */
  53582. export class PostProcessRenderPipelineManager {
  53583. private _renderPipelines;
  53584. /**
  53585. * Initializes a PostProcessRenderPipelineManager
  53586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53587. */
  53588. constructor();
  53589. /**
  53590. * Adds a pipeline to the manager
  53591. * @param renderPipeline The pipeline to add
  53592. */
  53593. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53594. /**
  53595. * Attaches a camera to the pipeline
  53596. * @param renderPipelineName The name of the pipeline to attach to
  53597. * @param cameras the camera to attach
  53598. * @param unique if the camera can be attached multiple times to the pipeline
  53599. */
  53600. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53601. /**
  53602. * Detaches a camera from the pipeline
  53603. * @param renderPipelineName The name of the pipeline to detach from
  53604. * @param cameras the camera to detach
  53605. */
  53606. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53607. /**
  53608. * Enables an effect by name on a pipeline
  53609. * @param renderPipelineName the name of the pipeline to enable the effect in
  53610. * @param renderEffectName the name of the effect to enable
  53611. * @param cameras the cameras that the effect should be enabled on
  53612. */
  53613. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53614. /**
  53615. * Disables an effect by name on a pipeline
  53616. * @param renderPipelineName the name of the pipeline to disable the effect in
  53617. * @param renderEffectName the name of the effect to disable
  53618. * @param cameras the cameras that the effect should be disabled on
  53619. */
  53620. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53621. /**
  53622. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53623. */
  53624. update(): void;
  53625. /** @hidden */
  53626. _rebuild(): void;
  53627. /**
  53628. * Disposes of the manager and pipelines
  53629. */
  53630. dispose(): void;
  53631. }
  53632. }
  53633. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53634. import { ISceneComponent } from "babylonjs/sceneComponent";
  53635. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53636. import { Scene } from "babylonjs/scene";
  53637. module "babylonjs/scene" {
  53638. interface Scene {
  53639. /** @hidden (Backing field) */
  53640. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53641. /**
  53642. * Gets the postprocess render pipeline manager
  53643. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53644. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53645. */
  53646. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53647. }
  53648. }
  53649. /**
  53650. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53651. */
  53652. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53653. /**
  53654. * The component name helpfull to identify the component in the list of scene components.
  53655. */
  53656. readonly name: string;
  53657. /**
  53658. * The scene the component belongs to.
  53659. */
  53660. scene: Scene;
  53661. /**
  53662. * Creates a new instance of the component for the given scene
  53663. * @param scene Defines the scene to register the component in
  53664. */
  53665. constructor(scene: Scene);
  53666. /**
  53667. * Registers the component in a given scene
  53668. */
  53669. register(): void;
  53670. /**
  53671. * Rebuilds the elements related to this component in case of
  53672. * context lost for instance.
  53673. */
  53674. rebuild(): void;
  53675. /**
  53676. * Disposes the component and the associated ressources
  53677. */
  53678. dispose(): void;
  53679. private _gatherRenderTargets;
  53680. }
  53681. }
  53682. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53683. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53684. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53685. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53686. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53687. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53688. }
  53689. declare module "babylonjs/Shaders/tonemap.fragment" {
  53690. /** @hidden */
  53691. export var tonemapPixelShader: {
  53692. name: string;
  53693. shader: string;
  53694. };
  53695. }
  53696. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53697. import { Camera } from "babylonjs/Cameras/camera";
  53698. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53699. import "babylonjs/Shaders/tonemap.fragment";
  53700. import { Engine } from "babylonjs/Engines/engine";
  53701. /** Defines operator used for tonemapping */
  53702. export enum TonemappingOperator {
  53703. /** Hable */
  53704. Hable = 0,
  53705. /** Reinhard */
  53706. Reinhard = 1,
  53707. /** HejiDawson */
  53708. HejiDawson = 2,
  53709. /** Photographic */
  53710. Photographic = 3
  53711. }
  53712. /**
  53713. * Defines a post process to apply tone mapping
  53714. */
  53715. export class TonemapPostProcess extends PostProcess {
  53716. private _operator;
  53717. /** Defines the required exposure adjustement */
  53718. exposureAdjustment: number;
  53719. /**
  53720. * Creates a new TonemapPostProcess
  53721. * @param name defines the name of the postprocess
  53722. * @param _operator defines the operator to use
  53723. * @param exposureAdjustment defines the required exposure adjustement
  53724. * @param camera defines the camera to use (can be null)
  53725. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53726. * @param engine defines the hosting engine (can be ignore if camera is set)
  53727. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53728. */
  53729. constructor(name: string, _operator: TonemappingOperator,
  53730. /** Defines the required exposure adjustement */
  53731. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53732. }
  53733. }
  53734. declare module "babylonjs/Shaders/depth.vertex" {
  53735. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53736. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53739. /** @hidden */
  53740. export var depthVertexShader: {
  53741. name: string;
  53742. shader: string;
  53743. };
  53744. }
  53745. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53746. /** @hidden */
  53747. export var volumetricLightScatteringPixelShader: {
  53748. name: string;
  53749. shader: string;
  53750. };
  53751. }
  53752. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53753. /** @hidden */
  53754. export var volumetricLightScatteringPassPixelShader: {
  53755. name: string;
  53756. shader: string;
  53757. };
  53758. }
  53759. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53760. import { Vector3 } from "babylonjs/Maths/math";
  53761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53762. import { Mesh } from "babylonjs/Meshes/mesh";
  53763. import { Camera } from "babylonjs/Cameras/camera";
  53764. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53765. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53766. import { Scene } from "babylonjs/scene";
  53767. import "babylonjs/Meshes/Builders/planeBuilder";
  53768. import "babylonjs/Shaders/depth.vertex";
  53769. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53770. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53771. import { Engine } from "babylonjs/Engines/engine";
  53772. /**
  53773. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53774. */
  53775. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53776. private _volumetricLightScatteringPass;
  53777. private _volumetricLightScatteringRTT;
  53778. private _viewPort;
  53779. private _screenCoordinates;
  53780. private _cachedDefines;
  53781. /**
  53782. * If not undefined, the mesh position is computed from the attached node position
  53783. */
  53784. attachedNode: {
  53785. position: Vector3;
  53786. };
  53787. /**
  53788. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53789. */
  53790. customMeshPosition: Vector3;
  53791. /**
  53792. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53793. */
  53794. useCustomMeshPosition: boolean;
  53795. /**
  53796. * If the post-process should inverse the light scattering direction
  53797. */
  53798. invert: boolean;
  53799. /**
  53800. * The internal mesh used by the post-process
  53801. */
  53802. mesh: Mesh;
  53803. /**
  53804. * @hidden
  53805. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53806. */
  53807. useDiffuseColor: boolean;
  53808. /**
  53809. * Array containing the excluded meshes not rendered in the internal pass
  53810. */
  53811. excludedMeshes: AbstractMesh[];
  53812. /**
  53813. * Controls the overall intensity of the post-process
  53814. */
  53815. exposure: number;
  53816. /**
  53817. * Dissipates each sample's contribution in range [0, 1]
  53818. */
  53819. decay: number;
  53820. /**
  53821. * Controls the overall intensity of each sample
  53822. */
  53823. weight: number;
  53824. /**
  53825. * Controls the density of each sample
  53826. */
  53827. density: number;
  53828. /**
  53829. * @constructor
  53830. * @param name The post-process name
  53831. * @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)
  53832. * @param camera The camera that the post-process will be attached to
  53833. * @param mesh The mesh used to create the light scattering
  53834. * @param samples The post-process quality, default 100
  53835. * @param samplingModeThe post-process filtering mode
  53836. * @param engine The babylon engine
  53837. * @param reusable If the post-process is reusable
  53838. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53839. */
  53840. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53841. /**
  53842. * Returns the string "VolumetricLightScatteringPostProcess"
  53843. * @returns "VolumetricLightScatteringPostProcess"
  53844. */
  53845. getClassName(): string;
  53846. private _isReady;
  53847. /**
  53848. * Sets the new light position for light scattering effect
  53849. * @param position The new custom light position
  53850. */
  53851. setCustomMeshPosition(position: Vector3): void;
  53852. /**
  53853. * Returns the light position for light scattering effect
  53854. * @return Vector3 The custom light position
  53855. */
  53856. getCustomMeshPosition(): Vector3;
  53857. /**
  53858. * Disposes the internal assets and detaches the post-process from the camera
  53859. */
  53860. dispose(camera: Camera): void;
  53861. /**
  53862. * Returns the render target texture used by the post-process
  53863. * @return the render target texture used by the post-process
  53864. */
  53865. getPass(): RenderTargetTexture;
  53866. private _meshExcluded;
  53867. private _createPass;
  53868. private _updateMeshScreenCoordinates;
  53869. /**
  53870. * Creates a default mesh for the Volumeric Light Scattering post-process
  53871. * @param name The mesh name
  53872. * @param scene The scene where to create the mesh
  53873. * @return the default mesh
  53874. */
  53875. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53876. }
  53877. }
  53878. declare module "babylonjs/PostProcesses/index" {
  53879. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53880. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53881. export * from "babylonjs/PostProcesses/bloomEffect";
  53882. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53883. export * from "babylonjs/PostProcesses/blurPostProcess";
  53884. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53885. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53886. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53887. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53888. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53889. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53890. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53891. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53892. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53893. export * from "babylonjs/PostProcesses/filterPostProcess";
  53894. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53895. export * from "babylonjs/PostProcesses/grainPostProcess";
  53896. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53897. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53898. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53899. export * from "babylonjs/PostProcesses/passPostProcess";
  53900. export * from "babylonjs/PostProcesses/postProcess";
  53901. export * from "babylonjs/PostProcesses/postProcessManager";
  53902. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53903. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53904. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53905. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53906. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53907. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53908. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53909. }
  53910. declare module "babylonjs/Probes/index" {
  53911. export * from "babylonjs/Probes/reflectionProbe";
  53912. }
  53913. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53914. import { Scene } from "babylonjs/scene";
  53915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53916. import { Color3 } from "babylonjs/Maths/math";
  53917. import { SmartArray } from "babylonjs/Misc/smartArray";
  53918. import { ISceneComponent } from "babylonjs/sceneComponent";
  53919. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53920. import "babylonjs/Meshes/Builders/boxBuilder";
  53921. import "babylonjs/Shaders/color.fragment";
  53922. import "babylonjs/Shaders/color.vertex";
  53923. module "babylonjs/scene" {
  53924. interface Scene {
  53925. /** @hidden (Backing field) */
  53926. _boundingBoxRenderer: BoundingBoxRenderer;
  53927. /** @hidden (Backing field) */
  53928. _forceShowBoundingBoxes: boolean;
  53929. /**
  53930. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53931. */
  53932. forceShowBoundingBoxes: boolean;
  53933. /**
  53934. * Gets the bounding box renderer associated with the scene
  53935. * @returns a BoundingBoxRenderer
  53936. */
  53937. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53938. }
  53939. }
  53940. module "babylonjs/Meshes/abstractMesh" {
  53941. interface AbstractMesh {
  53942. /** @hidden (Backing field) */
  53943. _showBoundingBox: boolean;
  53944. /**
  53945. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53946. */
  53947. showBoundingBox: boolean;
  53948. }
  53949. }
  53950. /**
  53951. * Component responsible of rendering the bounding box of the meshes in a scene.
  53952. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53953. */
  53954. export class BoundingBoxRenderer implements ISceneComponent {
  53955. /**
  53956. * The component name helpfull to identify the component in the list of scene components.
  53957. */
  53958. readonly name: string;
  53959. /**
  53960. * The scene the component belongs to.
  53961. */
  53962. scene: Scene;
  53963. /**
  53964. * Color of the bounding box lines placed in front of an object
  53965. */
  53966. frontColor: Color3;
  53967. /**
  53968. * Color of the bounding box lines placed behind an object
  53969. */
  53970. backColor: Color3;
  53971. /**
  53972. * Defines if the renderer should show the back lines or not
  53973. */
  53974. showBackLines: boolean;
  53975. /**
  53976. * @hidden
  53977. */
  53978. renderList: SmartArray<BoundingBox>;
  53979. private _colorShader;
  53980. private _vertexBuffers;
  53981. private _indexBuffer;
  53982. /**
  53983. * Instantiates a new bounding box renderer in a scene.
  53984. * @param scene the scene the renderer renders in
  53985. */
  53986. constructor(scene: Scene);
  53987. /**
  53988. * Registers the component in a given scene
  53989. */
  53990. register(): void;
  53991. private _evaluateSubMesh;
  53992. private _activeMesh;
  53993. private _prepareRessources;
  53994. private _createIndexBuffer;
  53995. /**
  53996. * Rebuilds the elements related to this component in case of
  53997. * context lost for instance.
  53998. */
  53999. rebuild(): void;
  54000. /**
  54001. * @hidden
  54002. */
  54003. reset(): void;
  54004. /**
  54005. * Render the bounding boxes of a specific rendering group
  54006. * @param renderingGroupId defines the rendering group to render
  54007. */
  54008. render(renderingGroupId: number): void;
  54009. /**
  54010. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54011. * @param mesh Define the mesh to render the occlusion bounding box for
  54012. */
  54013. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54014. /**
  54015. * Dispose and release the resources attached to this renderer.
  54016. */
  54017. dispose(): void;
  54018. }
  54019. }
  54020. declare module "babylonjs/Shaders/depth.fragment" {
  54021. /** @hidden */
  54022. export var depthPixelShader: {
  54023. name: string;
  54024. shader: string;
  54025. };
  54026. }
  54027. declare module "babylonjs/Rendering/depthRenderer" {
  54028. import { Nullable } from "babylonjs/types";
  54029. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54030. import { Scene } from "babylonjs/scene";
  54031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54032. import { Camera } from "babylonjs/Cameras/camera";
  54033. import "babylonjs/Shaders/depth.fragment";
  54034. import "babylonjs/Shaders/depth.vertex";
  54035. /**
  54036. * This represents a depth renderer in Babylon.
  54037. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54038. */
  54039. export class DepthRenderer {
  54040. private _scene;
  54041. private _depthMap;
  54042. private _effect;
  54043. private _cachedDefines;
  54044. private _camera;
  54045. /**
  54046. * Specifiess that the depth renderer will only be used within
  54047. * the camera it is created for.
  54048. * This can help forcing its rendering during the camera processing.
  54049. */
  54050. useOnlyInActiveCamera: boolean;
  54051. /** @hidden */
  54052. static _SceneComponentInitialization: (scene: Scene) => void;
  54053. /**
  54054. * Instantiates a depth renderer
  54055. * @param scene The scene the renderer belongs to
  54056. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54057. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54058. */
  54059. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54060. /**
  54061. * Creates the depth rendering effect and checks if the effect is ready.
  54062. * @param subMesh The submesh to be used to render the depth map of
  54063. * @param useInstances If multiple world instances should be used
  54064. * @returns if the depth renderer is ready to render the depth map
  54065. */
  54066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54067. /**
  54068. * Gets the texture which the depth map will be written to.
  54069. * @returns The depth map texture
  54070. */
  54071. getDepthMap(): RenderTargetTexture;
  54072. /**
  54073. * Disposes of the depth renderer.
  54074. */
  54075. dispose(): void;
  54076. }
  54077. }
  54078. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54079. import { Nullable } from "babylonjs/types";
  54080. import { Scene } from "babylonjs/scene";
  54081. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54082. import { Camera } from "babylonjs/Cameras/camera";
  54083. import { ISceneComponent } from "babylonjs/sceneComponent";
  54084. module "babylonjs/scene" {
  54085. interface Scene {
  54086. /** @hidden (Backing field) */
  54087. _depthRenderer: {
  54088. [id: string]: DepthRenderer;
  54089. };
  54090. /**
  54091. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54092. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54093. * @returns the created depth renderer
  54094. */
  54095. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54096. /**
  54097. * Disables a depth renderer for a given camera
  54098. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54099. */
  54100. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54101. }
  54102. }
  54103. /**
  54104. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54105. * in several rendering techniques.
  54106. */
  54107. export class DepthRendererSceneComponent implements ISceneComponent {
  54108. /**
  54109. * The component name helpfull to identify the component in the list of scene components.
  54110. */
  54111. readonly name: string;
  54112. /**
  54113. * The scene the component belongs to.
  54114. */
  54115. scene: Scene;
  54116. /**
  54117. * Creates a new instance of the component for the given scene
  54118. * @param scene Defines the scene to register the component in
  54119. */
  54120. constructor(scene: Scene);
  54121. /**
  54122. * Registers the component in a given scene
  54123. */
  54124. register(): void;
  54125. /**
  54126. * Rebuilds the elements related to this component in case of
  54127. * context lost for instance.
  54128. */
  54129. rebuild(): void;
  54130. /**
  54131. * Disposes the component and the associated ressources
  54132. */
  54133. dispose(): void;
  54134. private _gatherRenderTargets;
  54135. private _gatherActiveCameraRenderTargets;
  54136. }
  54137. }
  54138. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54139. import { Nullable } from "babylonjs/types";
  54140. import { Scene } from "babylonjs/scene";
  54141. import { ISceneComponent } from "babylonjs/sceneComponent";
  54142. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54143. module "babylonjs/scene" {
  54144. interface Scene {
  54145. /** @hidden (Backing field) */
  54146. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54147. /**
  54148. * Gets or Sets the current geometry buffer associated to the scene.
  54149. */
  54150. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54151. /**
  54152. * Enables a GeometryBufferRender and associates it with the scene
  54153. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54154. * @returns the GeometryBufferRenderer
  54155. */
  54156. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54157. /**
  54158. * Disables the GeometryBufferRender associated with the scene
  54159. */
  54160. disableGeometryBufferRenderer(): void;
  54161. }
  54162. }
  54163. /**
  54164. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54165. * in several rendering techniques.
  54166. */
  54167. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54168. /**
  54169. * The component name helpful to identify the component in the list of scene components.
  54170. */
  54171. readonly name: string;
  54172. /**
  54173. * The scene the component belongs to.
  54174. */
  54175. scene: Scene;
  54176. /**
  54177. * Creates a new instance of the component for the given scene
  54178. * @param scene Defines the scene to register the component in
  54179. */
  54180. constructor(scene: Scene);
  54181. /**
  54182. * Registers the component in a given scene
  54183. */
  54184. register(): void;
  54185. /**
  54186. * Rebuilds the elements related to this component in case of
  54187. * context lost for instance.
  54188. */
  54189. rebuild(): void;
  54190. /**
  54191. * Disposes the component and the associated ressources
  54192. */
  54193. dispose(): void;
  54194. private _gatherRenderTargets;
  54195. }
  54196. }
  54197. declare module "babylonjs/Shaders/outline.fragment" {
  54198. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54199. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54200. /** @hidden */
  54201. export var outlinePixelShader: {
  54202. name: string;
  54203. shader: string;
  54204. };
  54205. }
  54206. declare module "babylonjs/Shaders/outline.vertex" {
  54207. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54208. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54209. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54210. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54211. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54212. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54213. /** @hidden */
  54214. export var outlineVertexShader: {
  54215. name: string;
  54216. shader: string;
  54217. };
  54218. }
  54219. declare module "babylonjs/Rendering/outlineRenderer" {
  54220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54221. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54222. import { Scene } from "babylonjs/scene";
  54223. import { ISceneComponent } from "babylonjs/sceneComponent";
  54224. import "babylonjs/Shaders/outline.fragment";
  54225. import "babylonjs/Shaders/outline.vertex";
  54226. module "babylonjs/scene" {
  54227. interface Scene {
  54228. /** @hidden */
  54229. _outlineRenderer: OutlineRenderer;
  54230. /**
  54231. * Gets the outline renderer associated with the scene
  54232. * @returns a OutlineRenderer
  54233. */
  54234. getOutlineRenderer(): OutlineRenderer;
  54235. }
  54236. }
  54237. module "babylonjs/Meshes/abstractMesh" {
  54238. interface AbstractMesh {
  54239. /** @hidden (Backing field) */
  54240. _renderOutline: boolean;
  54241. /**
  54242. * Gets or sets a boolean indicating if the outline must be rendered as well
  54243. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54244. */
  54245. renderOutline: boolean;
  54246. /** @hidden (Backing field) */
  54247. _renderOverlay: boolean;
  54248. /**
  54249. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54250. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54251. */
  54252. renderOverlay: boolean;
  54253. }
  54254. }
  54255. /**
  54256. * This class is responsible to draw bothe outline/overlay of meshes.
  54257. * It should not be used directly but through the available method on mesh.
  54258. */
  54259. export class OutlineRenderer implements ISceneComponent {
  54260. /**
  54261. * The name of the component. Each component must have a unique name.
  54262. */
  54263. name: string;
  54264. /**
  54265. * The scene the component belongs to.
  54266. */
  54267. scene: Scene;
  54268. /**
  54269. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54270. */
  54271. zOffset: number;
  54272. private _engine;
  54273. private _effect;
  54274. private _cachedDefines;
  54275. private _savedDepthWrite;
  54276. /**
  54277. * Instantiates a new outline renderer. (There could be only one per scene).
  54278. * @param scene Defines the scene it belongs to
  54279. */
  54280. constructor(scene: Scene);
  54281. /**
  54282. * Register the component to one instance of a scene.
  54283. */
  54284. register(): void;
  54285. /**
  54286. * Rebuilds the elements related to this component in case of
  54287. * context lost for instance.
  54288. */
  54289. rebuild(): void;
  54290. /**
  54291. * Disposes the component and the associated ressources.
  54292. */
  54293. dispose(): void;
  54294. /**
  54295. * Renders the outline in the canvas.
  54296. * @param subMesh Defines the sumesh to render
  54297. * @param batch Defines the batch of meshes in case of instances
  54298. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54299. */
  54300. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54301. /**
  54302. * Returns whether or not the outline renderer is ready for a given submesh.
  54303. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54304. * @param subMesh Defines the submesh to check readyness for
  54305. * @param useInstances Defines wheter wee are trying to render instances or not
  54306. * @returns true if ready otherwise false
  54307. */
  54308. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54309. private _beforeRenderingMesh;
  54310. private _afterRenderingMesh;
  54311. }
  54312. }
  54313. declare module "babylonjs/Rendering/index" {
  54314. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54315. export * from "babylonjs/Rendering/depthRenderer";
  54316. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54317. export * from "babylonjs/Rendering/edgesRenderer";
  54318. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54319. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54320. export * from "babylonjs/Rendering/outlineRenderer";
  54321. export * from "babylonjs/Rendering/renderingGroup";
  54322. export * from "babylonjs/Rendering/renderingManager";
  54323. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54324. }
  54325. declare module "babylonjs/Sprites/index" {
  54326. export * from "babylonjs/Sprites/sprite";
  54327. export * from "babylonjs/Sprites/spriteManager";
  54328. export * from "babylonjs/Sprites/spriteSceneComponent";
  54329. }
  54330. declare module "babylonjs/Misc/assetsManager" {
  54331. import { Scene } from "babylonjs/scene";
  54332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54333. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54334. import { Skeleton } from "babylonjs/Bones/skeleton";
  54335. import { Observable } from "babylonjs/Misc/observable";
  54336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54337. import { Texture } from "babylonjs/Materials/Textures/texture";
  54338. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54339. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54340. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54341. /**
  54342. * Defines the list of states available for a task inside a AssetsManager
  54343. */
  54344. export enum AssetTaskState {
  54345. /**
  54346. * Initialization
  54347. */
  54348. INIT = 0,
  54349. /**
  54350. * Running
  54351. */
  54352. RUNNING = 1,
  54353. /**
  54354. * Done
  54355. */
  54356. DONE = 2,
  54357. /**
  54358. * Error
  54359. */
  54360. ERROR = 3
  54361. }
  54362. /**
  54363. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54364. */
  54365. export abstract class AbstractAssetTask {
  54366. /**
  54367. * Task name
  54368. */ name: string;
  54369. /**
  54370. * Callback called when the task is successful
  54371. */
  54372. onSuccess: (task: any) => void;
  54373. /**
  54374. * Callback called when the task is not successful
  54375. */
  54376. onError: (task: any, message?: string, exception?: any) => void;
  54377. /**
  54378. * Creates a new AssetsManager
  54379. * @param name defines the name of the task
  54380. */
  54381. constructor(
  54382. /**
  54383. * Task name
  54384. */ name: string);
  54385. private _isCompleted;
  54386. private _taskState;
  54387. private _errorObject;
  54388. /**
  54389. * Get if the task is completed
  54390. */
  54391. readonly isCompleted: boolean;
  54392. /**
  54393. * Gets the current state of the task
  54394. */
  54395. readonly taskState: AssetTaskState;
  54396. /**
  54397. * Gets the current error object (if task is in error)
  54398. */
  54399. readonly errorObject: {
  54400. message?: string;
  54401. exception?: any;
  54402. };
  54403. /**
  54404. * Internal only
  54405. * @hidden
  54406. */
  54407. _setErrorObject(message?: string, exception?: any): void;
  54408. /**
  54409. * Execute the current task
  54410. * @param scene defines the scene where you want your assets to be loaded
  54411. * @param onSuccess is a callback called when the task is successfully executed
  54412. * @param onError is a callback called if an error occurs
  54413. */
  54414. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54415. /**
  54416. * Execute the current task
  54417. * @param scene defines the scene where you want your assets to be loaded
  54418. * @param onSuccess is a callback called when the task is successfully executed
  54419. * @param onError is a callback called if an error occurs
  54420. */
  54421. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54422. /**
  54423. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54424. * This can be used with failed tasks that have the reason for failure fixed.
  54425. */
  54426. reset(): void;
  54427. private onErrorCallback;
  54428. private onDoneCallback;
  54429. }
  54430. /**
  54431. * Define the interface used by progress events raised during assets loading
  54432. */
  54433. export interface IAssetsProgressEvent {
  54434. /**
  54435. * Defines the number of remaining tasks to process
  54436. */
  54437. remainingCount: number;
  54438. /**
  54439. * Defines the total number of tasks
  54440. */
  54441. totalCount: number;
  54442. /**
  54443. * Defines the task that was just processed
  54444. */
  54445. task: AbstractAssetTask;
  54446. }
  54447. /**
  54448. * Class used to share progress information about assets loading
  54449. */
  54450. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54451. /**
  54452. * Defines the number of remaining tasks to process
  54453. */
  54454. remainingCount: number;
  54455. /**
  54456. * Defines the total number of tasks
  54457. */
  54458. totalCount: number;
  54459. /**
  54460. * Defines the task that was just processed
  54461. */
  54462. task: AbstractAssetTask;
  54463. /**
  54464. * Creates a AssetsProgressEvent
  54465. * @param remainingCount defines the number of remaining tasks to process
  54466. * @param totalCount defines the total number of tasks
  54467. * @param task defines the task that was just processed
  54468. */
  54469. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54470. }
  54471. /**
  54472. * Define a task used by AssetsManager to load meshes
  54473. */
  54474. export class MeshAssetTask extends AbstractAssetTask {
  54475. /**
  54476. * Defines the name of the task
  54477. */
  54478. name: string;
  54479. /**
  54480. * Defines the list of mesh's names you want to load
  54481. */
  54482. meshesNames: any;
  54483. /**
  54484. * Defines the root url to use as a base to load your meshes and associated resources
  54485. */
  54486. rootUrl: string;
  54487. /**
  54488. * Defines the filename of the scene to load from
  54489. */
  54490. sceneFilename: string;
  54491. /**
  54492. * Gets the list of loaded meshes
  54493. */
  54494. loadedMeshes: Array<AbstractMesh>;
  54495. /**
  54496. * Gets the list of loaded particle systems
  54497. */
  54498. loadedParticleSystems: Array<IParticleSystem>;
  54499. /**
  54500. * Gets the list of loaded skeletons
  54501. */
  54502. loadedSkeletons: Array<Skeleton>;
  54503. /**
  54504. * Gets the list of loaded animation groups
  54505. */
  54506. loadedAnimationGroups: Array<AnimationGroup>;
  54507. /**
  54508. * Callback called when the task is successful
  54509. */
  54510. onSuccess: (task: MeshAssetTask) => void;
  54511. /**
  54512. * Callback called when the task is successful
  54513. */
  54514. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54515. /**
  54516. * Creates a new MeshAssetTask
  54517. * @param name defines the name of the task
  54518. * @param meshesNames defines the list of mesh's names you want to load
  54519. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54520. * @param sceneFilename defines the filename of the scene to load from
  54521. */
  54522. constructor(
  54523. /**
  54524. * Defines the name of the task
  54525. */
  54526. name: string,
  54527. /**
  54528. * Defines the list of mesh's names you want to load
  54529. */
  54530. meshesNames: any,
  54531. /**
  54532. * Defines the root url to use as a base to load your meshes and associated resources
  54533. */
  54534. rootUrl: string,
  54535. /**
  54536. * Defines the filename of the scene to load from
  54537. */
  54538. sceneFilename: string);
  54539. /**
  54540. * Execute the current task
  54541. * @param scene defines the scene where you want your assets to be loaded
  54542. * @param onSuccess is a callback called when the task is successfully executed
  54543. * @param onError is a callback called if an error occurs
  54544. */
  54545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54546. }
  54547. /**
  54548. * Define a task used by AssetsManager to load text content
  54549. */
  54550. export class TextFileAssetTask extends AbstractAssetTask {
  54551. /**
  54552. * Defines the name of the task
  54553. */
  54554. name: string;
  54555. /**
  54556. * Defines the location of the file to load
  54557. */
  54558. url: string;
  54559. /**
  54560. * Gets the loaded text string
  54561. */
  54562. text: string;
  54563. /**
  54564. * Callback called when the task is successful
  54565. */
  54566. onSuccess: (task: TextFileAssetTask) => void;
  54567. /**
  54568. * Callback called when the task is successful
  54569. */
  54570. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54571. /**
  54572. * Creates a new TextFileAssetTask object
  54573. * @param name defines the name of the task
  54574. * @param url defines the location of the file to load
  54575. */
  54576. constructor(
  54577. /**
  54578. * Defines the name of the task
  54579. */
  54580. name: string,
  54581. /**
  54582. * Defines the location of the file to load
  54583. */
  54584. url: string);
  54585. /**
  54586. * Execute the current task
  54587. * @param scene defines the scene where you want your assets to be loaded
  54588. * @param onSuccess is a callback called when the task is successfully executed
  54589. * @param onError is a callback called if an error occurs
  54590. */
  54591. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54592. }
  54593. /**
  54594. * Define a task used by AssetsManager to load binary data
  54595. */
  54596. export class BinaryFileAssetTask extends AbstractAssetTask {
  54597. /**
  54598. * Defines the name of the task
  54599. */
  54600. name: string;
  54601. /**
  54602. * Defines the location of the file to load
  54603. */
  54604. url: string;
  54605. /**
  54606. * Gets the lodaded data (as an array buffer)
  54607. */
  54608. data: ArrayBuffer;
  54609. /**
  54610. * Callback called when the task is successful
  54611. */
  54612. onSuccess: (task: BinaryFileAssetTask) => void;
  54613. /**
  54614. * Callback called when the task is successful
  54615. */
  54616. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54617. /**
  54618. * Creates a new BinaryFileAssetTask object
  54619. * @param name defines the name of the new task
  54620. * @param url defines the location of the file to load
  54621. */
  54622. constructor(
  54623. /**
  54624. * Defines the name of the task
  54625. */
  54626. name: string,
  54627. /**
  54628. * Defines the location of the file to load
  54629. */
  54630. url: string);
  54631. /**
  54632. * Execute the current task
  54633. * @param scene defines the scene where you want your assets to be loaded
  54634. * @param onSuccess is a callback called when the task is successfully executed
  54635. * @param onError is a callback called if an error occurs
  54636. */
  54637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54638. }
  54639. /**
  54640. * Define a task used by AssetsManager to load images
  54641. */
  54642. export class ImageAssetTask extends AbstractAssetTask {
  54643. /**
  54644. * Defines the name of the task
  54645. */
  54646. name: string;
  54647. /**
  54648. * Defines the location of the image to load
  54649. */
  54650. url: string;
  54651. /**
  54652. * Gets the loaded images
  54653. */
  54654. image: HTMLImageElement;
  54655. /**
  54656. * Callback called when the task is successful
  54657. */
  54658. onSuccess: (task: ImageAssetTask) => void;
  54659. /**
  54660. * Callback called when the task is successful
  54661. */
  54662. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54663. /**
  54664. * Creates a new ImageAssetTask
  54665. * @param name defines the name of the task
  54666. * @param url defines the location of the image to load
  54667. */
  54668. constructor(
  54669. /**
  54670. * Defines the name of the task
  54671. */
  54672. name: string,
  54673. /**
  54674. * Defines the location of the image to load
  54675. */
  54676. url: string);
  54677. /**
  54678. * Execute the current task
  54679. * @param scene defines the scene where you want your assets to be loaded
  54680. * @param onSuccess is a callback called when the task is successfully executed
  54681. * @param onError is a callback called if an error occurs
  54682. */
  54683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54684. }
  54685. /**
  54686. * Defines the interface used by texture loading tasks
  54687. */
  54688. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54689. /**
  54690. * Gets the loaded texture
  54691. */
  54692. texture: TEX;
  54693. }
  54694. /**
  54695. * Define a task used by AssetsManager to load 2D textures
  54696. */
  54697. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54698. /**
  54699. * Defines the name of the task
  54700. */
  54701. name: string;
  54702. /**
  54703. * Defines the location of the file to load
  54704. */
  54705. url: string;
  54706. /**
  54707. * Defines if mipmap should not be generated (default is false)
  54708. */
  54709. noMipmap?: boolean | undefined;
  54710. /**
  54711. * Defines if texture must be inverted on Y axis (default is false)
  54712. */
  54713. invertY?: boolean | undefined;
  54714. /**
  54715. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54716. */
  54717. samplingMode: number;
  54718. /**
  54719. * Gets the loaded texture
  54720. */
  54721. texture: Texture;
  54722. /**
  54723. * Callback called when the task is successful
  54724. */
  54725. onSuccess: (task: TextureAssetTask) => void;
  54726. /**
  54727. * Callback called when the task is successful
  54728. */
  54729. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54730. /**
  54731. * Creates a new TextureAssetTask object
  54732. * @param name defines the name of the task
  54733. * @param url defines the location of the file to load
  54734. * @param noMipmap defines if mipmap should not be generated (default is false)
  54735. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54736. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54737. */
  54738. constructor(
  54739. /**
  54740. * Defines the name of the task
  54741. */
  54742. name: string,
  54743. /**
  54744. * Defines the location of the file to load
  54745. */
  54746. url: string,
  54747. /**
  54748. * Defines if mipmap should not be generated (default is false)
  54749. */
  54750. noMipmap?: boolean | undefined,
  54751. /**
  54752. * Defines if texture must be inverted on Y axis (default is false)
  54753. */
  54754. invertY?: boolean | undefined,
  54755. /**
  54756. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54757. */
  54758. samplingMode?: number);
  54759. /**
  54760. * Execute the current task
  54761. * @param scene defines the scene where you want your assets to be loaded
  54762. * @param onSuccess is a callback called when the task is successfully executed
  54763. * @param onError is a callback called if an error occurs
  54764. */
  54765. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54766. }
  54767. /**
  54768. * Define a task used by AssetsManager to load cube textures
  54769. */
  54770. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54771. /**
  54772. * Defines the name of the task
  54773. */
  54774. name: string;
  54775. /**
  54776. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54777. */
  54778. url: string;
  54779. /**
  54780. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54781. */
  54782. extensions?: string[] | undefined;
  54783. /**
  54784. * Defines if mipmaps should not be generated (default is false)
  54785. */
  54786. noMipmap?: boolean | undefined;
  54787. /**
  54788. * Defines the explicit list of files (undefined by default)
  54789. */
  54790. files?: string[] | undefined;
  54791. /**
  54792. * Gets the loaded texture
  54793. */
  54794. texture: CubeTexture;
  54795. /**
  54796. * Callback called when the task is successful
  54797. */
  54798. onSuccess: (task: CubeTextureAssetTask) => void;
  54799. /**
  54800. * Callback called when the task is successful
  54801. */
  54802. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54803. /**
  54804. * Creates a new CubeTextureAssetTask
  54805. * @param name defines the name of the task
  54806. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54807. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54808. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54809. * @param files defines the explicit list of files (undefined by default)
  54810. */
  54811. constructor(
  54812. /**
  54813. * Defines the name of the task
  54814. */
  54815. name: string,
  54816. /**
  54817. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54818. */
  54819. url: string,
  54820. /**
  54821. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54822. */
  54823. extensions?: string[] | undefined,
  54824. /**
  54825. * Defines if mipmaps should not be generated (default is false)
  54826. */
  54827. noMipmap?: boolean | undefined,
  54828. /**
  54829. * Defines the explicit list of files (undefined by default)
  54830. */
  54831. files?: string[] | undefined);
  54832. /**
  54833. * Execute the current task
  54834. * @param scene defines the scene where you want your assets to be loaded
  54835. * @param onSuccess is a callback called when the task is successfully executed
  54836. * @param onError is a callback called if an error occurs
  54837. */
  54838. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54839. }
  54840. /**
  54841. * Define a task used by AssetsManager to load HDR cube textures
  54842. */
  54843. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54844. /**
  54845. * Defines the name of the task
  54846. */
  54847. name: string;
  54848. /**
  54849. * Defines the location of the file to load
  54850. */
  54851. url: string;
  54852. /**
  54853. * Defines the desired size (the more it increases the longer the generation will be)
  54854. */
  54855. size: number;
  54856. /**
  54857. * Defines if mipmaps should not be generated (default is false)
  54858. */
  54859. noMipmap: boolean;
  54860. /**
  54861. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54862. */
  54863. generateHarmonics: boolean;
  54864. /**
  54865. * 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)
  54866. */
  54867. gammaSpace: boolean;
  54868. /**
  54869. * Internal Use Only
  54870. */
  54871. reserved: boolean;
  54872. /**
  54873. * Gets the loaded texture
  54874. */
  54875. texture: HDRCubeTexture;
  54876. /**
  54877. * Callback called when the task is successful
  54878. */
  54879. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54880. /**
  54881. * Callback called when the task is successful
  54882. */
  54883. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54884. /**
  54885. * Creates a new HDRCubeTextureAssetTask object
  54886. * @param name defines the name of the task
  54887. * @param url defines the location of the file to load
  54888. * @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.
  54889. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54890. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54891. * @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)
  54892. * @param reserved Internal use only
  54893. */
  54894. constructor(
  54895. /**
  54896. * Defines the name of the task
  54897. */
  54898. name: string,
  54899. /**
  54900. * Defines the location of the file to load
  54901. */
  54902. url: string,
  54903. /**
  54904. * Defines the desired size (the more it increases the longer the generation will be)
  54905. */
  54906. size: number,
  54907. /**
  54908. * Defines if mipmaps should not be generated (default is false)
  54909. */
  54910. noMipmap?: boolean,
  54911. /**
  54912. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54913. */
  54914. generateHarmonics?: boolean,
  54915. /**
  54916. * 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)
  54917. */
  54918. gammaSpace?: boolean,
  54919. /**
  54920. * Internal Use Only
  54921. */
  54922. reserved?: boolean);
  54923. /**
  54924. * Execute the current task
  54925. * @param scene defines the scene where you want your assets to be loaded
  54926. * @param onSuccess is a callback called when the task is successfully executed
  54927. * @param onError is a callback called if an error occurs
  54928. */
  54929. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54930. }
  54931. /**
  54932. * This class can be used to easily import assets into a scene
  54933. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54934. */
  54935. export class AssetsManager {
  54936. private _scene;
  54937. private _isLoading;
  54938. protected _tasks: AbstractAssetTask[];
  54939. protected _waitingTasksCount: number;
  54940. protected _totalTasksCount: number;
  54941. /**
  54942. * Callback called when all tasks are processed
  54943. */
  54944. onFinish: (tasks: AbstractAssetTask[]) => void;
  54945. /**
  54946. * Callback called when a task is successful
  54947. */
  54948. onTaskSuccess: (task: AbstractAssetTask) => void;
  54949. /**
  54950. * Callback called when a task had an error
  54951. */
  54952. onTaskError: (task: AbstractAssetTask) => void;
  54953. /**
  54954. * Callback called when a task is done (whatever the result is)
  54955. */
  54956. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54957. /**
  54958. * Observable called when all tasks are processed
  54959. */
  54960. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54961. /**
  54962. * Observable called when a task had an error
  54963. */
  54964. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54965. /**
  54966. * Observable called when a task is successful
  54967. */
  54968. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54969. /**
  54970. * Observable called when a task is done (whatever the result is)
  54971. */
  54972. onProgressObservable: Observable<IAssetsProgressEvent>;
  54973. /**
  54974. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54975. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54976. */
  54977. useDefaultLoadingScreen: boolean;
  54978. /**
  54979. * Creates a new AssetsManager
  54980. * @param scene defines the scene to work on
  54981. */
  54982. constructor(scene: Scene);
  54983. /**
  54984. * Add a MeshAssetTask to the list of active tasks
  54985. * @param taskName defines the name of the new task
  54986. * @param meshesNames defines the name of meshes to load
  54987. * @param rootUrl defines the root url to use to locate files
  54988. * @param sceneFilename defines the filename of the scene file
  54989. * @returns a new MeshAssetTask object
  54990. */
  54991. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54992. /**
  54993. * Add a TextFileAssetTask to the list of active tasks
  54994. * @param taskName defines the name of the new task
  54995. * @param url defines the url of the file to load
  54996. * @returns a new TextFileAssetTask object
  54997. */
  54998. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54999. /**
  55000. * Add a BinaryFileAssetTask to the list of active tasks
  55001. * @param taskName defines the name of the new task
  55002. * @param url defines the url of the file to load
  55003. * @returns a new BinaryFileAssetTask object
  55004. */
  55005. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55006. /**
  55007. * Add a ImageAssetTask to the list of active tasks
  55008. * @param taskName defines the name of the new task
  55009. * @param url defines the url of the file to load
  55010. * @returns a new ImageAssetTask object
  55011. */
  55012. addImageTask(taskName: string, url: string): ImageAssetTask;
  55013. /**
  55014. * Add a TextureAssetTask to the list of active tasks
  55015. * @param taskName defines the name of the new task
  55016. * @param url defines the url of the file to load
  55017. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55018. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55019. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55020. * @returns a new TextureAssetTask object
  55021. */
  55022. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55023. /**
  55024. * Add a CubeTextureAssetTask to the list of active tasks
  55025. * @param taskName defines the name of the new task
  55026. * @param url defines the url of the file to load
  55027. * @param extensions defines the extension to use to load the cube map (can be null)
  55028. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55029. * @param files defines the list of files to load (can be null)
  55030. * @returns a new CubeTextureAssetTask object
  55031. */
  55032. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55033. /**
  55034. *
  55035. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55036. * @param taskName defines the name of the new task
  55037. * @param url defines the url of the file to load
  55038. * @param size defines the size you want for the cubemap (can be null)
  55039. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55040. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55041. * @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)
  55042. * @param reserved Internal use only
  55043. * @returns a new HDRCubeTextureAssetTask object
  55044. */
  55045. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55046. /**
  55047. * Remove a task from the assets manager.
  55048. * @param task the task to remove
  55049. */
  55050. removeTask(task: AbstractAssetTask): void;
  55051. private _decreaseWaitingTasksCount;
  55052. private _runTask;
  55053. /**
  55054. * Reset the AssetsManager and remove all tasks
  55055. * @return the current instance of the AssetsManager
  55056. */
  55057. reset(): AssetsManager;
  55058. /**
  55059. * Start the loading process
  55060. * @return the current instance of the AssetsManager
  55061. */
  55062. load(): AssetsManager;
  55063. }
  55064. }
  55065. declare module "babylonjs/Misc/deferred" {
  55066. /**
  55067. * Wrapper class for promise with external resolve and reject.
  55068. */
  55069. export class Deferred<T> {
  55070. /**
  55071. * The promise associated with this deferred object.
  55072. */
  55073. readonly promise: Promise<T>;
  55074. private _resolve;
  55075. private _reject;
  55076. /**
  55077. * The resolve method of the promise associated with this deferred object.
  55078. */
  55079. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55080. /**
  55081. * The reject method of the promise associated with this deferred object.
  55082. */
  55083. readonly reject: (reason?: any) => void;
  55084. /**
  55085. * Constructor for this deferred object.
  55086. */
  55087. constructor();
  55088. }
  55089. }
  55090. declare module "babylonjs/Misc/filesInput" {
  55091. import { Engine } from "babylonjs/Engines/engine";
  55092. import { Scene } from "babylonjs/scene";
  55093. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55094. /**
  55095. * Class used to help managing file picking and drag'n'drop
  55096. */
  55097. export class FilesInput {
  55098. /**
  55099. * List of files ready to be loaded
  55100. */
  55101. static readonly FilesToLoad: {
  55102. [key: string]: File;
  55103. };
  55104. /**
  55105. * Callback called when a file is processed
  55106. */
  55107. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55108. private _engine;
  55109. private _currentScene;
  55110. private _sceneLoadedCallback;
  55111. private _progressCallback;
  55112. private _additionalRenderLoopLogicCallback;
  55113. private _textureLoadingCallback;
  55114. private _startingProcessingFilesCallback;
  55115. private _onReloadCallback;
  55116. private _errorCallback;
  55117. private _elementToMonitor;
  55118. private _sceneFileToLoad;
  55119. private _filesToLoad;
  55120. /**
  55121. * Creates a new FilesInput
  55122. * @param engine defines the rendering engine
  55123. * @param scene defines the hosting scene
  55124. * @param sceneLoadedCallback callback called when scene is loaded
  55125. * @param progressCallback callback called to track progress
  55126. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55127. * @param textureLoadingCallback callback called when a texture is loading
  55128. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55129. * @param onReloadCallback callback called when a reload is requested
  55130. * @param errorCallback callback call if an error occurs
  55131. */
  55132. 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);
  55133. private _dragEnterHandler;
  55134. private _dragOverHandler;
  55135. private _dropHandler;
  55136. /**
  55137. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55138. * @param elementToMonitor defines the DOM element to track
  55139. */
  55140. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55141. /**
  55142. * Release all associated resources
  55143. */
  55144. dispose(): void;
  55145. private renderFunction;
  55146. private drag;
  55147. private drop;
  55148. private _traverseFolder;
  55149. private _processFiles;
  55150. /**
  55151. * Load files from a drop event
  55152. * @param event defines the drop event to use as source
  55153. */
  55154. loadFiles(event: any): void;
  55155. private _processReload;
  55156. /**
  55157. * Reload the current scene from the loaded files
  55158. */
  55159. reload(): void;
  55160. }
  55161. }
  55162. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55163. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55164. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55165. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55166. }
  55167. declare module "babylonjs/Misc/sceneOptimizer" {
  55168. import { Scene, IDisposable } from "babylonjs/scene";
  55169. import { Observable } from "babylonjs/Misc/observable";
  55170. /**
  55171. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55173. */
  55174. export class SceneOptimization {
  55175. /**
  55176. * Defines the priority of this optimization (0 by default which means first in the list)
  55177. */
  55178. priority: number;
  55179. /**
  55180. * Gets a string describing the action executed by the current optimization
  55181. * @returns description string
  55182. */
  55183. getDescription(): string;
  55184. /**
  55185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55186. * @param scene defines the current scene where to apply this optimization
  55187. * @param optimizer defines the current optimizer
  55188. * @returns true if everything that can be done was applied
  55189. */
  55190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55191. /**
  55192. * Creates the SceneOptimization object
  55193. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55194. * @param desc defines the description associated with the optimization
  55195. */
  55196. constructor(
  55197. /**
  55198. * Defines the priority of this optimization (0 by default which means first in the list)
  55199. */
  55200. priority?: number);
  55201. }
  55202. /**
  55203. * Defines an optimization used to reduce the size of render target textures
  55204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55205. */
  55206. export class TextureOptimization extends SceneOptimization {
  55207. /**
  55208. * Defines the priority of this optimization (0 by default which means first in the list)
  55209. */
  55210. priority: number;
  55211. /**
  55212. * 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
  55213. */
  55214. maximumSize: number;
  55215. /**
  55216. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55217. */
  55218. step: number;
  55219. /**
  55220. * Gets a string describing the action executed by the current optimization
  55221. * @returns description string
  55222. */
  55223. getDescription(): string;
  55224. /**
  55225. * Creates the TextureOptimization object
  55226. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55227. * @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
  55228. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55229. */
  55230. constructor(
  55231. /**
  55232. * Defines the priority of this optimization (0 by default which means first in the list)
  55233. */
  55234. priority?: number,
  55235. /**
  55236. * 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
  55237. */
  55238. maximumSize?: number,
  55239. /**
  55240. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55241. */
  55242. step?: number);
  55243. /**
  55244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55245. * @param scene defines the current scene where to apply this optimization
  55246. * @param optimizer defines the current optimizer
  55247. * @returns true if everything that can be done was applied
  55248. */
  55249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55250. }
  55251. /**
  55252. * Defines an optimization used to increase or decrease the rendering resolution
  55253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55254. */
  55255. export class HardwareScalingOptimization extends SceneOptimization {
  55256. /**
  55257. * Defines the priority of this optimization (0 by default which means first in the list)
  55258. */
  55259. priority: number;
  55260. /**
  55261. * Defines the maximum scale to use (2 by default)
  55262. */
  55263. maximumScale: number;
  55264. /**
  55265. * Defines the step to use between two passes (0.5 by default)
  55266. */
  55267. step: number;
  55268. private _currentScale;
  55269. private _directionOffset;
  55270. /**
  55271. * Gets a string describing the action executed by the current optimization
  55272. * @return description string
  55273. */
  55274. getDescription(): string;
  55275. /**
  55276. * Creates the HardwareScalingOptimization object
  55277. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55278. * @param maximumScale defines the maximum scale to use (2 by default)
  55279. * @param step defines the step to use between two passes (0.5 by default)
  55280. */
  55281. constructor(
  55282. /**
  55283. * Defines the priority of this optimization (0 by default which means first in the list)
  55284. */
  55285. priority?: number,
  55286. /**
  55287. * Defines the maximum scale to use (2 by default)
  55288. */
  55289. maximumScale?: number,
  55290. /**
  55291. * Defines the step to use between two passes (0.5 by default)
  55292. */
  55293. step?: number);
  55294. /**
  55295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55296. * @param scene defines the current scene where to apply this optimization
  55297. * @param optimizer defines the current optimizer
  55298. * @returns true if everything that can be done was applied
  55299. */
  55300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55301. }
  55302. /**
  55303. * Defines an optimization used to remove shadows
  55304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55305. */
  55306. export class ShadowsOptimization extends SceneOptimization {
  55307. /**
  55308. * Gets a string describing the action executed by the current optimization
  55309. * @return description string
  55310. */
  55311. getDescription(): string;
  55312. /**
  55313. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55314. * @param scene defines the current scene where to apply this optimization
  55315. * @param optimizer defines the current optimizer
  55316. * @returns true if everything that can be done was applied
  55317. */
  55318. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55319. }
  55320. /**
  55321. * Defines an optimization used to turn post-processes off
  55322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55323. */
  55324. export class PostProcessesOptimization extends SceneOptimization {
  55325. /**
  55326. * Gets a string describing the action executed by the current optimization
  55327. * @return description string
  55328. */
  55329. getDescription(): string;
  55330. /**
  55331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55332. * @param scene defines the current scene where to apply this optimization
  55333. * @param optimizer defines the current optimizer
  55334. * @returns true if everything that can be done was applied
  55335. */
  55336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55337. }
  55338. /**
  55339. * Defines an optimization used to turn lens flares off
  55340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55341. */
  55342. export class LensFlaresOptimization extends SceneOptimization {
  55343. /**
  55344. * Gets a string describing the action executed by the current optimization
  55345. * @return description string
  55346. */
  55347. getDescription(): string;
  55348. /**
  55349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55350. * @param scene defines the current scene where to apply this optimization
  55351. * @param optimizer defines the current optimizer
  55352. * @returns true if everything that can be done was applied
  55353. */
  55354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55355. }
  55356. /**
  55357. * Defines an optimization based on user defined callback.
  55358. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55359. */
  55360. export class CustomOptimization extends SceneOptimization {
  55361. /**
  55362. * Callback called to apply the custom optimization.
  55363. */
  55364. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55365. /**
  55366. * Callback called to get custom description
  55367. */
  55368. onGetDescription: () => string;
  55369. /**
  55370. * Gets a string describing the action executed by the current optimization
  55371. * @returns description string
  55372. */
  55373. getDescription(): string;
  55374. /**
  55375. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55376. * @param scene defines the current scene where to apply this optimization
  55377. * @param optimizer defines the current optimizer
  55378. * @returns true if everything that can be done was applied
  55379. */
  55380. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55381. }
  55382. /**
  55383. * Defines an optimization used to turn particles off
  55384. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55385. */
  55386. export class ParticlesOptimization extends SceneOptimization {
  55387. /**
  55388. * Gets a string describing the action executed by the current optimization
  55389. * @return description string
  55390. */
  55391. getDescription(): string;
  55392. /**
  55393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55394. * @param scene defines the current scene where to apply this optimization
  55395. * @param optimizer defines the current optimizer
  55396. * @returns true if everything that can be done was applied
  55397. */
  55398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55399. }
  55400. /**
  55401. * Defines an optimization used to turn render targets off
  55402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55403. */
  55404. export class RenderTargetsOptimization extends SceneOptimization {
  55405. /**
  55406. * Gets a string describing the action executed by the current optimization
  55407. * @return description string
  55408. */
  55409. getDescription(): string;
  55410. /**
  55411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55412. * @param scene defines the current scene where to apply this optimization
  55413. * @param optimizer defines the current optimizer
  55414. * @returns true if everything that can be done was applied
  55415. */
  55416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55417. }
  55418. /**
  55419. * Defines an optimization used to merge meshes with compatible materials
  55420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55421. */
  55422. export class MergeMeshesOptimization extends SceneOptimization {
  55423. private static _UpdateSelectionTree;
  55424. /**
  55425. * Gets or sets a boolean which defines if optimization octree has to be updated
  55426. */
  55427. /**
  55428. * Gets or sets a boolean which defines if optimization octree has to be updated
  55429. */
  55430. static UpdateSelectionTree: boolean;
  55431. /**
  55432. * Gets a string describing the action executed by the current optimization
  55433. * @return description string
  55434. */
  55435. getDescription(): string;
  55436. private _canBeMerged;
  55437. /**
  55438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55439. * @param scene defines the current scene where to apply this optimization
  55440. * @param optimizer defines the current optimizer
  55441. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55442. * @returns true if everything that can be done was applied
  55443. */
  55444. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55445. }
  55446. /**
  55447. * Defines a list of options used by SceneOptimizer
  55448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55449. */
  55450. export class SceneOptimizerOptions {
  55451. /**
  55452. * Defines the target frame rate to reach (60 by default)
  55453. */
  55454. targetFrameRate: number;
  55455. /**
  55456. * Defines the interval between two checkes (2000ms by default)
  55457. */
  55458. trackerDuration: number;
  55459. /**
  55460. * Gets the list of optimizations to apply
  55461. */
  55462. optimizations: SceneOptimization[];
  55463. /**
  55464. * Creates a new list of options used by SceneOptimizer
  55465. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55466. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55467. */
  55468. constructor(
  55469. /**
  55470. * Defines the target frame rate to reach (60 by default)
  55471. */
  55472. targetFrameRate?: number,
  55473. /**
  55474. * Defines the interval between two checkes (2000ms by default)
  55475. */
  55476. trackerDuration?: number);
  55477. /**
  55478. * Add a new optimization
  55479. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55480. * @returns the current SceneOptimizerOptions
  55481. */
  55482. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55483. /**
  55484. * Add a new custom optimization
  55485. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55486. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55487. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55488. * @returns the current SceneOptimizerOptions
  55489. */
  55490. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55491. /**
  55492. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55493. * @param targetFrameRate defines the target frame rate (60 by default)
  55494. * @returns a SceneOptimizerOptions object
  55495. */
  55496. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55497. /**
  55498. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55499. * @param targetFrameRate defines the target frame rate (60 by default)
  55500. * @returns a SceneOptimizerOptions object
  55501. */
  55502. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55503. /**
  55504. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55505. * @param targetFrameRate defines the target frame rate (60 by default)
  55506. * @returns a SceneOptimizerOptions object
  55507. */
  55508. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55509. }
  55510. /**
  55511. * Class used to run optimizations in order to reach a target frame rate
  55512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55513. */
  55514. export class SceneOptimizer implements IDisposable {
  55515. private _isRunning;
  55516. private _options;
  55517. private _scene;
  55518. private _currentPriorityLevel;
  55519. private _targetFrameRate;
  55520. private _trackerDuration;
  55521. private _currentFrameRate;
  55522. private _sceneDisposeObserver;
  55523. private _improvementMode;
  55524. /**
  55525. * Defines an observable called when the optimizer reaches the target frame rate
  55526. */
  55527. onSuccessObservable: Observable<SceneOptimizer>;
  55528. /**
  55529. * Defines an observable called when the optimizer enables an optimization
  55530. */
  55531. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55532. /**
  55533. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55534. */
  55535. onFailureObservable: Observable<SceneOptimizer>;
  55536. /**
  55537. * Gets a boolean indicating if the optimizer is in improvement mode
  55538. */
  55539. readonly isInImprovementMode: boolean;
  55540. /**
  55541. * Gets the current priority level (0 at start)
  55542. */
  55543. readonly currentPriorityLevel: number;
  55544. /**
  55545. * Gets the current frame rate checked by the SceneOptimizer
  55546. */
  55547. readonly currentFrameRate: number;
  55548. /**
  55549. * Gets or sets the current target frame rate (60 by default)
  55550. */
  55551. /**
  55552. * Gets or sets the current target frame rate (60 by default)
  55553. */
  55554. targetFrameRate: number;
  55555. /**
  55556. * Gets or sets the current interval between two checks (every 2000ms by default)
  55557. */
  55558. /**
  55559. * Gets or sets the current interval between two checks (every 2000ms by default)
  55560. */
  55561. trackerDuration: number;
  55562. /**
  55563. * Gets the list of active optimizations
  55564. */
  55565. readonly optimizations: SceneOptimization[];
  55566. /**
  55567. * Creates a new SceneOptimizer
  55568. * @param scene defines the scene to work on
  55569. * @param options defines the options to use with the SceneOptimizer
  55570. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55571. * @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)
  55572. */
  55573. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55574. /**
  55575. * Stops the current optimizer
  55576. */
  55577. stop(): void;
  55578. /**
  55579. * Reset the optimizer to initial step (current priority level = 0)
  55580. */
  55581. reset(): void;
  55582. /**
  55583. * Start the optimizer. By default it will try to reach a specific framerate
  55584. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55585. */
  55586. start(): void;
  55587. private _checkCurrentState;
  55588. /**
  55589. * Release all resources
  55590. */
  55591. dispose(): void;
  55592. /**
  55593. * Helper function to create a SceneOptimizer with one single line of code
  55594. * @param scene defines the scene to work on
  55595. * @param options defines the options to use with the SceneOptimizer
  55596. * @param onSuccess defines a callback to call on success
  55597. * @param onFailure defines a callback to call on failure
  55598. * @returns the new SceneOptimizer object
  55599. */
  55600. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55601. }
  55602. }
  55603. declare module "babylonjs/Misc/sceneSerializer" {
  55604. import { Scene } from "babylonjs/scene";
  55605. /**
  55606. * Class used to serialize a scene into a string
  55607. */
  55608. export class SceneSerializer {
  55609. /**
  55610. * Clear cache used by a previous serialization
  55611. */
  55612. static ClearCache(): void;
  55613. /**
  55614. * Serialize a scene into a JSON compatible object
  55615. * @param scene defines the scene to serialize
  55616. * @returns a JSON compatible object
  55617. */
  55618. static Serialize(scene: Scene): any;
  55619. /**
  55620. * Serialize a mesh into a JSON compatible object
  55621. * @param toSerialize defines the mesh to serialize
  55622. * @param withParents defines if parents must be serialized as well
  55623. * @param withChildren defines if children must be serialized as well
  55624. * @returns a JSON compatible object
  55625. */
  55626. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55627. }
  55628. }
  55629. declare module "babylonjs/Misc/videoRecorder" {
  55630. import { Nullable } from "babylonjs/types";
  55631. import { Engine } from "babylonjs/Engines/engine";
  55632. /**
  55633. * This represents the different options avilable for the video capture.
  55634. */
  55635. export interface VideoRecorderOptions {
  55636. /** Defines the mime type of the video */
  55637. mimeType: string;
  55638. /** Defines the video the video should be recorded at */
  55639. fps: number;
  55640. /** Defines the chunk size for the recording data */
  55641. recordChunckSize: number;
  55642. }
  55643. /**
  55644. * This can helps recording videos from BabylonJS.
  55645. * This is based on the available WebRTC functionalities of the browser.
  55646. *
  55647. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55648. */
  55649. export class VideoRecorder {
  55650. private static readonly _defaultOptions;
  55651. /**
  55652. * Returns wehther or not the VideoRecorder is available in your browser.
  55653. * @param engine Defines the Babylon Engine to check the support for
  55654. * @returns true if supported otherwise false
  55655. */
  55656. static IsSupported(engine: Engine): boolean;
  55657. private readonly _options;
  55658. private _canvas;
  55659. private _mediaRecorder;
  55660. private _recordedChunks;
  55661. private _fileName;
  55662. private _resolve;
  55663. private _reject;
  55664. /**
  55665. * True wether a recording is already in progress.
  55666. */
  55667. readonly isRecording: boolean;
  55668. /**
  55669. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55670. * a video file.
  55671. * @param engine Defines the BabylonJS Engine you wish to record
  55672. * @param options Defines options that can be used to customized the capture
  55673. */
  55674. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55675. /**
  55676. * Stops the current recording before the default capture timeout passed in the startRecording
  55677. * functions.
  55678. */
  55679. stopRecording(): void;
  55680. /**
  55681. * Starts recording the canvas for a max duration specified in parameters.
  55682. * @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.
  55683. * @param maxDuration Defines the maximum recording time in seconds.
  55684. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55685. * @return a promise callback at the end of the recording with the video data in Blob.
  55686. */
  55687. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55688. /**
  55689. * Releases internal resources used during the recording.
  55690. */
  55691. dispose(): void;
  55692. private _handleDataAvailable;
  55693. private _handleError;
  55694. private _handleStop;
  55695. }
  55696. }
  55697. declare module "babylonjs/Misc/workerPool" {
  55698. import { IDisposable } from "babylonjs/scene";
  55699. /**
  55700. * Helper class to push actions to a pool of workers.
  55701. */
  55702. export class WorkerPool implements IDisposable {
  55703. private _workerInfos;
  55704. private _pendingActions;
  55705. /**
  55706. * Constructor
  55707. * @param workers Array of workers to use for actions
  55708. */
  55709. constructor(workers: Array<Worker>);
  55710. /**
  55711. * Terminates all workers and clears any pending actions.
  55712. */
  55713. dispose(): void;
  55714. /**
  55715. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55716. * pended until a worker has completed its action.
  55717. * @param action The action to perform. Call onComplete when the action is complete.
  55718. */
  55719. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55720. private _execute;
  55721. }
  55722. }
  55723. declare module "babylonjs/Misc/screenshotTools" {
  55724. import { Camera } from "babylonjs/Cameras/camera";
  55725. import { Engine } from "babylonjs/Engines/engine";
  55726. /**
  55727. * Class containing a set of static utilities functions for screenshots
  55728. */
  55729. export class ScreenshotTools {
  55730. /**
  55731. * Captures a screenshot of the current rendering
  55732. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55733. * @param engine defines the rendering engine
  55734. * @param camera defines the source camera
  55735. * @param size This parameter can be set to a single number or to an object with the
  55736. * following (optional) properties: precision, width, height. If a single number is passed,
  55737. * it will be used for both width and height. If an object is passed, the screenshot size
  55738. * will be derived from the parameters. The precision property is a multiplier allowing
  55739. * rendering at a higher or lower resolution
  55740. * @param successCallback defines the callback receives a single parameter which contains the
  55741. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55742. * src parameter of an <img> to display it
  55743. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55744. * Check your browser for supported MIME types
  55745. */
  55746. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55747. /**
  55748. * Generates an image screenshot from the specified camera.
  55749. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55750. * @param engine The engine to use for rendering
  55751. * @param camera The camera to use for rendering
  55752. * @param size This parameter can be set to a single number or to an object with the
  55753. * following (optional) properties: precision, width, height. If a single number is passed,
  55754. * it will be used for both width and height. If an object is passed, the screenshot size
  55755. * will be derived from the parameters. The precision property is a multiplier allowing
  55756. * rendering at a higher or lower resolution
  55757. * @param successCallback The callback receives a single parameter which contains the
  55758. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55759. * src parameter of an <img> to display it
  55760. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55761. * Check your browser for supported MIME types
  55762. * @param samples Texture samples (default: 1)
  55763. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55764. * @param fileName A name for for the downloaded file.
  55765. */
  55766. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55767. }
  55768. }
  55769. declare module "babylonjs/Misc/index" {
  55770. export * from "babylonjs/Misc/andOrNotEvaluator";
  55771. export * from "babylonjs/Misc/assetsManager";
  55772. export * from "babylonjs/Misc/dds";
  55773. export * from "babylonjs/Misc/decorators";
  55774. export * from "babylonjs/Misc/deferred";
  55775. export * from "babylonjs/Misc/environmentTextureTools";
  55776. export * from "babylonjs/Misc/filesInput";
  55777. export * from "babylonjs/Misc/HighDynamicRange/index";
  55778. export * from "babylonjs/Misc/khronosTextureContainer";
  55779. export * from "babylonjs/Misc/observable";
  55780. export * from "babylonjs/Misc/performanceMonitor";
  55781. export * from "babylonjs/Misc/promise";
  55782. export * from "babylonjs/Misc/sceneOptimizer";
  55783. export * from "babylonjs/Misc/sceneSerializer";
  55784. export * from "babylonjs/Misc/smartArray";
  55785. export * from "babylonjs/Misc/stringDictionary";
  55786. export * from "babylonjs/Misc/tags";
  55787. export * from "babylonjs/Misc/textureTools";
  55788. export * from "babylonjs/Misc/tga";
  55789. export * from "babylonjs/Misc/tools";
  55790. export * from "babylonjs/Misc/videoRecorder";
  55791. export * from "babylonjs/Misc/virtualJoystick";
  55792. export * from "babylonjs/Misc/workerPool";
  55793. export * from "babylonjs/Misc/logger";
  55794. export * from "babylonjs/Misc/typeStore";
  55795. export * from "babylonjs/Misc/filesInputStore";
  55796. export * from "babylonjs/Misc/deepCopier";
  55797. export * from "babylonjs/Misc/pivotTools";
  55798. export * from "babylonjs/Misc/precisionDate";
  55799. export * from "babylonjs/Misc/screenshotTools";
  55800. export * from "babylonjs/Misc/typeStore";
  55801. }
  55802. declare module "babylonjs/index" {
  55803. export * from "babylonjs/abstractScene";
  55804. export * from "babylonjs/Actions/index";
  55805. export * from "babylonjs/Animations/index";
  55806. export * from "babylonjs/assetContainer";
  55807. export * from "babylonjs/Audio/index";
  55808. export * from "babylonjs/Behaviors/index";
  55809. export * from "babylonjs/Bones/index";
  55810. export * from "babylonjs/Cameras/index";
  55811. export * from "babylonjs/Collisions/index";
  55812. export * from "babylonjs/Culling/index";
  55813. export * from "babylonjs/Debug/index";
  55814. export * from "babylonjs/Engines/index";
  55815. export * from "babylonjs/Events/index";
  55816. export * from "babylonjs/Gamepads/index";
  55817. export * from "babylonjs/Gizmos/index";
  55818. export * from "babylonjs/Helpers/index";
  55819. export * from "babylonjs/Instrumentation/index";
  55820. export * from "babylonjs/Layers/index";
  55821. export * from "babylonjs/LensFlares/index";
  55822. export * from "babylonjs/Lights/index";
  55823. export * from "babylonjs/Loading/index";
  55824. export * from "babylonjs/Materials/index";
  55825. export * from "babylonjs/Maths/index";
  55826. export * from "babylonjs/Meshes/index";
  55827. export * from "babylonjs/Morph/index";
  55828. export * from "babylonjs/node";
  55829. export * from "babylonjs/Offline/index";
  55830. export * from "babylonjs/Particles/index";
  55831. export * from "babylonjs/Physics/index";
  55832. export * from "babylonjs/PostProcesses/index";
  55833. export * from "babylonjs/Probes/index";
  55834. export * from "babylonjs/Rendering/index";
  55835. export * from "babylonjs/scene";
  55836. export * from "babylonjs/sceneComponent";
  55837. export * from "babylonjs/Sprites/index";
  55838. export * from "babylonjs/States/index";
  55839. export * from "babylonjs/Misc/index";
  55840. export * from "babylonjs/types";
  55841. }
  55842. declare module "babylonjs/Legacy/legacy" {
  55843. export * from "babylonjs/index";
  55844. }
  55845. declare module "babylonjs/Shaders/blur.fragment" {
  55846. /** @hidden */
  55847. export var blurPixelShader: {
  55848. name: string;
  55849. shader: string;
  55850. };
  55851. }
  55852. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55853. /** @hidden */
  55854. export var bones300Declaration: {
  55855. name: string;
  55856. shader: string;
  55857. };
  55858. }
  55859. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55860. /** @hidden */
  55861. export var instances300Declaration: {
  55862. name: string;
  55863. shader: string;
  55864. };
  55865. }
  55866. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55867. /** @hidden */
  55868. export var pointCloudVertexDeclaration: {
  55869. name: string;
  55870. shader: string;
  55871. };
  55872. }
  55873. // Mixins
  55874. interface Window {
  55875. mozIndexedDB: IDBFactory;
  55876. webkitIndexedDB: IDBFactory;
  55877. msIndexedDB: IDBFactory;
  55878. webkitURL: typeof URL;
  55879. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55880. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55881. WebGLRenderingContext: WebGLRenderingContext;
  55882. MSGesture: MSGesture;
  55883. CANNON: any;
  55884. AudioContext: AudioContext;
  55885. webkitAudioContext: AudioContext;
  55886. PointerEvent: any;
  55887. Math: Math;
  55888. Uint8Array: Uint8ArrayConstructor;
  55889. Float32Array: Float32ArrayConstructor;
  55890. mozURL: typeof URL;
  55891. msURL: typeof URL;
  55892. VRFrameData: any; // WebVR, from specs 1.1
  55893. DracoDecoderModule: any;
  55894. setImmediate(handler: (...args: any[]) => void): number;
  55895. }
  55896. interface Document {
  55897. mozCancelFullScreen(): void;
  55898. msCancelFullScreen(): void;
  55899. webkitCancelFullScreen(): void;
  55900. requestPointerLock(): void;
  55901. exitPointerLock(): void;
  55902. mozFullScreen: boolean;
  55903. msIsFullScreen: boolean;
  55904. readonly webkitIsFullScreen: boolean;
  55905. readonly pointerLockElement: Element;
  55906. mozPointerLockElement: HTMLElement;
  55907. msPointerLockElement: HTMLElement;
  55908. webkitPointerLockElement: HTMLElement;
  55909. }
  55910. interface HTMLCanvasElement {
  55911. requestPointerLock(): void;
  55912. msRequestPointerLock?(): void;
  55913. mozRequestPointerLock?(): void;
  55914. webkitRequestPointerLock?(): void;
  55915. /** Track wether a record is in progress */
  55916. isRecording: boolean;
  55917. /** Capture Stream method defined by some browsers */
  55918. captureStream(fps?: number): MediaStream;
  55919. }
  55920. interface CanvasRenderingContext2D {
  55921. msImageSmoothingEnabled: boolean;
  55922. }
  55923. interface MouseEvent {
  55924. mozMovementX: number;
  55925. mozMovementY: number;
  55926. webkitMovementX: number;
  55927. webkitMovementY: number;
  55928. msMovementX: number;
  55929. msMovementY: number;
  55930. }
  55931. interface Navigator {
  55932. mozGetVRDevices: (any: any) => any;
  55933. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55934. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55935. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55936. webkitGetGamepads(): Gamepad[];
  55937. msGetGamepads(): Gamepad[];
  55938. webkitGamepads(): Gamepad[];
  55939. }
  55940. interface HTMLVideoElement {
  55941. mozSrcObject: any;
  55942. }
  55943. interface Math {
  55944. fround(x: number): number;
  55945. imul(a: number, b: number): number;
  55946. }
  55947. interface WebGLProgram {
  55948. context?: WebGLRenderingContext;
  55949. vertexShader?: WebGLShader;
  55950. fragmentShader?: WebGLShader;
  55951. isParallelCompiled: boolean;
  55952. onCompiled?: () => void;
  55953. }
  55954. interface WebGLRenderingContext {
  55955. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55956. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55957. vertexAttribDivisor(index: number, divisor: number): void;
  55958. createVertexArray(): any;
  55959. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55960. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55961. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55962. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55963. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55964. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55965. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55966. // Queries
  55967. createQuery(): WebGLQuery;
  55968. deleteQuery(query: WebGLQuery): void;
  55969. beginQuery(target: number, query: WebGLQuery): void;
  55970. endQuery(target: number): void;
  55971. getQueryParameter(query: WebGLQuery, pname: number): any;
  55972. getQuery(target: number, pname: number): any;
  55973. MAX_SAMPLES: number;
  55974. RGBA8: number;
  55975. READ_FRAMEBUFFER: number;
  55976. DRAW_FRAMEBUFFER: number;
  55977. UNIFORM_BUFFER: number;
  55978. HALF_FLOAT_OES: number;
  55979. RGBA16F: number;
  55980. RGBA32F: number;
  55981. R32F: number;
  55982. RG32F: number;
  55983. RGB32F: number;
  55984. R16F: number;
  55985. RG16F: number;
  55986. RGB16F: number;
  55987. RED: number;
  55988. RG: number;
  55989. R8: number;
  55990. RG8: number;
  55991. UNSIGNED_INT_24_8: number;
  55992. DEPTH24_STENCIL8: number;
  55993. /* Multiple Render Targets */
  55994. drawBuffers(buffers: number[]): void;
  55995. readBuffer(src: number): void;
  55996. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55997. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55998. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55999. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56000. // Occlusion Query
  56001. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56002. ANY_SAMPLES_PASSED: number;
  56003. QUERY_RESULT_AVAILABLE: number;
  56004. QUERY_RESULT: number;
  56005. }
  56006. interface WebGLBuffer {
  56007. references: number;
  56008. capacity: number;
  56009. is32Bits: boolean;
  56010. }
  56011. interface WebGLProgram {
  56012. transformFeedback?: WebGLTransformFeedback | null;
  56013. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56014. }
  56015. interface EXT_disjoint_timer_query {
  56016. QUERY_COUNTER_BITS_EXT: number;
  56017. TIME_ELAPSED_EXT: number;
  56018. TIMESTAMP_EXT: number;
  56019. GPU_DISJOINT_EXT: number;
  56020. QUERY_RESULT_EXT: number;
  56021. QUERY_RESULT_AVAILABLE_EXT: number;
  56022. queryCounterEXT(query: WebGLQuery, target: number): void;
  56023. createQueryEXT(): WebGLQuery;
  56024. beginQueryEXT(target: number, query: WebGLQuery): void;
  56025. endQueryEXT(target: number): void;
  56026. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56027. deleteQueryEXT(query: WebGLQuery): void;
  56028. }
  56029. interface WebGLUniformLocation {
  56030. _currentState: any;
  56031. }
  56032. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56033. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56034. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56035. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56036. interface WebGLRenderingContext {
  56037. readonly RASTERIZER_DISCARD: number;
  56038. readonly DEPTH_COMPONENT24: number;
  56039. readonly TEXTURE_3D: number;
  56040. readonly TEXTURE_2D_ARRAY: number;
  56041. readonly TEXTURE_COMPARE_FUNC: number;
  56042. readonly TEXTURE_COMPARE_MODE: number;
  56043. readonly COMPARE_REF_TO_TEXTURE: number;
  56044. readonly TEXTURE_WRAP_R: number;
  56045. readonly HALF_FLOAT: number;
  56046. readonly RGB8: number;
  56047. readonly RED_INTEGER: number;
  56048. readonly RG_INTEGER: number;
  56049. readonly RGB_INTEGER: number;
  56050. readonly RGBA_INTEGER: number;
  56051. readonly R8_SNORM: number;
  56052. readonly RG8_SNORM: number;
  56053. readonly RGB8_SNORM: number;
  56054. readonly RGBA8_SNORM: number;
  56055. readonly R8I: number;
  56056. readonly RG8I: number;
  56057. readonly RGB8I: number;
  56058. readonly RGBA8I: number;
  56059. readonly R8UI: number;
  56060. readonly RG8UI: number;
  56061. readonly RGB8UI: number;
  56062. readonly RGBA8UI: number;
  56063. readonly R16I: number;
  56064. readonly RG16I: number;
  56065. readonly RGB16I: number;
  56066. readonly RGBA16I: number;
  56067. readonly R16UI: number;
  56068. readonly RG16UI: number;
  56069. readonly RGB16UI: number;
  56070. readonly RGBA16UI: number;
  56071. readonly R32I: number;
  56072. readonly RG32I: number;
  56073. readonly RGB32I: number;
  56074. readonly RGBA32I: number;
  56075. readonly R32UI: number;
  56076. readonly RG32UI: number;
  56077. readonly RGB32UI: number;
  56078. readonly RGBA32UI: number;
  56079. readonly RGB10_A2UI: number;
  56080. readonly R11F_G11F_B10F: number;
  56081. readonly RGB9_E5: number;
  56082. readonly RGB10_A2: number;
  56083. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56084. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56085. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56086. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56087. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56088. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56089. 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;
  56090. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56091. readonly TRANSFORM_FEEDBACK: number;
  56092. readonly INTERLEAVED_ATTRIBS: number;
  56093. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56094. createTransformFeedback(): WebGLTransformFeedback;
  56095. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56096. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56097. beginTransformFeedback(primitiveMode: number): void;
  56098. endTransformFeedback(): void;
  56099. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56100. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56101. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56102. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56103. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56104. }
  56105. interface ImageBitmap {
  56106. readonly width: number;
  56107. readonly height: number;
  56108. close(): void;
  56109. }
  56110. interface WebGLQuery extends WebGLObject {
  56111. }
  56112. declare var WebGLQuery: {
  56113. prototype: WebGLQuery;
  56114. new(): WebGLQuery;
  56115. };
  56116. interface WebGLSampler extends WebGLObject {
  56117. }
  56118. declare var WebGLSampler: {
  56119. prototype: WebGLSampler;
  56120. new(): WebGLSampler;
  56121. };
  56122. interface WebGLSync extends WebGLObject {
  56123. }
  56124. declare var WebGLSync: {
  56125. prototype: WebGLSync;
  56126. new(): WebGLSync;
  56127. };
  56128. interface WebGLTransformFeedback extends WebGLObject {
  56129. }
  56130. declare var WebGLTransformFeedback: {
  56131. prototype: WebGLTransformFeedback;
  56132. new(): WebGLTransformFeedback;
  56133. };
  56134. interface WebGLVertexArrayObject extends WebGLObject {
  56135. }
  56136. declare var WebGLVertexArrayObject: {
  56137. prototype: WebGLVertexArrayObject;
  56138. new(): WebGLVertexArrayObject;
  56139. };
  56140. // Type definitions for WebVR API
  56141. // Project: https://w3c.github.io/webvr/
  56142. // Definitions by: six a <https://github.com/lostfictions>
  56143. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56144. interface VRDisplay extends EventTarget {
  56145. /**
  56146. * Dictionary of capabilities describing the VRDisplay.
  56147. */
  56148. readonly capabilities: VRDisplayCapabilities;
  56149. /**
  56150. * z-depth defining the far plane of the eye view frustum
  56151. * enables mapping of values in the render target depth
  56152. * attachment to scene coordinates. Initially set to 10000.0.
  56153. */
  56154. depthFar: number;
  56155. /**
  56156. * z-depth defining the near plane of the eye view frustum
  56157. * enables mapping of values in the render target depth
  56158. * attachment to scene coordinates. Initially set to 0.01.
  56159. */
  56160. depthNear: number;
  56161. /**
  56162. * An identifier for this distinct VRDisplay. Used as an
  56163. * association point in the Gamepad API.
  56164. */
  56165. readonly displayId: number;
  56166. /**
  56167. * A display name, a user-readable name identifying it.
  56168. */
  56169. readonly displayName: string;
  56170. readonly isConnected: boolean;
  56171. readonly isPresenting: boolean;
  56172. /**
  56173. * If this VRDisplay supports room-scale experiences, the optional
  56174. * stage attribute contains details on the room-scale parameters.
  56175. */
  56176. readonly stageParameters: VRStageParameters | null;
  56177. /**
  56178. * Passing the value returned by `requestAnimationFrame` to
  56179. * `cancelAnimationFrame` will unregister the callback.
  56180. * @param handle Define the hanle of the request to cancel
  56181. */
  56182. cancelAnimationFrame(handle: number): void;
  56183. /**
  56184. * Stops presenting to the VRDisplay.
  56185. * @returns a promise to know when it stopped
  56186. */
  56187. exitPresent(): Promise<void>;
  56188. /**
  56189. * Return the current VREyeParameters for the given eye.
  56190. * @param whichEye Define the eye we want the parameter for
  56191. * @returns the eye parameters
  56192. */
  56193. getEyeParameters(whichEye: string): VREyeParameters;
  56194. /**
  56195. * Populates the passed VRFrameData with the information required to render
  56196. * the current frame.
  56197. * @param frameData Define the data structure to populate
  56198. * @returns true if ok otherwise false
  56199. */
  56200. getFrameData(frameData: VRFrameData): boolean;
  56201. /**
  56202. * Get the layers currently being presented.
  56203. * @returns the list of VR layers
  56204. */
  56205. getLayers(): VRLayer[];
  56206. /**
  56207. * Return a VRPose containing the future predicted pose of the VRDisplay
  56208. * when the current frame will be presented. The value returned will not
  56209. * change until JavaScript has returned control to the browser.
  56210. *
  56211. * The VRPose will contain the position, orientation, velocity,
  56212. * and acceleration of each of these properties.
  56213. * @returns the pose object
  56214. */
  56215. getPose(): VRPose;
  56216. /**
  56217. * Return the current instantaneous pose of the VRDisplay, with no
  56218. * prediction applied.
  56219. * @returns the current instantaneous pose
  56220. */
  56221. getImmediatePose(): VRPose;
  56222. /**
  56223. * The callback passed to `requestAnimationFrame` will be called
  56224. * any time a new frame should be rendered. When the VRDisplay is
  56225. * presenting the callback will be called at the native refresh
  56226. * rate of the HMD. When not presenting this function acts
  56227. * identically to how window.requestAnimationFrame acts. Content should
  56228. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56229. * asynchronously from other displays and at differing refresh rates.
  56230. * @param callback Define the eaction to run next frame
  56231. * @returns the request handle it
  56232. */
  56233. requestAnimationFrame(callback: FrameRequestCallback): number;
  56234. /**
  56235. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56236. * Repeat calls while already presenting will update the VRLayers being displayed.
  56237. * @param layers Define the list of layer to present
  56238. * @returns a promise to know when the request has been fulfilled
  56239. */
  56240. requestPresent(layers: VRLayer[]): Promise<void>;
  56241. /**
  56242. * Reset the pose for this display, treating its current position and
  56243. * orientation as the "origin/zero" values. VRPose.position,
  56244. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56245. * updated when calling resetPose(). This should be called in only
  56246. * sitting-space experiences.
  56247. */
  56248. resetPose(): void;
  56249. /**
  56250. * The VRLayer provided to the VRDisplay will be captured and presented
  56251. * in the HMD. Calling this function has the same effect on the source
  56252. * canvas as any other operation that uses its source image, and canvases
  56253. * created without preserveDrawingBuffer set to true will be cleared.
  56254. * @param pose Define the pose to submit
  56255. */
  56256. submitFrame(pose?: VRPose): void;
  56257. }
  56258. declare var VRDisplay: {
  56259. prototype: VRDisplay;
  56260. new(): VRDisplay;
  56261. };
  56262. interface VRLayer {
  56263. leftBounds?: number[] | Float32Array | null;
  56264. rightBounds?: number[] | Float32Array | null;
  56265. source?: HTMLCanvasElement | null;
  56266. }
  56267. interface VRDisplayCapabilities {
  56268. readonly canPresent: boolean;
  56269. readonly hasExternalDisplay: boolean;
  56270. readonly hasOrientation: boolean;
  56271. readonly hasPosition: boolean;
  56272. readonly maxLayers: number;
  56273. }
  56274. interface VREyeParameters {
  56275. /** @deprecated */
  56276. readonly fieldOfView: VRFieldOfView;
  56277. readonly offset: Float32Array;
  56278. readonly renderHeight: number;
  56279. readonly renderWidth: number;
  56280. }
  56281. interface VRFieldOfView {
  56282. readonly downDegrees: number;
  56283. readonly leftDegrees: number;
  56284. readonly rightDegrees: number;
  56285. readonly upDegrees: number;
  56286. }
  56287. interface VRFrameData {
  56288. readonly leftProjectionMatrix: Float32Array;
  56289. readonly leftViewMatrix: Float32Array;
  56290. readonly pose: VRPose;
  56291. readonly rightProjectionMatrix: Float32Array;
  56292. readonly rightViewMatrix: Float32Array;
  56293. readonly timestamp: number;
  56294. }
  56295. interface VRPose {
  56296. readonly angularAcceleration: Float32Array | null;
  56297. readonly angularVelocity: Float32Array | null;
  56298. readonly linearAcceleration: Float32Array | null;
  56299. readonly linearVelocity: Float32Array | null;
  56300. readonly orientation: Float32Array | null;
  56301. readonly position: Float32Array | null;
  56302. readonly timestamp: number;
  56303. }
  56304. interface VRStageParameters {
  56305. sittingToStandingTransform?: Float32Array;
  56306. sizeX?: number;
  56307. sizeY?: number;
  56308. }
  56309. interface Navigator {
  56310. getVRDisplays(): Promise<VRDisplay[]>;
  56311. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56312. }
  56313. interface Window {
  56314. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56315. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56316. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56317. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56318. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56319. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56320. }
  56321. interface Gamepad {
  56322. readonly displayId: number;
  56323. }
  56324. interface XRDevice {
  56325. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56326. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56327. }
  56328. interface XRSession {
  56329. getInputSources(): Array<any>;
  56330. baseLayer: XRWebGLLayer;
  56331. requestFrameOfReference(type: string): Promise<void>;
  56332. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56333. end(): Promise<void>;
  56334. requestAnimationFrame: Function;
  56335. addEventListener: Function;
  56336. }
  56337. interface XRSessionCreationOptions {
  56338. outputContext?: WebGLRenderingContext | null;
  56339. immersive?: boolean;
  56340. environmentIntegration?: boolean;
  56341. }
  56342. interface XRLayer {
  56343. getViewport: Function;
  56344. framebufferWidth: number;
  56345. framebufferHeight: number;
  56346. }
  56347. interface XRView {
  56348. projectionMatrix: Float32Array;
  56349. }
  56350. interface XRFrame {
  56351. getDevicePose: Function;
  56352. getInputPose: Function;
  56353. views: Array<XRView>;
  56354. baseLayer: XRLayer;
  56355. }
  56356. interface XRFrameOfReference {
  56357. }
  56358. interface XRWebGLLayer extends XRLayer {
  56359. framebuffer: WebGLFramebuffer;
  56360. }
  56361. declare var XRWebGLLayer: {
  56362. prototype: XRWebGLLayer;
  56363. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56364. };
  56365. declare module "babylonjs" {
  56366. export * from "babylonjs/Legacy/legacy";
  56367. }
  56368. declare module BABYLON {
  56369. /** Alias type for value that can be null */
  56370. export type Nullable<T> = T | null;
  56371. /**
  56372. * Alias type for number that are floats
  56373. * @ignorenaming
  56374. */
  56375. export type float = number;
  56376. /**
  56377. * Alias type for number that are doubles.
  56378. * @ignorenaming
  56379. */
  56380. export type double = number;
  56381. /**
  56382. * Alias type for number that are integer
  56383. * @ignorenaming
  56384. */
  56385. export type int = number;
  56386. /** Alias type for number array or Float32Array */
  56387. export type FloatArray = number[] | Float32Array;
  56388. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56389. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56390. /**
  56391. * Alias for types that can be used by a Buffer or VertexBuffer.
  56392. */
  56393. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56394. /**
  56395. * Alias type for primitive types
  56396. * @ignorenaming
  56397. */
  56398. type Primitive = undefined | null | boolean | string | number | Function;
  56399. /**
  56400. * Type modifier to make all the properties of an object Readonly
  56401. */
  56402. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56403. /**
  56404. * Type modifier to make all the properties of an object Readonly recursively
  56405. */
  56406. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56407. /** @hidden */
  56408. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56409. }
  56410. /** @hidden */
  56411. /** @hidden */
  56412. type DeepImmutableObject<T> = {
  56413. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56414. };
  56415. }
  56416. declare module BABYLON {
  56417. /**
  56418. * Class containing a set of static utilities functions for arrays.
  56419. */
  56420. export class ArrayTools {
  56421. /**
  56422. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56423. * @param size the number of element to construct and put in the array
  56424. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56425. * @returns a new array filled with new objects
  56426. */
  56427. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56428. }
  56429. }
  56430. declare module BABYLON {
  56431. /**
  56432. * Scalar computation library
  56433. */
  56434. export class Scalar {
  56435. /**
  56436. * Two pi constants convenient for computation.
  56437. */
  56438. static TwoPi: number;
  56439. /**
  56440. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56441. * @param a number
  56442. * @param b number
  56443. * @param epsilon (default = 1.401298E-45)
  56444. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56445. */
  56446. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56447. /**
  56448. * Returns a string : the upper case translation of the number i to hexadecimal.
  56449. * @param i number
  56450. * @returns the upper case translation of the number i to hexadecimal.
  56451. */
  56452. static ToHex(i: number): string;
  56453. /**
  56454. * Returns -1 if value is negative and +1 is value is positive.
  56455. * @param value the value
  56456. * @returns the value itself if it's equal to zero.
  56457. */
  56458. static Sign(value: number): number;
  56459. /**
  56460. * Returns the value itself if it's between min and max.
  56461. * Returns min if the value is lower than min.
  56462. * Returns max if the value is greater than max.
  56463. * @param value the value to clmap
  56464. * @param min the min value to clamp to (default: 0)
  56465. * @param max the max value to clamp to (default: 1)
  56466. * @returns the clamped value
  56467. */
  56468. static Clamp(value: number, min?: number, max?: number): number;
  56469. /**
  56470. * the log2 of value.
  56471. * @param value the value to compute log2 of
  56472. * @returns the log2 of value.
  56473. */
  56474. static Log2(value: number): number;
  56475. /**
  56476. * Loops the value, so that it is never larger than length and never smaller than 0.
  56477. *
  56478. * This is similar to the modulo operator but it works with floating point numbers.
  56479. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56480. * With t = 5 and length = 2.5, the result would be 0.0.
  56481. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56482. * @param value the value
  56483. * @param length the length
  56484. * @returns the looped value
  56485. */
  56486. static Repeat(value: number, length: number): number;
  56487. /**
  56488. * Normalize the value between 0.0 and 1.0 using min and max values
  56489. * @param value value to normalize
  56490. * @param min max to normalize between
  56491. * @param max min to normalize between
  56492. * @returns the normalized value
  56493. */
  56494. static Normalize(value: number, min: number, max: number): number;
  56495. /**
  56496. * Denormalize the value from 0.0 and 1.0 using min and max values
  56497. * @param normalized value to denormalize
  56498. * @param min max to denormalize between
  56499. * @param max min to denormalize between
  56500. * @returns the denormalized value
  56501. */
  56502. static Denormalize(normalized: number, min: number, max: number): number;
  56503. /**
  56504. * Calculates the shortest difference between two given angles given in degrees.
  56505. * @param current current angle in degrees
  56506. * @param target target angle in degrees
  56507. * @returns the delta
  56508. */
  56509. static DeltaAngle(current: number, target: number): number;
  56510. /**
  56511. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56512. * @param tx value
  56513. * @param length length
  56514. * @returns The returned value will move back and forth between 0 and length
  56515. */
  56516. static PingPong(tx: number, length: number): number;
  56517. /**
  56518. * Interpolates between min and max with smoothing at the limits.
  56519. *
  56520. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56521. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56522. * @param from from
  56523. * @param to to
  56524. * @param tx value
  56525. * @returns the smooth stepped value
  56526. */
  56527. static SmoothStep(from: number, to: number, tx: number): number;
  56528. /**
  56529. * Moves a value current towards target.
  56530. *
  56531. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56532. * Negative values of maxDelta pushes the value away from target.
  56533. * @param current current value
  56534. * @param target target value
  56535. * @param maxDelta max distance to move
  56536. * @returns resulting value
  56537. */
  56538. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56539. /**
  56540. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56541. *
  56542. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56543. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56544. * @param current current value
  56545. * @param target target value
  56546. * @param maxDelta max distance to move
  56547. * @returns resulting angle
  56548. */
  56549. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56550. /**
  56551. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56552. * @param start start value
  56553. * @param end target value
  56554. * @param amount amount to lerp between
  56555. * @returns the lerped value
  56556. */
  56557. static Lerp(start: number, end: number, amount: number): number;
  56558. /**
  56559. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56560. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56561. * @param start start value
  56562. * @param end target value
  56563. * @param amount amount to lerp between
  56564. * @returns the lerped value
  56565. */
  56566. static LerpAngle(start: number, end: number, amount: number): number;
  56567. /**
  56568. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56569. * @param a start value
  56570. * @param b target value
  56571. * @param value value between a and b
  56572. * @returns the inverseLerp value
  56573. */
  56574. static InverseLerp(a: number, b: number, value: number): number;
  56575. /**
  56576. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56577. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56578. * @param value1 spline value
  56579. * @param tangent1 spline value
  56580. * @param value2 spline value
  56581. * @param tangent2 spline value
  56582. * @param amount input value
  56583. * @returns hermite result
  56584. */
  56585. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56586. /**
  56587. * Returns a random float number between and min and max values
  56588. * @param min min value of random
  56589. * @param max max value of random
  56590. * @returns random value
  56591. */
  56592. static RandomRange(min: number, max: number): number;
  56593. /**
  56594. * This function returns percentage of a number in a given range.
  56595. *
  56596. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56597. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56598. * @param number to convert to percentage
  56599. * @param min min range
  56600. * @param max max range
  56601. * @returns the percentage
  56602. */
  56603. static RangeToPercent(number: number, min: number, max: number): number;
  56604. /**
  56605. * This function returns number that corresponds to the percentage in a given range.
  56606. *
  56607. * PercentToRange(0.34,0,100) will return 34.
  56608. * @param percent to convert to number
  56609. * @param min min range
  56610. * @param max max range
  56611. * @returns the number
  56612. */
  56613. static PercentToRange(percent: number, min: number, max: number): number;
  56614. /**
  56615. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56616. * @param angle The angle to normalize in radian.
  56617. * @return The converted angle.
  56618. */
  56619. static NormalizeRadians(angle: number): number;
  56620. }
  56621. }
  56622. declare module BABYLON {
  56623. /**
  56624. * Constant used to convert a value to gamma space
  56625. * @ignorenaming
  56626. */
  56627. export const ToGammaSpace: number;
  56628. /**
  56629. * Constant used to convert a value to linear space
  56630. * @ignorenaming
  56631. */
  56632. export const ToLinearSpace = 2.2;
  56633. /**
  56634. * Constant used to define the minimal number value in Babylon.js
  56635. * @ignorenaming
  56636. */
  56637. export const Epsilon = 0.001;
  56638. /**
  56639. * Class used to hold a RBG color
  56640. */
  56641. export class Color3 {
  56642. /**
  56643. * Defines the red component (between 0 and 1, default is 0)
  56644. */
  56645. r: number;
  56646. /**
  56647. * Defines the green component (between 0 and 1, default is 0)
  56648. */
  56649. g: number;
  56650. /**
  56651. * Defines the blue component (between 0 and 1, default is 0)
  56652. */
  56653. b: number;
  56654. /**
  56655. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56656. * @param r defines the red component (between 0 and 1, default is 0)
  56657. * @param g defines the green component (between 0 and 1, default is 0)
  56658. * @param b defines the blue component (between 0 and 1, default is 0)
  56659. */
  56660. constructor(
  56661. /**
  56662. * Defines the red component (between 0 and 1, default is 0)
  56663. */
  56664. r?: number,
  56665. /**
  56666. * Defines the green component (between 0 and 1, default is 0)
  56667. */
  56668. g?: number,
  56669. /**
  56670. * Defines the blue component (between 0 and 1, default is 0)
  56671. */
  56672. b?: number);
  56673. /**
  56674. * Creates a string with the Color3 current values
  56675. * @returns the string representation of the Color3 object
  56676. */
  56677. toString(): string;
  56678. /**
  56679. * Returns the string "Color3"
  56680. * @returns "Color3"
  56681. */
  56682. getClassName(): string;
  56683. /**
  56684. * Compute the Color3 hash code
  56685. * @returns an unique number that can be used to hash Color3 objects
  56686. */
  56687. getHashCode(): number;
  56688. /**
  56689. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56690. * @param array defines the array where to store the r,g,b components
  56691. * @param index defines an optional index in the target array to define where to start storing values
  56692. * @returns the current Color3 object
  56693. */
  56694. toArray(array: FloatArray, index?: number): Color3;
  56695. /**
  56696. * Returns a new Color4 object from the current Color3 and the given alpha
  56697. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56698. * @returns a new Color4 object
  56699. */
  56700. toColor4(alpha?: number): Color4;
  56701. /**
  56702. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56703. * @returns the new array
  56704. */
  56705. asArray(): number[];
  56706. /**
  56707. * Returns the luminance value
  56708. * @returns a float value
  56709. */
  56710. toLuminance(): number;
  56711. /**
  56712. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56713. * @param otherColor defines the second operand
  56714. * @returns the new Color3 object
  56715. */
  56716. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56717. /**
  56718. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56719. * @param otherColor defines the second operand
  56720. * @param result defines the Color3 object where to store the result
  56721. * @returns the current Color3
  56722. */
  56723. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56724. /**
  56725. * Determines equality between Color3 objects
  56726. * @param otherColor defines the second operand
  56727. * @returns true if the rgb values are equal to the given ones
  56728. */
  56729. equals(otherColor: DeepImmutable<Color3>): boolean;
  56730. /**
  56731. * Determines equality between the current Color3 object and a set of r,b,g values
  56732. * @param r defines the red component to check
  56733. * @param g defines the green component to check
  56734. * @param b defines the blue component to check
  56735. * @returns true if the rgb values are equal to the given ones
  56736. */
  56737. equalsFloats(r: number, g: number, b: number): boolean;
  56738. /**
  56739. * Multiplies in place each rgb value by scale
  56740. * @param scale defines the scaling factor
  56741. * @returns the updated Color3
  56742. */
  56743. scale(scale: number): Color3;
  56744. /**
  56745. * Multiplies the rgb values by scale and stores the result into "result"
  56746. * @param scale defines the scaling factor
  56747. * @param result defines the Color3 object where to store the result
  56748. * @returns the unmodified current Color3
  56749. */
  56750. scaleToRef(scale: number, result: Color3): Color3;
  56751. /**
  56752. * Scale the current Color3 values by a factor and add the result to a given Color3
  56753. * @param scale defines the scale factor
  56754. * @param result defines color to store the result into
  56755. * @returns the unmodified current Color3
  56756. */
  56757. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56758. /**
  56759. * Clamps the rgb values by the min and max values and stores the result into "result"
  56760. * @param min defines minimum clamping value (default is 0)
  56761. * @param max defines maximum clamping value (default is 1)
  56762. * @param result defines color to store the result into
  56763. * @returns the original Color3
  56764. */
  56765. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56766. /**
  56767. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56768. * @param otherColor defines the second operand
  56769. * @returns the new Color3
  56770. */
  56771. add(otherColor: DeepImmutable<Color3>): Color3;
  56772. /**
  56773. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56774. * @param otherColor defines the second operand
  56775. * @param result defines Color3 object to store the result into
  56776. * @returns the unmodified current Color3
  56777. */
  56778. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56779. /**
  56780. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56781. * @param otherColor defines the second operand
  56782. * @returns the new Color3
  56783. */
  56784. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56785. /**
  56786. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56787. * @param otherColor defines the second operand
  56788. * @param result defines Color3 object to store the result into
  56789. * @returns the unmodified current Color3
  56790. */
  56791. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56792. /**
  56793. * Copy the current object
  56794. * @returns a new Color3 copied the current one
  56795. */
  56796. clone(): Color3;
  56797. /**
  56798. * Copies the rgb values from the source in the current Color3
  56799. * @param source defines the source Color3 object
  56800. * @returns the updated Color3 object
  56801. */
  56802. copyFrom(source: DeepImmutable<Color3>): Color3;
  56803. /**
  56804. * Updates the Color3 rgb values from the given floats
  56805. * @param r defines the red component to read from
  56806. * @param g defines the green component to read from
  56807. * @param b defines the blue component to read from
  56808. * @returns the current Color3 object
  56809. */
  56810. copyFromFloats(r: number, g: number, b: number): Color3;
  56811. /**
  56812. * Updates the Color3 rgb values from the given floats
  56813. * @param r defines the red component to read from
  56814. * @param g defines the green component to read from
  56815. * @param b defines the blue component to read from
  56816. * @returns the current Color3 object
  56817. */
  56818. set(r: number, g: number, b: number): Color3;
  56819. /**
  56820. * Compute the Color3 hexadecimal code as a string
  56821. * @returns a string containing the hexadecimal representation of the Color3 object
  56822. */
  56823. toHexString(): string;
  56824. /**
  56825. * Computes a new Color3 converted from the current one to linear space
  56826. * @returns a new Color3 object
  56827. */
  56828. toLinearSpace(): Color3;
  56829. /**
  56830. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56831. * @param convertedColor defines the Color3 object where to store the linear space version
  56832. * @returns the unmodified Color3
  56833. */
  56834. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56835. /**
  56836. * Computes a new Color3 converted from the current one to gamma space
  56837. * @returns a new Color3 object
  56838. */
  56839. toGammaSpace(): Color3;
  56840. /**
  56841. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56842. * @param convertedColor defines the Color3 object where to store the gamma space version
  56843. * @returns the unmodified Color3
  56844. */
  56845. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56846. private static _BlackReadOnly;
  56847. /**
  56848. * Creates a new Color3 from the string containing valid hexadecimal values
  56849. * @param hex defines a string containing valid hexadecimal values
  56850. * @returns a new Color3 object
  56851. */
  56852. static FromHexString(hex: string): Color3;
  56853. /**
  56854. * Creates a new Vector3 from the starting index of the given array
  56855. * @param array defines the source array
  56856. * @param offset defines an offset in the source array
  56857. * @returns a new Color3 object
  56858. */
  56859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  56860. /**
  56861. * Creates a new Color3 from integer values (< 256)
  56862. * @param r defines the red component to read from (value between 0 and 255)
  56863. * @param g defines the green component to read from (value between 0 and 255)
  56864. * @param b defines the blue component to read from (value between 0 and 255)
  56865. * @returns a new Color3 object
  56866. */
  56867. static FromInts(r: number, g: number, b: number): Color3;
  56868. /**
  56869. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56870. * @param start defines the start Color3 value
  56871. * @param end defines the end Color3 value
  56872. * @param amount defines the gradient value between start and end
  56873. * @returns a new Color3 object
  56874. */
  56875. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  56876. /**
  56877. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56878. * @param left defines the start value
  56879. * @param right defines the end value
  56880. * @param amount defines the gradient factor
  56881. * @param result defines the Color3 object where to store the result
  56882. */
  56883. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  56884. /**
  56885. * Returns a Color3 value containing a red color
  56886. * @returns a new Color3 object
  56887. */
  56888. static Red(): Color3;
  56889. /**
  56890. * Returns a Color3 value containing a green color
  56891. * @returns a new Color3 object
  56892. */
  56893. static Green(): Color3;
  56894. /**
  56895. * Returns a Color3 value containing a blue color
  56896. * @returns a new Color3 object
  56897. */
  56898. static Blue(): Color3;
  56899. /**
  56900. * Returns a Color3 value containing a black color
  56901. * @returns a new Color3 object
  56902. */
  56903. static Black(): Color3;
  56904. /**
  56905. * Gets a Color3 value containing a black color that must not be updated
  56906. */
  56907. static readonly BlackReadOnly: DeepImmutable<Color3>;
  56908. /**
  56909. * Returns a Color3 value containing a white color
  56910. * @returns a new Color3 object
  56911. */
  56912. static White(): Color3;
  56913. /**
  56914. * Returns a Color3 value containing a purple color
  56915. * @returns a new Color3 object
  56916. */
  56917. static Purple(): Color3;
  56918. /**
  56919. * Returns a Color3 value containing a magenta color
  56920. * @returns a new Color3 object
  56921. */
  56922. static Magenta(): Color3;
  56923. /**
  56924. * Returns a Color3 value containing a yellow color
  56925. * @returns a new Color3 object
  56926. */
  56927. static Yellow(): Color3;
  56928. /**
  56929. * Returns a Color3 value containing a gray color
  56930. * @returns a new Color3 object
  56931. */
  56932. static Gray(): Color3;
  56933. /**
  56934. * Returns a Color3 value containing a teal color
  56935. * @returns a new Color3 object
  56936. */
  56937. static Teal(): Color3;
  56938. /**
  56939. * Returns a Color3 value containing a random color
  56940. * @returns a new Color3 object
  56941. */
  56942. static Random(): Color3;
  56943. }
  56944. /**
  56945. * Class used to hold a RBGA color
  56946. */
  56947. export class Color4 {
  56948. /**
  56949. * Defines the red component (between 0 and 1, default is 0)
  56950. */
  56951. r: number;
  56952. /**
  56953. * Defines the green component (between 0 and 1, default is 0)
  56954. */
  56955. g: number;
  56956. /**
  56957. * Defines the blue component (between 0 and 1, default is 0)
  56958. */
  56959. b: number;
  56960. /**
  56961. * Defines the alpha component (between 0 and 1, default is 1)
  56962. */
  56963. a: number;
  56964. /**
  56965. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  56966. * @param r defines the red component (between 0 and 1, default is 0)
  56967. * @param g defines the green component (between 0 and 1, default is 0)
  56968. * @param b defines the blue component (between 0 and 1, default is 0)
  56969. * @param a defines the alpha component (between 0 and 1, default is 1)
  56970. */
  56971. constructor(
  56972. /**
  56973. * Defines the red component (between 0 and 1, default is 0)
  56974. */
  56975. r?: number,
  56976. /**
  56977. * Defines the green component (between 0 and 1, default is 0)
  56978. */
  56979. g?: number,
  56980. /**
  56981. * Defines the blue component (between 0 and 1, default is 0)
  56982. */
  56983. b?: number,
  56984. /**
  56985. * Defines the alpha component (between 0 and 1, default is 1)
  56986. */
  56987. a?: number);
  56988. /**
  56989. * Adds in place the given Color4 values to the current Color4 object
  56990. * @param right defines the second operand
  56991. * @returns the current updated Color4 object
  56992. */
  56993. addInPlace(right: DeepImmutable<Color4>): Color4;
  56994. /**
  56995. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  56996. * @returns the new array
  56997. */
  56998. asArray(): number[];
  56999. /**
  57000. * Stores from the starting index in the given array the Color4 successive values
  57001. * @param array defines the array where to store the r,g,b components
  57002. * @param index defines an optional index in the target array to define where to start storing values
  57003. * @returns the current Color4 object
  57004. */
  57005. toArray(array: number[], index?: number): Color4;
  57006. /**
  57007. * Determines equality between Color4 objects
  57008. * @param otherColor defines the second operand
  57009. * @returns true if the rgba values are equal to the given ones
  57010. */
  57011. equals(otherColor: DeepImmutable<Color4>): boolean;
  57012. /**
  57013. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57014. * @param right defines the second operand
  57015. * @returns a new Color4 object
  57016. */
  57017. add(right: DeepImmutable<Color4>): Color4;
  57018. /**
  57019. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57020. * @param right defines the second operand
  57021. * @returns a new Color4 object
  57022. */
  57023. subtract(right: DeepImmutable<Color4>): Color4;
  57024. /**
  57025. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57026. * @param right defines the second operand
  57027. * @param result defines the Color4 object where to store the result
  57028. * @returns the current Color4 object
  57029. */
  57030. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57031. /**
  57032. * Creates a new Color4 with the current Color4 values multiplied by scale
  57033. * @param scale defines the scaling factor to apply
  57034. * @returns a new Color4 object
  57035. */
  57036. scale(scale: number): Color4;
  57037. /**
  57038. * Multiplies the current Color4 values by scale and stores the result in "result"
  57039. * @param scale defines the scaling factor to apply
  57040. * @param result defines the Color4 object where to store the result
  57041. * @returns the current unmodified Color4
  57042. */
  57043. scaleToRef(scale: number, result: Color4): Color4;
  57044. /**
  57045. * Scale the current Color4 values by a factor and add the result to a given Color4
  57046. * @param scale defines the scale factor
  57047. * @param result defines the Color4 object where to store the result
  57048. * @returns the unmodified current Color4
  57049. */
  57050. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57051. /**
  57052. * Clamps the rgb values by the min and max values and stores the result into "result"
  57053. * @param min defines minimum clamping value (default is 0)
  57054. * @param max defines maximum clamping value (default is 1)
  57055. * @param result defines color to store the result into.
  57056. * @returns the cuurent Color4
  57057. */
  57058. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57059. /**
  57060. * Multipy an Color4 value by another and return a new Color4 object
  57061. * @param color defines the Color4 value to multiply by
  57062. * @returns a new Color4 object
  57063. */
  57064. multiply(color: Color4): Color4;
  57065. /**
  57066. * Multipy a Color4 value by another and push the result in a reference value
  57067. * @param color defines the Color4 value to multiply by
  57068. * @param result defines the Color4 to fill the result in
  57069. * @returns the result Color4
  57070. */
  57071. multiplyToRef(color: Color4, result: Color4): Color4;
  57072. /**
  57073. * Creates a string with the Color4 current values
  57074. * @returns the string representation of the Color4 object
  57075. */
  57076. toString(): string;
  57077. /**
  57078. * Returns the string "Color4"
  57079. * @returns "Color4"
  57080. */
  57081. getClassName(): string;
  57082. /**
  57083. * Compute the Color4 hash code
  57084. * @returns an unique number that can be used to hash Color4 objects
  57085. */
  57086. getHashCode(): number;
  57087. /**
  57088. * Creates a new Color4 copied from the current one
  57089. * @returns a new Color4 object
  57090. */
  57091. clone(): Color4;
  57092. /**
  57093. * Copies the given Color4 values into the current one
  57094. * @param source defines the source Color4 object
  57095. * @returns the current updated Color4 object
  57096. */
  57097. copyFrom(source: Color4): Color4;
  57098. /**
  57099. * Copies the given float values into the current one
  57100. * @param r defines the red component to read from
  57101. * @param g defines the green component to read from
  57102. * @param b defines the blue component to read from
  57103. * @param a defines the alpha component to read from
  57104. * @returns the current updated Color4 object
  57105. */
  57106. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57107. /**
  57108. * Copies the given float values into the current one
  57109. * @param r defines the red component to read from
  57110. * @param g defines the green component to read from
  57111. * @param b defines the blue component to read from
  57112. * @param a defines the alpha component to read from
  57113. * @returns the current updated Color4 object
  57114. */
  57115. set(r: number, g: number, b: number, a: number): Color4;
  57116. /**
  57117. * Compute the Color4 hexadecimal code as a string
  57118. * @returns a string containing the hexadecimal representation of the Color4 object
  57119. */
  57120. toHexString(): string;
  57121. /**
  57122. * Computes a new Color4 converted from the current one to linear space
  57123. * @returns a new Color4 object
  57124. */
  57125. toLinearSpace(): Color4;
  57126. /**
  57127. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57128. * @param convertedColor defines the Color4 object where to store the linear space version
  57129. * @returns the unmodified Color4
  57130. */
  57131. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57132. /**
  57133. * Computes a new Color4 converted from the current one to gamma space
  57134. * @returns a new Color4 object
  57135. */
  57136. toGammaSpace(): Color4;
  57137. /**
  57138. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57139. * @param convertedColor defines the Color4 object where to store the gamma space version
  57140. * @returns the unmodified Color4
  57141. */
  57142. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57143. /**
  57144. * Creates a new Color4 from the string containing valid hexadecimal values
  57145. * @param hex defines a string containing valid hexadecimal values
  57146. * @returns a new Color4 object
  57147. */
  57148. static FromHexString(hex: string): Color4;
  57149. /**
  57150. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57151. * @param left defines the start value
  57152. * @param right defines the end value
  57153. * @param amount defines the gradient factor
  57154. * @returns a new Color4 object
  57155. */
  57156. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57157. /**
  57158. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57159. * @param left defines the start value
  57160. * @param right defines the end value
  57161. * @param amount defines the gradient factor
  57162. * @param result defines the Color4 object where to store data
  57163. */
  57164. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57165. /**
  57166. * Creates a new Color4 from a Color3 and an alpha value
  57167. * @param color3 defines the source Color3 to read from
  57168. * @param alpha defines the alpha component (1.0 by default)
  57169. * @returns a new Color4 object
  57170. */
  57171. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57172. /**
  57173. * Creates a new Color4 from the starting index element of the given array
  57174. * @param array defines the source array to read from
  57175. * @param offset defines the offset in the source array
  57176. * @returns a new Color4 object
  57177. */
  57178. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57179. /**
  57180. * Creates a new Color3 from integer values (< 256)
  57181. * @param r defines the red component to read from (value between 0 and 255)
  57182. * @param g defines the green component to read from (value between 0 and 255)
  57183. * @param b defines the blue component to read from (value between 0 and 255)
  57184. * @param a defines the alpha component to read from (value between 0 and 255)
  57185. * @returns a new Color3 object
  57186. */
  57187. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57188. /**
  57189. * Check the content of a given array and convert it to an array containing RGBA data
  57190. * If the original array was already containing count * 4 values then it is returned directly
  57191. * @param colors defines the array to check
  57192. * @param count defines the number of RGBA data to expect
  57193. * @returns an array containing count * 4 values (RGBA)
  57194. */
  57195. static CheckColors4(colors: number[], count: number): number[];
  57196. }
  57197. /**
  57198. * Class representing a vector containing 2 coordinates
  57199. */
  57200. export class Vector2 {
  57201. /** defines the first coordinate */
  57202. x: number;
  57203. /** defines the second coordinate */
  57204. y: number;
  57205. /**
  57206. * Creates a new Vector2 from the given x and y coordinates
  57207. * @param x defines the first coordinate
  57208. * @param y defines the second coordinate
  57209. */
  57210. constructor(
  57211. /** defines the first coordinate */
  57212. x?: number,
  57213. /** defines the second coordinate */
  57214. y?: number);
  57215. /**
  57216. * Gets a string with the Vector2 coordinates
  57217. * @returns a string with the Vector2 coordinates
  57218. */
  57219. toString(): string;
  57220. /**
  57221. * Gets class name
  57222. * @returns the string "Vector2"
  57223. */
  57224. getClassName(): string;
  57225. /**
  57226. * Gets current vector hash code
  57227. * @returns the Vector2 hash code as a number
  57228. */
  57229. getHashCode(): number;
  57230. /**
  57231. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57232. * @param array defines the source array
  57233. * @param index defines the offset in source array
  57234. * @returns the current Vector2
  57235. */
  57236. toArray(array: FloatArray, index?: number): Vector2;
  57237. /**
  57238. * Copy the current vector to an array
  57239. * @returns a new array with 2 elements: the Vector2 coordinates.
  57240. */
  57241. asArray(): number[];
  57242. /**
  57243. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57244. * @param source defines the source Vector2
  57245. * @returns the current updated Vector2
  57246. */
  57247. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57248. /**
  57249. * Sets the Vector2 coordinates with the given floats
  57250. * @param x defines the first coordinate
  57251. * @param y defines the second coordinate
  57252. * @returns the current updated Vector2
  57253. */
  57254. copyFromFloats(x: number, y: number): Vector2;
  57255. /**
  57256. * Sets the Vector2 coordinates with the given floats
  57257. * @param x defines the first coordinate
  57258. * @param y defines the second coordinate
  57259. * @returns the current updated Vector2
  57260. */
  57261. set(x: number, y: number): Vector2;
  57262. /**
  57263. * Add another vector with the current one
  57264. * @param otherVector defines the other vector
  57265. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57266. */
  57267. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57268. /**
  57269. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57270. * @param otherVector defines the other vector
  57271. * @param result defines the target vector
  57272. * @returns the unmodified current Vector2
  57273. */
  57274. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57275. /**
  57276. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57277. * @param otherVector defines the other vector
  57278. * @returns the current updated Vector2
  57279. */
  57280. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57281. /**
  57282. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57283. * @param otherVector defines the other vector
  57284. * @returns a new Vector2
  57285. */
  57286. addVector3(otherVector: Vector3): Vector2;
  57287. /**
  57288. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57289. * @param otherVector defines the other vector
  57290. * @returns a new Vector2
  57291. */
  57292. subtract(otherVector: Vector2): Vector2;
  57293. /**
  57294. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57295. * @param otherVector defines the other vector
  57296. * @param result defines the target vector
  57297. * @returns the unmodified current Vector2
  57298. */
  57299. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57300. /**
  57301. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57302. * @param otherVector defines the other vector
  57303. * @returns the current updated Vector2
  57304. */
  57305. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57306. /**
  57307. * Multiplies in place the current Vector2 coordinates by the given ones
  57308. * @param otherVector defines the other vector
  57309. * @returns the current updated Vector2
  57310. */
  57311. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57312. /**
  57313. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57314. * @param otherVector defines the other vector
  57315. * @returns a new Vector2
  57316. */
  57317. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57318. /**
  57319. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57320. * @param otherVector defines the other vector
  57321. * @param result defines the target vector
  57322. * @returns the unmodified current Vector2
  57323. */
  57324. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57325. /**
  57326. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57327. * @param x defines the first coordinate
  57328. * @param y defines the second coordinate
  57329. * @returns a new Vector2
  57330. */
  57331. multiplyByFloats(x: number, y: number): Vector2;
  57332. /**
  57333. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57334. * @param otherVector defines the other vector
  57335. * @returns a new Vector2
  57336. */
  57337. divide(otherVector: Vector2): Vector2;
  57338. /**
  57339. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57340. * @param otherVector defines the other vector
  57341. * @param result defines the target vector
  57342. * @returns the unmodified current Vector2
  57343. */
  57344. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57345. /**
  57346. * Divides the current Vector2 coordinates by the given ones
  57347. * @param otherVector defines the other vector
  57348. * @returns the current updated Vector2
  57349. */
  57350. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57351. /**
  57352. * Gets a new Vector2 with current Vector2 negated coordinates
  57353. * @returns a new Vector2
  57354. */
  57355. negate(): Vector2;
  57356. /**
  57357. * Multiply the Vector2 coordinates by scale
  57358. * @param scale defines the scaling factor
  57359. * @returns the current updated Vector2
  57360. */
  57361. scaleInPlace(scale: number): Vector2;
  57362. /**
  57363. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57364. * @param scale defines the scaling factor
  57365. * @returns a new Vector2
  57366. */
  57367. scale(scale: number): Vector2;
  57368. /**
  57369. * Scale the current Vector2 values by a factor to a given Vector2
  57370. * @param scale defines the scale factor
  57371. * @param result defines the Vector2 object where to store the result
  57372. * @returns the unmodified current Vector2
  57373. */
  57374. scaleToRef(scale: number, result: Vector2): Vector2;
  57375. /**
  57376. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57377. * @param scale defines the scale factor
  57378. * @param result defines the Vector2 object where to store the result
  57379. * @returns the unmodified current Vector2
  57380. */
  57381. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57382. /**
  57383. * Gets a boolean if two vectors are equals
  57384. * @param otherVector defines the other vector
  57385. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57386. */
  57387. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57388. /**
  57389. * Gets a boolean if two vectors are equals (using an epsilon value)
  57390. * @param otherVector defines the other vector
  57391. * @param epsilon defines the minimal distance to consider equality
  57392. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57393. */
  57394. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57395. /**
  57396. * Gets a new Vector2 from current Vector2 floored values
  57397. * @returns a new Vector2
  57398. */
  57399. floor(): Vector2;
  57400. /**
  57401. * Gets a new Vector2 from current Vector2 floored values
  57402. * @returns a new Vector2
  57403. */
  57404. fract(): Vector2;
  57405. /**
  57406. * Gets the length of the vector
  57407. * @returns the vector length (float)
  57408. */
  57409. length(): number;
  57410. /**
  57411. * Gets the vector squared length
  57412. * @returns the vector squared length (float)
  57413. */
  57414. lengthSquared(): number;
  57415. /**
  57416. * Normalize the vector
  57417. * @returns the current updated Vector2
  57418. */
  57419. normalize(): Vector2;
  57420. /**
  57421. * Gets a new Vector2 copied from the Vector2
  57422. * @returns a new Vector2
  57423. */
  57424. clone(): Vector2;
  57425. /**
  57426. * Gets a new Vector2(0, 0)
  57427. * @returns a new Vector2
  57428. */
  57429. static Zero(): Vector2;
  57430. /**
  57431. * Gets a new Vector2(1, 1)
  57432. * @returns a new Vector2
  57433. */
  57434. static One(): Vector2;
  57435. /**
  57436. * Gets a new Vector2 set from the given index element of the given array
  57437. * @param array defines the data source
  57438. * @param offset defines the offset in the data source
  57439. * @returns a new Vector2
  57440. */
  57441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57442. /**
  57443. * Sets "result" from the given index element of the given array
  57444. * @param array defines the data source
  57445. * @param offset defines the offset in the data source
  57446. * @param result defines the target vector
  57447. */
  57448. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57449. /**
  57450. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57451. * @param value1 defines 1st point of control
  57452. * @param value2 defines 2nd point of control
  57453. * @param value3 defines 3rd point of control
  57454. * @param value4 defines 4th point of control
  57455. * @param amount defines the interpolation factor
  57456. * @returns a new Vector2
  57457. */
  57458. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57459. /**
  57460. * 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".
  57461. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57462. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57463. * @param value defines the value to clamp
  57464. * @param min defines the lower limit
  57465. * @param max defines the upper limit
  57466. * @returns a new Vector2
  57467. */
  57468. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57469. /**
  57470. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57471. * @param value1 defines the 1st control point
  57472. * @param tangent1 defines the outgoing tangent
  57473. * @param value2 defines the 2nd control point
  57474. * @param tangent2 defines the incoming tangent
  57475. * @param amount defines the interpolation factor
  57476. * @returns a new Vector2
  57477. */
  57478. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57479. /**
  57480. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57481. * @param start defines the start vector
  57482. * @param end defines the end vector
  57483. * @param amount defines the interpolation factor
  57484. * @returns a new Vector2
  57485. */
  57486. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57487. /**
  57488. * Gets the dot product of the vector "left" and the vector "right"
  57489. * @param left defines first vector
  57490. * @param right defines second vector
  57491. * @returns the dot product (float)
  57492. */
  57493. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57494. /**
  57495. * Returns a new Vector2 equal to the normalized given vector
  57496. * @param vector defines the vector to normalize
  57497. * @returns a new Vector2
  57498. */
  57499. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57500. /**
  57501. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57502. * @param left defines 1st vector
  57503. * @param right defines 2nd vector
  57504. * @returns a new Vector2
  57505. */
  57506. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57507. /**
  57508. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57509. * @param left defines 1st vector
  57510. * @param right defines 2nd vector
  57511. * @returns a new Vector2
  57512. */
  57513. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57514. /**
  57515. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57516. * @param vector defines the vector to transform
  57517. * @param transformation defines the matrix to apply
  57518. * @returns a new Vector2
  57519. */
  57520. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57521. /**
  57522. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57523. * @param vector defines the vector to transform
  57524. * @param transformation defines the matrix to apply
  57525. * @param result defines the target vector
  57526. */
  57527. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57528. /**
  57529. * Determines if a given vector is included in a triangle
  57530. * @param p defines the vector to test
  57531. * @param p0 defines 1st triangle point
  57532. * @param p1 defines 2nd triangle point
  57533. * @param p2 defines 3rd triangle point
  57534. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57535. */
  57536. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57537. /**
  57538. * Gets the distance between the vectors "value1" and "value2"
  57539. * @param value1 defines first vector
  57540. * @param value2 defines second vector
  57541. * @returns the distance between vectors
  57542. */
  57543. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57544. /**
  57545. * Returns the squared distance between the vectors "value1" and "value2"
  57546. * @param value1 defines first vector
  57547. * @param value2 defines second vector
  57548. * @returns the squared distance between vectors
  57549. */
  57550. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57551. /**
  57552. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57553. * @param value1 defines first vector
  57554. * @param value2 defines second vector
  57555. * @returns a new Vector2
  57556. */
  57557. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57558. /**
  57559. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57560. * @param p defines the middle point
  57561. * @param segA defines one point of the segment
  57562. * @param segB defines the other point of the segment
  57563. * @returns the shortest distance
  57564. */
  57565. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57566. }
  57567. /**
  57568. * Classed used to store (x,y,z) vector representation
  57569. * A Vector3 is the main object used in 3D geometry
  57570. * It can represent etiher the coordinates of a point the space, either a direction
  57571. * Reminder: js uses a left handed forward facing system
  57572. */
  57573. export class Vector3 {
  57574. /**
  57575. * Defines the first coordinates (on X axis)
  57576. */
  57577. x: number;
  57578. /**
  57579. * Defines the second coordinates (on Y axis)
  57580. */
  57581. y: number;
  57582. /**
  57583. * Defines the third coordinates (on Z axis)
  57584. */
  57585. z: number;
  57586. private static _UpReadOnly;
  57587. /**
  57588. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57589. * @param x defines the first coordinates (on X axis)
  57590. * @param y defines the second coordinates (on Y axis)
  57591. * @param z defines the third coordinates (on Z axis)
  57592. */
  57593. constructor(
  57594. /**
  57595. * Defines the first coordinates (on X axis)
  57596. */
  57597. x?: number,
  57598. /**
  57599. * Defines the second coordinates (on Y axis)
  57600. */
  57601. y?: number,
  57602. /**
  57603. * Defines the third coordinates (on Z axis)
  57604. */
  57605. z?: number);
  57606. /**
  57607. * Creates a string representation of the Vector3
  57608. * @returns a string with the Vector3 coordinates.
  57609. */
  57610. toString(): string;
  57611. /**
  57612. * Gets the class name
  57613. * @returns the string "Vector3"
  57614. */
  57615. getClassName(): string;
  57616. /**
  57617. * Creates the Vector3 hash code
  57618. * @returns a number which tends to be unique between Vector3 instances
  57619. */
  57620. getHashCode(): number;
  57621. /**
  57622. * Creates an array containing three elements : the coordinates of the Vector3
  57623. * @returns a new array of numbers
  57624. */
  57625. asArray(): number[];
  57626. /**
  57627. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57628. * @param array defines the destination array
  57629. * @param index defines the offset in the destination array
  57630. * @returns the current Vector3
  57631. */
  57632. toArray(array: FloatArray, index?: number): Vector3;
  57633. /**
  57634. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57635. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57636. */
  57637. toQuaternion(): Quaternion;
  57638. /**
  57639. * Adds the given vector to the current Vector3
  57640. * @param otherVector defines the second operand
  57641. * @returns the current updated Vector3
  57642. */
  57643. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57644. /**
  57645. * Adds the given coordinates to the current Vector3
  57646. * @param x defines the x coordinate of the operand
  57647. * @param y defines the y coordinate of the operand
  57648. * @param z defines the z coordinate of the operand
  57649. * @returns the current updated Vector3
  57650. */
  57651. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57652. /**
  57653. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57654. * @param otherVector defines the second operand
  57655. * @returns the resulting Vector3
  57656. */
  57657. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57658. /**
  57659. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57660. * @param otherVector defines the second operand
  57661. * @param result defines the Vector3 object where to store the result
  57662. * @returns the current Vector3
  57663. */
  57664. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57665. /**
  57666. * Subtract the given vector from the current Vector3
  57667. * @param otherVector defines the second operand
  57668. * @returns the current updated Vector3
  57669. */
  57670. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57671. /**
  57672. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57673. * @param otherVector defines the second operand
  57674. * @returns the resulting Vector3
  57675. */
  57676. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57677. /**
  57678. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57679. * @param otherVector defines the second operand
  57680. * @param result defines the Vector3 object where to store the result
  57681. * @returns the current Vector3
  57682. */
  57683. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57684. /**
  57685. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57686. * @param x defines the x coordinate of the operand
  57687. * @param y defines the y coordinate of the operand
  57688. * @param z defines the z coordinate of the operand
  57689. * @returns the resulting Vector3
  57690. */
  57691. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57692. /**
  57693. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57694. * @param x defines the x coordinate of the operand
  57695. * @param y defines the y coordinate of the operand
  57696. * @param z defines the z coordinate of the operand
  57697. * @param result defines the Vector3 object where to store the result
  57698. * @returns the current Vector3
  57699. */
  57700. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57701. /**
  57702. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57703. * @returns a new Vector3
  57704. */
  57705. negate(): Vector3;
  57706. /**
  57707. * Multiplies the Vector3 coordinates by the float "scale"
  57708. * @param scale defines the multiplier factor
  57709. * @returns the current updated Vector3
  57710. */
  57711. scaleInPlace(scale: number): Vector3;
  57712. /**
  57713. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57714. * @param scale defines the multiplier factor
  57715. * @returns a new Vector3
  57716. */
  57717. scale(scale: number): Vector3;
  57718. /**
  57719. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57720. * @param scale defines the multiplier factor
  57721. * @param result defines the Vector3 object where to store the result
  57722. * @returns the current Vector3
  57723. */
  57724. scaleToRef(scale: number, result: Vector3): Vector3;
  57725. /**
  57726. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57727. * @param scale defines the scale factor
  57728. * @param result defines the Vector3 object where to store the result
  57729. * @returns the unmodified current Vector3
  57730. */
  57731. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57732. /**
  57733. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57734. * @param otherVector defines the second operand
  57735. * @returns true if both vectors are equals
  57736. */
  57737. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57738. /**
  57739. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57740. * @param otherVector defines the second operand
  57741. * @param epsilon defines the minimal distance to define values as equals
  57742. * @returns true if both vectors are distant less than epsilon
  57743. */
  57744. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57745. /**
  57746. * Returns true if the current Vector3 coordinates equals the given floats
  57747. * @param x defines the x coordinate of the operand
  57748. * @param y defines the y coordinate of the operand
  57749. * @param z defines the z coordinate of the operand
  57750. * @returns true if both vectors are equals
  57751. */
  57752. equalsToFloats(x: number, y: number, z: number): boolean;
  57753. /**
  57754. * Multiplies the current Vector3 coordinates by the given ones
  57755. * @param otherVector defines the second operand
  57756. * @returns the current updated Vector3
  57757. */
  57758. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57759. /**
  57760. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57761. * @param otherVector defines the second operand
  57762. * @returns the new Vector3
  57763. */
  57764. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57765. /**
  57766. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57767. * @param otherVector defines the second operand
  57768. * @param result defines the Vector3 object where to store the result
  57769. * @returns the current Vector3
  57770. */
  57771. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57772. /**
  57773. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57774. * @param x defines the x coordinate of the operand
  57775. * @param y defines the y coordinate of the operand
  57776. * @param z defines the z coordinate of the operand
  57777. * @returns the new Vector3
  57778. */
  57779. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57780. /**
  57781. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57782. * @param otherVector defines the second operand
  57783. * @returns the new Vector3
  57784. */
  57785. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57786. /**
  57787. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57788. * @param otherVector defines the second operand
  57789. * @param result defines the Vector3 object where to store the result
  57790. * @returns the current Vector3
  57791. */
  57792. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57793. /**
  57794. * Divides the current Vector3 coordinates by the given ones.
  57795. * @param otherVector defines the second operand
  57796. * @returns the current updated Vector3
  57797. */
  57798. divideInPlace(otherVector: Vector3): Vector3;
  57799. /**
  57800. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57801. * @param other defines the second operand
  57802. * @returns the current updated Vector3
  57803. */
  57804. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57805. /**
  57806. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57807. * @param other defines the second operand
  57808. * @returns the current updated Vector3
  57809. */
  57810. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57811. /**
  57812. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57813. * @param x defines the x coordinate of the operand
  57814. * @param y defines the y coordinate of the operand
  57815. * @param z defines the z coordinate of the operand
  57816. * @returns the current updated Vector3
  57817. */
  57818. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57819. /**
  57820. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57821. * @param x defines the x coordinate of the operand
  57822. * @param y defines the y coordinate of the operand
  57823. * @param z defines the z coordinate of the operand
  57824. * @returns the current updated Vector3
  57825. */
  57826. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57827. /**
  57828. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57829. * Check if is non uniform within a certain amount of decimal places to account for this
  57830. * @param epsilon the amount the values can differ
  57831. * @returns if the the vector is non uniform to a certain number of decimal places
  57832. */
  57833. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57834. /**
  57835. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57836. */
  57837. readonly isNonUniform: boolean;
  57838. /**
  57839. * Gets a new Vector3 from current Vector3 floored values
  57840. * @returns a new Vector3
  57841. */
  57842. floor(): Vector3;
  57843. /**
  57844. * Gets a new Vector3 from current Vector3 floored values
  57845. * @returns a new Vector3
  57846. */
  57847. fract(): Vector3;
  57848. /**
  57849. * Gets the length of the Vector3
  57850. * @returns the length of the Vecto3
  57851. */
  57852. length(): number;
  57853. /**
  57854. * Gets the squared length of the Vector3
  57855. * @returns squared length of the Vector3
  57856. */
  57857. lengthSquared(): number;
  57858. /**
  57859. * Normalize the current Vector3.
  57860. * Please note that this is an in place operation.
  57861. * @returns the current updated Vector3
  57862. */
  57863. normalize(): Vector3;
  57864. /**
  57865. * Reorders the x y z properties of the vector in place
  57866. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  57867. * @returns the current updated vector
  57868. */
  57869. reorderInPlace(order: string): this;
  57870. /**
  57871. * Rotates the vector around 0,0,0 by a quaternion
  57872. * @param quaternion the rotation quaternion
  57873. * @param result vector to store the result
  57874. * @returns the resulting vector
  57875. */
  57876. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  57877. /**
  57878. * Rotates a vector around a given point
  57879. * @param quaternion the rotation quaternion
  57880. * @param point the point to rotate around
  57881. * @param result vector to store the result
  57882. * @returns the resulting vector
  57883. */
  57884. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  57885. /**
  57886. * Normalize the current Vector3 with the given input length.
  57887. * Please note that this is an in place operation.
  57888. * @param len the length of the vector
  57889. * @returns the current updated Vector3
  57890. */
  57891. normalizeFromLength(len: number): Vector3;
  57892. /**
  57893. * Normalize the current Vector3 to a new vector
  57894. * @returns the new Vector3
  57895. */
  57896. normalizeToNew(): Vector3;
  57897. /**
  57898. * Normalize the current Vector3 to the reference
  57899. * @param reference define the Vector3 to update
  57900. * @returns the updated Vector3
  57901. */
  57902. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  57903. /**
  57904. * Creates a new Vector3 copied from the current Vector3
  57905. * @returns the new Vector3
  57906. */
  57907. clone(): Vector3;
  57908. /**
  57909. * Copies the given vector coordinates to the current Vector3 ones
  57910. * @param source defines the source Vector3
  57911. * @returns the current updated Vector3
  57912. */
  57913. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  57914. /**
  57915. * Copies the given floats to the current Vector3 coordinates
  57916. * @param x defines the x coordinate of the operand
  57917. * @param y defines the y coordinate of the operand
  57918. * @param z defines the z coordinate of the operand
  57919. * @returns the current updated Vector3
  57920. */
  57921. copyFromFloats(x: number, y: number, z: number): Vector3;
  57922. /**
  57923. * Copies the given floats to the current Vector3 coordinates
  57924. * @param x defines the x coordinate of the operand
  57925. * @param y defines the y coordinate of the operand
  57926. * @param z defines the z coordinate of the operand
  57927. * @returns the current updated Vector3
  57928. */
  57929. set(x: number, y: number, z: number): Vector3;
  57930. /**
  57931. * Copies the given float to the current Vector3 coordinates
  57932. * @param v defines the x, y and z coordinates of the operand
  57933. * @returns the current updated Vector3
  57934. */
  57935. setAll(v: number): Vector3;
  57936. /**
  57937. * Get the clip factor between two vectors
  57938. * @param vector0 defines the first operand
  57939. * @param vector1 defines the second operand
  57940. * @param axis defines the axis to use
  57941. * @param size defines the size along the axis
  57942. * @returns the clip factor
  57943. */
  57944. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  57945. /**
  57946. * Get angle between two vectors
  57947. * @param vector0 angle between vector0 and vector1
  57948. * @param vector1 angle between vector0 and vector1
  57949. * @param normal direction of the normal
  57950. * @return the angle between vector0 and vector1
  57951. */
  57952. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  57953. /**
  57954. * Returns a new Vector3 set from the index "offset" of the given array
  57955. * @param array defines the source array
  57956. * @param offset defines the offset in the source array
  57957. * @returns the new Vector3
  57958. */
  57959. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  57960. /**
  57961. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  57962. * This function is deprecated. Use FromArray instead
  57963. * @param array defines the source array
  57964. * @param offset defines the offset in the source array
  57965. * @returns the new Vector3
  57966. */
  57967. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  57968. /**
  57969. * Sets the given vector "result" with the element values from the index "offset" of the given array
  57970. * @param array defines the source array
  57971. * @param offset defines the offset in the source array
  57972. * @param result defines the Vector3 where to store the result
  57973. */
  57974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  57975. /**
  57976. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  57977. * This function is deprecated. Use FromArrayToRef instead.
  57978. * @param array defines the source array
  57979. * @param offset defines the offset in the source array
  57980. * @param result defines the Vector3 where to store the result
  57981. */
  57982. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  57983. /**
  57984. * Sets the given vector "result" with the given floats.
  57985. * @param x defines the x coordinate of the source
  57986. * @param y defines the y coordinate of the source
  57987. * @param z defines the z coordinate of the source
  57988. * @param result defines the Vector3 where to store the result
  57989. */
  57990. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  57991. /**
  57992. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  57993. * @returns a new empty Vector3
  57994. */
  57995. static Zero(): Vector3;
  57996. /**
  57997. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  57998. * @returns a new unit Vector3
  57999. */
  58000. static One(): Vector3;
  58001. /**
  58002. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58003. * @returns a new up Vector3
  58004. */
  58005. static Up(): Vector3;
  58006. /**
  58007. * Gets a up Vector3 that must not be updated
  58008. */
  58009. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58010. /**
  58011. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58012. * @returns a new down Vector3
  58013. */
  58014. static Down(): Vector3;
  58015. /**
  58016. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58017. * @returns a new forward Vector3
  58018. */
  58019. static Forward(): Vector3;
  58020. /**
  58021. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58022. * @returns a new forward Vector3
  58023. */
  58024. static Backward(): Vector3;
  58025. /**
  58026. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58027. * @returns a new right Vector3
  58028. */
  58029. static Right(): Vector3;
  58030. /**
  58031. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58032. * @returns a new left Vector3
  58033. */
  58034. static Left(): Vector3;
  58035. /**
  58036. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58037. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58038. * @param vector defines the Vector3 to transform
  58039. * @param transformation defines the transformation matrix
  58040. * @returns the transformed Vector3
  58041. */
  58042. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58043. /**
  58044. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58045. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58046. * @param vector defines the Vector3 to transform
  58047. * @param transformation defines the transformation matrix
  58048. * @param result defines the Vector3 where to store the result
  58049. */
  58050. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58051. /**
  58052. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58053. * This method computes tranformed coordinates only, not transformed direction vectors
  58054. * @param x define the x coordinate of the source vector
  58055. * @param y define the y coordinate of the source vector
  58056. * @param z define the z coordinate of the source vector
  58057. * @param transformation defines the transformation matrix
  58058. * @param result defines the Vector3 where to store the result
  58059. */
  58060. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58061. /**
  58062. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58064. * @param vector defines the Vector3 to transform
  58065. * @param transformation defines the transformation matrix
  58066. * @returns the new Vector3
  58067. */
  58068. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58069. /**
  58070. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58071. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58072. * @param vector defines the Vector3 to transform
  58073. * @param transformation defines the transformation matrix
  58074. * @param result defines the Vector3 where to store the result
  58075. */
  58076. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58077. /**
  58078. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58079. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58080. * @param x define the x coordinate of the source vector
  58081. * @param y define the y coordinate of the source vector
  58082. * @param z define the z coordinate of the source vector
  58083. * @param transformation defines the transformation matrix
  58084. * @param result defines the Vector3 where to store the result
  58085. */
  58086. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58087. /**
  58088. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58089. * @param value1 defines the first control point
  58090. * @param value2 defines the second control point
  58091. * @param value3 defines the third control point
  58092. * @param value4 defines the fourth control point
  58093. * @param amount defines the amount on the spline to use
  58094. * @returns the new Vector3
  58095. */
  58096. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58097. /**
  58098. * 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"
  58099. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58100. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58101. * @param value defines the current value
  58102. * @param min defines the lower range value
  58103. * @param max defines the upper range value
  58104. * @returns the new Vector3
  58105. */
  58106. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58107. /**
  58108. * 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"
  58109. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58110. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58111. * @param value defines the current value
  58112. * @param min defines the lower range value
  58113. * @param max defines the upper range value
  58114. * @param result defines the Vector3 where to store the result
  58115. */
  58116. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58117. /**
  58118. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58119. * @param value1 defines the first control point
  58120. * @param tangent1 defines the first tangent vector
  58121. * @param value2 defines the second control point
  58122. * @param tangent2 defines the second tangent vector
  58123. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58124. * @returns the new Vector3
  58125. */
  58126. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58127. /**
  58128. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58129. * @param start defines the start value
  58130. * @param end defines the end value
  58131. * @param amount max defines amount between both (between 0 and 1)
  58132. * @returns the new Vector3
  58133. */
  58134. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58135. /**
  58136. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58137. * @param start defines the start value
  58138. * @param end defines the end value
  58139. * @param amount max defines amount between both (between 0 and 1)
  58140. * @param result defines the Vector3 where to store the result
  58141. */
  58142. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58143. /**
  58144. * Returns the dot product (float) between the vectors "left" and "right"
  58145. * @param left defines the left operand
  58146. * @param right defines the right operand
  58147. * @returns the dot product
  58148. */
  58149. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58150. /**
  58151. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58152. * The cross product is then orthogonal to both "left" and "right"
  58153. * @param left defines the left operand
  58154. * @param right defines the right operand
  58155. * @returns the cross product
  58156. */
  58157. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58158. /**
  58159. * Sets the given vector "result" with the cross product of "left" and "right"
  58160. * The cross product is then orthogonal to both "left" and "right"
  58161. * @param left defines the left operand
  58162. * @param right defines the right operand
  58163. * @param result defines the Vector3 where to store the result
  58164. */
  58165. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58166. /**
  58167. * Returns a new Vector3 as the normalization of the given vector
  58168. * @param vector defines the Vector3 to normalize
  58169. * @returns the new Vector3
  58170. */
  58171. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58172. /**
  58173. * Sets the given vector "result" with the normalization of the given first vector
  58174. * @param vector defines the Vector3 to normalize
  58175. * @param result defines the Vector3 where to store the result
  58176. */
  58177. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58178. /**
  58179. * Project a Vector3 onto screen space
  58180. * @param vector defines the Vector3 to project
  58181. * @param world defines the world matrix to use
  58182. * @param transform defines the transform (view x projection) matrix to use
  58183. * @param viewport defines the screen viewport to use
  58184. * @returns the new Vector3
  58185. */
  58186. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58187. /** @hidden */
  58188. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58189. /**
  58190. * Unproject from screen space to object space
  58191. * @param source defines the screen space Vector3 to use
  58192. * @param viewportWidth defines the current width of the viewport
  58193. * @param viewportHeight defines the current height of the viewport
  58194. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58195. * @param transform defines the transform (view x projection) matrix to use
  58196. * @returns the new Vector3
  58197. */
  58198. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58199. /**
  58200. * Unproject from screen space to object space
  58201. * @param source defines the screen space Vector3 to use
  58202. * @param viewportWidth defines the current width of the viewport
  58203. * @param viewportHeight defines the current height of the viewport
  58204. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58205. * @param view defines the view matrix to use
  58206. * @param projection defines the projection matrix to use
  58207. * @returns the new Vector3
  58208. */
  58209. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58210. /**
  58211. * Unproject from screen space to object space
  58212. * @param source defines the screen space Vector3 to use
  58213. * @param viewportWidth defines the current width of the viewport
  58214. * @param viewportHeight defines the current height of the viewport
  58215. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58216. * @param view defines the view matrix to use
  58217. * @param projection defines the projection matrix to use
  58218. * @param result defines the Vector3 where to store the result
  58219. */
  58220. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58221. /**
  58222. * Unproject from screen space to object space
  58223. * @param sourceX defines the screen space x coordinate to use
  58224. * @param sourceY defines the screen space y coordinate to use
  58225. * @param sourceZ defines the screen space z coordinate to use
  58226. * @param viewportWidth defines the current width of the viewport
  58227. * @param viewportHeight defines the current height of the viewport
  58228. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58229. * @param view defines the view matrix to use
  58230. * @param projection defines the projection matrix to use
  58231. * @param result defines the Vector3 where to store the result
  58232. */
  58233. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58234. /**
  58235. * Gets the minimal coordinate values between two Vector3
  58236. * @param left defines the first operand
  58237. * @param right defines the second operand
  58238. * @returns the new Vector3
  58239. */
  58240. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58241. /**
  58242. * Gets the maximal coordinate values between two Vector3
  58243. * @param left defines the first operand
  58244. * @param right defines the second operand
  58245. * @returns the new Vector3
  58246. */
  58247. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58248. /**
  58249. * Returns the distance between the vectors "value1" and "value2"
  58250. * @param value1 defines the first operand
  58251. * @param value2 defines the second operand
  58252. * @returns the distance
  58253. */
  58254. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58255. /**
  58256. * Returns the squared distance between the vectors "value1" and "value2"
  58257. * @param value1 defines the first operand
  58258. * @param value2 defines the second operand
  58259. * @returns the squared distance
  58260. */
  58261. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58262. /**
  58263. * Returns a new Vector3 located at the center between "value1" and "value2"
  58264. * @param value1 defines the first operand
  58265. * @param value2 defines the second operand
  58266. * @returns the new Vector3
  58267. */
  58268. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58269. /**
  58270. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58271. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58272. * to something in order to rotate it from its local system to the given target system
  58273. * Note: axis1, axis2 and axis3 are normalized during this operation
  58274. * @param axis1 defines the first axis
  58275. * @param axis2 defines the second axis
  58276. * @param axis3 defines the third axis
  58277. * @returns a new Vector3
  58278. */
  58279. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58280. /**
  58281. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58282. * @param axis1 defines the first axis
  58283. * @param axis2 defines the second axis
  58284. * @param axis3 defines the third axis
  58285. * @param ref defines the Vector3 where to store the result
  58286. */
  58287. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58288. }
  58289. /**
  58290. * Vector4 class created for EulerAngle class conversion to Quaternion
  58291. */
  58292. export class Vector4 {
  58293. /** x value of the vector */
  58294. x: number;
  58295. /** y value of the vector */
  58296. y: number;
  58297. /** z value of the vector */
  58298. z: number;
  58299. /** w value of the vector */
  58300. w: number;
  58301. /**
  58302. * Creates a Vector4 object from the given floats.
  58303. * @param x x value of the vector
  58304. * @param y y value of the vector
  58305. * @param z z value of the vector
  58306. * @param w w value of the vector
  58307. */
  58308. constructor(
  58309. /** x value of the vector */
  58310. x: number,
  58311. /** y value of the vector */
  58312. y: number,
  58313. /** z value of the vector */
  58314. z: number,
  58315. /** w value of the vector */
  58316. w: number);
  58317. /**
  58318. * Returns the string with the Vector4 coordinates.
  58319. * @returns a string containing all the vector values
  58320. */
  58321. toString(): string;
  58322. /**
  58323. * Returns the string "Vector4".
  58324. * @returns "Vector4"
  58325. */
  58326. getClassName(): string;
  58327. /**
  58328. * Returns the Vector4 hash code.
  58329. * @returns a unique hash code
  58330. */
  58331. getHashCode(): number;
  58332. /**
  58333. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58334. * @returns the resulting array
  58335. */
  58336. asArray(): number[];
  58337. /**
  58338. * Populates the given array from the given index with the Vector4 coordinates.
  58339. * @param array array to populate
  58340. * @param index index of the array to start at (default: 0)
  58341. * @returns the Vector4.
  58342. */
  58343. toArray(array: FloatArray, index?: number): Vector4;
  58344. /**
  58345. * Adds the given vector to the current Vector4.
  58346. * @param otherVector the vector to add
  58347. * @returns the updated Vector4.
  58348. */
  58349. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58350. /**
  58351. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58352. * @param otherVector the vector to add
  58353. * @returns the resulting vector
  58354. */
  58355. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58356. /**
  58357. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58358. * @param otherVector the vector to add
  58359. * @param result the vector to store the result
  58360. * @returns the current Vector4.
  58361. */
  58362. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58363. /**
  58364. * Subtract in place the given vector from the current Vector4.
  58365. * @param otherVector the vector to subtract
  58366. * @returns the updated Vector4.
  58367. */
  58368. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58369. /**
  58370. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58371. * @param otherVector the vector to add
  58372. * @returns the new vector with the result
  58373. */
  58374. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58375. /**
  58376. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58377. * @param otherVector the vector to subtract
  58378. * @param result the vector to store the result
  58379. * @returns the current Vector4.
  58380. */
  58381. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58382. /**
  58383. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58384. */
  58385. /**
  58386. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58387. * @param x value to subtract
  58388. * @param y value to subtract
  58389. * @param z value to subtract
  58390. * @param w value to subtract
  58391. * @returns new vector containing the result
  58392. */
  58393. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58394. /**
  58395. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58396. * @param x value to subtract
  58397. * @param y value to subtract
  58398. * @param z value to subtract
  58399. * @param w value to subtract
  58400. * @param result the vector to store the result in
  58401. * @returns the current Vector4.
  58402. */
  58403. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58404. /**
  58405. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58406. * @returns a new vector with the negated values
  58407. */
  58408. negate(): Vector4;
  58409. /**
  58410. * Multiplies the current Vector4 coordinates by scale (float).
  58411. * @param scale the number to scale with
  58412. * @returns the updated Vector4.
  58413. */
  58414. scaleInPlace(scale: number): Vector4;
  58415. /**
  58416. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58417. * @param scale the number to scale with
  58418. * @returns a new vector with the result
  58419. */
  58420. scale(scale: number): Vector4;
  58421. /**
  58422. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58423. * @param scale the number to scale with
  58424. * @param result a vector to store the result in
  58425. * @returns the current Vector4.
  58426. */
  58427. scaleToRef(scale: number, result: Vector4): Vector4;
  58428. /**
  58429. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58430. * @param scale defines the scale factor
  58431. * @param result defines the Vector4 object where to store the result
  58432. * @returns the unmodified current Vector4
  58433. */
  58434. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58435. /**
  58436. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58437. * @param otherVector the vector to compare against
  58438. * @returns true if they are equal
  58439. */
  58440. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58441. /**
  58442. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58443. * @param otherVector vector to compare against
  58444. * @param epsilon (Default: very small number)
  58445. * @returns true if they are equal
  58446. */
  58447. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58448. /**
  58449. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58450. * @param x x value to compare against
  58451. * @param y y value to compare against
  58452. * @param z z value to compare against
  58453. * @param w w value to compare against
  58454. * @returns true if equal
  58455. */
  58456. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58457. /**
  58458. * Multiplies in place the current Vector4 by the given one.
  58459. * @param otherVector vector to multiple with
  58460. * @returns the updated Vector4.
  58461. */
  58462. multiplyInPlace(otherVector: Vector4): Vector4;
  58463. /**
  58464. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58465. * @param otherVector vector to multiple with
  58466. * @returns resulting new vector
  58467. */
  58468. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58469. /**
  58470. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58471. * @param otherVector vector to multiple with
  58472. * @param result vector to store the result
  58473. * @returns the current Vector4.
  58474. */
  58475. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58476. /**
  58477. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58478. * @param x x value multiply with
  58479. * @param y y value multiply with
  58480. * @param z z value multiply with
  58481. * @param w w value multiply with
  58482. * @returns resulting new vector
  58483. */
  58484. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58485. /**
  58486. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58487. * @param otherVector vector to devide with
  58488. * @returns resulting new vector
  58489. */
  58490. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58491. /**
  58492. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58493. * @param otherVector vector to devide with
  58494. * @param result vector to store the result
  58495. * @returns the current Vector4.
  58496. */
  58497. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58498. /**
  58499. * Divides the current Vector3 coordinates by the given ones.
  58500. * @param otherVector vector to devide with
  58501. * @returns the updated Vector3.
  58502. */
  58503. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58504. /**
  58505. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58506. * @param other defines the second operand
  58507. * @returns the current updated Vector4
  58508. */
  58509. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58510. /**
  58511. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58512. * @param other defines the second operand
  58513. * @returns the current updated Vector4
  58514. */
  58515. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58516. /**
  58517. * Gets a new Vector4 from current Vector4 floored values
  58518. * @returns a new Vector4
  58519. */
  58520. floor(): Vector4;
  58521. /**
  58522. * Gets a new Vector4 from current Vector3 floored values
  58523. * @returns a new Vector4
  58524. */
  58525. fract(): Vector4;
  58526. /**
  58527. * Returns the Vector4 length (float).
  58528. * @returns the length
  58529. */
  58530. length(): number;
  58531. /**
  58532. * Returns the Vector4 squared length (float).
  58533. * @returns the length squared
  58534. */
  58535. lengthSquared(): number;
  58536. /**
  58537. * Normalizes in place the Vector4.
  58538. * @returns the updated Vector4.
  58539. */
  58540. normalize(): Vector4;
  58541. /**
  58542. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58543. * @returns this converted to a new vector3
  58544. */
  58545. toVector3(): Vector3;
  58546. /**
  58547. * Returns a new Vector4 copied from the current one.
  58548. * @returns the new cloned vector
  58549. */
  58550. clone(): Vector4;
  58551. /**
  58552. * Updates the current Vector4 with the given one coordinates.
  58553. * @param source the source vector to copy from
  58554. * @returns the updated Vector4.
  58555. */
  58556. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58557. /**
  58558. * Updates the current Vector4 coordinates with the given floats.
  58559. * @param x float to copy from
  58560. * @param y float to copy from
  58561. * @param z float to copy from
  58562. * @param w float to copy from
  58563. * @returns the updated Vector4.
  58564. */
  58565. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58566. /**
  58567. * Updates the current Vector4 coordinates with the given floats.
  58568. * @param x float to set from
  58569. * @param y float to set from
  58570. * @param z float to set from
  58571. * @param w float to set from
  58572. * @returns the updated Vector4.
  58573. */
  58574. set(x: number, y: number, z: number, w: number): Vector4;
  58575. /**
  58576. * Copies the given float to the current Vector3 coordinates
  58577. * @param v defines the x, y, z and w coordinates of the operand
  58578. * @returns the current updated Vector3
  58579. */
  58580. setAll(v: number): Vector4;
  58581. /**
  58582. * Returns a new Vector4 set from the starting index of the given array.
  58583. * @param array the array to pull values from
  58584. * @param offset the offset into the array to start at
  58585. * @returns the new vector
  58586. */
  58587. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58588. /**
  58589. * Updates the given vector "result" from the starting index of the given array.
  58590. * @param array the array to pull values from
  58591. * @param offset the offset into the array to start at
  58592. * @param result the vector to store the result in
  58593. */
  58594. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58595. /**
  58596. * Updates the given vector "result" from the starting index of the given Float32Array.
  58597. * @param array the array to pull values from
  58598. * @param offset the offset into the array to start at
  58599. * @param result the vector to store the result in
  58600. */
  58601. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58602. /**
  58603. * Updates the given vector "result" coordinates from the given floats.
  58604. * @param x float to set from
  58605. * @param y float to set from
  58606. * @param z float to set from
  58607. * @param w float to set from
  58608. * @param result the vector to the floats in
  58609. */
  58610. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58611. /**
  58612. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58613. * @returns the new vector
  58614. */
  58615. static Zero(): Vector4;
  58616. /**
  58617. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58618. * @returns the new vector
  58619. */
  58620. static One(): Vector4;
  58621. /**
  58622. * Returns a new normalized Vector4 from the given one.
  58623. * @param vector the vector to normalize
  58624. * @returns the vector
  58625. */
  58626. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58627. /**
  58628. * Updates the given vector "result" from the normalization of the given one.
  58629. * @param vector the vector to normalize
  58630. * @param result the vector to store the result in
  58631. */
  58632. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58633. /**
  58634. * Returns a vector with the minimum values from the left and right vectors
  58635. * @param left left vector to minimize
  58636. * @param right right vector to minimize
  58637. * @returns a new vector with the minimum of the left and right vector values
  58638. */
  58639. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58640. /**
  58641. * Returns a vector with the maximum values from the left and right vectors
  58642. * @param left left vector to maximize
  58643. * @param right right vector to maximize
  58644. * @returns a new vector with the maximum of the left and right vector values
  58645. */
  58646. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58647. /**
  58648. * Returns the distance (float) between the vectors "value1" and "value2".
  58649. * @param value1 value to calulate the distance between
  58650. * @param value2 value to calulate the distance between
  58651. * @return the distance between the two vectors
  58652. */
  58653. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58654. /**
  58655. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58656. * @param value1 value to calulate the distance between
  58657. * @param value2 value to calulate the distance between
  58658. * @return the distance between the two vectors squared
  58659. */
  58660. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58661. /**
  58662. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58663. * @param value1 value to calulate the center between
  58664. * @param value2 value to calulate the center between
  58665. * @return the center between the two vectors
  58666. */
  58667. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58668. /**
  58669. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58670. * This methods computes transformed normalized direction vectors only.
  58671. * @param vector the vector to transform
  58672. * @param transformation the transformation matrix to apply
  58673. * @returns the new vector
  58674. */
  58675. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58676. /**
  58677. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58678. * This methods computes transformed normalized direction vectors only.
  58679. * @param vector the vector to transform
  58680. * @param transformation the transformation matrix to apply
  58681. * @param result the vector to store the result in
  58682. */
  58683. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58684. /**
  58685. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58686. * This methods computes transformed normalized direction vectors only.
  58687. * @param x value to transform
  58688. * @param y value to transform
  58689. * @param z value to transform
  58690. * @param w value to transform
  58691. * @param transformation the transformation matrix to apply
  58692. * @param result the vector to store the results in
  58693. */
  58694. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58695. /**
  58696. * Creates a new Vector4 from a Vector3
  58697. * @param source defines the source data
  58698. * @param w defines the 4th component (default is 0)
  58699. * @returns a new Vector4
  58700. */
  58701. static FromVector3(source: Vector3, w?: number): Vector4;
  58702. }
  58703. /**
  58704. * Interface for the size containing width and height
  58705. */
  58706. export interface ISize {
  58707. /**
  58708. * Width
  58709. */
  58710. width: number;
  58711. /**
  58712. * Heighht
  58713. */
  58714. height: number;
  58715. }
  58716. /**
  58717. * Size containing widht and height
  58718. */
  58719. export class Size implements ISize {
  58720. /**
  58721. * Width
  58722. */
  58723. width: number;
  58724. /**
  58725. * Height
  58726. */
  58727. height: number;
  58728. /**
  58729. * Creates a Size object from the given width and height (floats).
  58730. * @param width width of the new size
  58731. * @param height height of the new size
  58732. */
  58733. constructor(width: number, height: number);
  58734. /**
  58735. * Returns a string with the Size width and height
  58736. * @returns a string with the Size width and height
  58737. */
  58738. toString(): string;
  58739. /**
  58740. * "Size"
  58741. * @returns the string "Size"
  58742. */
  58743. getClassName(): string;
  58744. /**
  58745. * Returns the Size hash code.
  58746. * @returns a hash code for a unique width and height
  58747. */
  58748. getHashCode(): number;
  58749. /**
  58750. * Updates the current size from the given one.
  58751. * @param src the given size
  58752. */
  58753. copyFrom(src: Size): void;
  58754. /**
  58755. * Updates in place the current Size from the given floats.
  58756. * @param width width of the new size
  58757. * @param height height of the new size
  58758. * @returns the updated Size.
  58759. */
  58760. copyFromFloats(width: number, height: number): Size;
  58761. /**
  58762. * Updates in place the current Size from the given floats.
  58763. * @param width width to set
  58764. * @param height height to set
  58765. * @returns the updated Size.
  58766. */
  58767. set(width: number, height: number): Size;
  58768. /**
  58769. * Multiplies the width and height by numbers
  58770. * @param w factor to multiple the width by
  58771. * @param h factor to multiple the height by
  58772. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58773. */
  58774. multiplyByFloats(w: number, h: number): Size;
  58775. /**
  58776. * Clones the size
  58777. * @returns a new Size copied from the given one.
  58778. */
  58779. clone(): Size;
  58780. /**
  58781. * True if the current Size and the given one width and height are strictly equal.
  58782. * @param other the other size to compare against
  58783. * @returns True if the current Size and the given one width and height are strictly equal.
  58784. */
  58785. equals(other: Size): boolean;
  58786. /**
  58787. * The surface of the Size : width * height (float).
  58788. */
  58789. readonly surface: number;
  58790. /**
  58791. * Create a new size of zero
  58792. * @returns a new Size set to (0.0, 0.0)
  58793. */
  58794. static Zero(): Size;
  58795. /**
  58796. * Sums the width and height of two sizes
  58797. * @param otherSize size to add to this size
  58798. * @returns a new Size set as the addition result of the current Size and the given one.
  58799. */
  58800. add(otherSize: Size): Size;
  58801. /**
  58802. * Subtracts the width and height of two
  58803. * @param otherSize size to subtract to this size
  58804. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58805. */
  58806. subtract(otherSize: Size): Size;
  58807. /**
  58808. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58809. * @param start starting size to lerp between
  58810. * @param end end size to lerp between
  58811. * @param amount amount to lerp between the start and end values
  58812. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58813. */
  58814. static Lerp(start: Size, end: Size, amount: number): Size;
  58815. }
  58816. /**
  58817. * Class used to store quaternion data
  58818. * @see https://en.wikipedia.org/wiki/Quaternion
  58819. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58820. */
  58821. export class Quaternion {
  58822. /** defines the first component (0 by default) */
  58823. x: number;
  58824. /** defines the second component (0 by default) */
  58825. y: number;
  58826. /** defines the third component (0 by default) */
  58827. z: number;
  58828. /** defines the fourth component (1.0 by default) */
  58829. w: number;
  58830. /**
  58831. * Creates a new Quaternion from the given floats
  58832. * @param x defines the first component (0 by default)
  58833. * @param y defines the second component (0 by default)
  58834. * @param z defines the third component (0 by default)
  58835. * @param w defines the fourth component (1.0 by default)
  58836. */
  58837. constructor(
  58838. /** defines the first component (0 by default) */
  58839. x?: number,
  58840. /** defines the second component (0 by default) */
  58841. y?: number,
  58842. /** defines the third component (0 by default) */
  58843. z?: number,
  58844. /** defines the fourth component (1.0 by default) */
  58845. w?: number);
  58846. /**
  58847. * Gets a string representation for the current quaternion
  58848. * @returns a string with the Quaternion coordinates
  58849. */
  58850. toString(): string;
  58851. /**
  58852. * Gets the class name of the quaternion
  58853. * @returns the string "Quaternion"
  58854. */
  58855. getClassName(): string;
  58856. /**
  58857. * Gets a hash code for this quaternion
  58858. * @returns the quaternion hash code
  58859. */
  58860. getHashCode(): number;
  58861. /**
  58862. * Copy the quaternion to an array
  58863. * @returns a new array populated with 4 elements from the quaternion coordinates
  58864. */
  58865. asArray(): number[];
  58866. /**
  58867. * Check if two quaternions are equals
  58868. * @param otherQuaternion defines the second operand
  58869. * @return true if the current quaternion and the given one coordinates are strictly equals
  58870. */
  58871. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  58872. /**
  58873. * Clone the current quaternion
  58874. * @returns a new quaternion copied from the current one
  58875. */
  58876. clone(): Quaternion;
  58877. /**
  58878. * Copy a quaternion to the current one
  58879. * @param other defines the other quaternion
  58880. * @returns the updated current quaternion
  58881. */
  58882. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  58883. /**
  58884. * Updates the current quaternion with the given float coordinates
  58885. * @param x defines the x coordinate
  58886. * @param y defines the y coordinate
  58887. * @param z defines the z coordinate
  58888. * @param w defines the w coordinate
  58889. * @returns the updated current quaternion
  58890. */
  58891. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  58892. /**
  58893. * Updates the current quaternion from the given float coordinates
  58894. * @param x defines the x coordinate
  58895. * @param y defines the y coordinate
  58896. * @param z defines the z coordinate
  58897. * @param w defines the w coordinate
  58898. * @returns the updated current quaternion
  58899. */
  58900. set(x: number, y: number, z: number, w: number): Quaternion;
  58901. /**
  58902. * Adds two quaternions
  58903. * @param other defines the second operand
  58904. * @returns a new quaternion as the addition result of the given one and the current quaternion
  58905. */
  58906. add(other: DeepImmutable<Quaternion>): Quaternion;
  58907. /**
  58908. * Add a quaternion to the current one
  58909. * @param other defines the quaternion to add
  58910. * @returns the current quaternion
  58911. */
  58912. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  58913. /**
  58914. * Subtract two quaternions
  58915. * @param other defines the second operand
  58916. * @returns a new quaternion as the subtraction result of the given one from the current one
  58917. */
  58918. subtract(other: Quaternion): Quaternion;
  58919. /**
  58920. * Multiplies the current quaternion by a scale factor
  58921. * @param value defines the scale factor
  58922. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  58923. */
  58924. scale(value: number): Quaternion;
  58925. /**
  58926. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  58927. * @param scale defines the scale factor
  58928. * @param result defines the Quaternion object where to store the result
  58929. * @returns the unmodified current quaternion
  58930. */
  58931. scaleToRef(scale: number, result: Quaternion): Quaternion;
  58932. /**
  58933. * Multiplies in place the current quaternion by a scale factor
  58934. * @param value defines the scale factor
  58935. * @returns the current modified quaternion
  58936. */
  58937. scaleInPlace(value: number): Quaternion;
  58938. /**
  58939. * Scale the current quaternion values by a factor and add the result to a given quaternion
  58940. * @param scale defines the scale factor
  58941. * @param result defines the Quaternion object where to store the result
  58942. * @returns the unmodified current quaternion
  58943. */
  58944. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  58945. /**
  58946. * Multiplies two quaternions
  58947. * @param q1 defines the second operand
  58948. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  58949. */
  58950. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  58951. /**
  58952. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  58953. * @param q1 defines the second operand
  58954. * @param result defines the target quaternion
  58955. * @returns the current quaternion
  58956. */
  58957. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  58958. /**
  58959. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  58960. * @param q1 defines the second operand
  58961. * @returns the currentupdated quaternion
  58962. */
  58963. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  58964. /**
  58965. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  58966. * @param ref defines the target quaternion
  58967. * @returns the current quaternion
  58968. */
  58969. conjugateToRef(ref: Quaternion): Quaternion;
  58970. /**
  58971. * Conjugates in place (1-q) the current quaternion
  58972. * @returns the current updated quaternion
  58973. */
  58974. conjugateInPlace(): Quaternion;
  58975. /**
  58976. * Conjugates in place (1-q) the current quaternion
  58977. * @returns a new quaternion
  58978. */
  58979. conjugate(): Quaternion;
  58980. /**
  58981. * Gets length of current quaternion
  58982. * @returns the quaternion length (float)
  58983. */
  58984. length(): number;
  58985. /**
  58986. * Normalize in place the current quaternion
  58987. * @returns the current updated quaternion
  58988. */
  58989. normalize(): Quaternion;
  58990. /**
  58991. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  58992. * @param order is a reserved parameter and is ignore for now
  58993. * @returns a new Vector3 containing the Euler angles
  58994. */
  58995. toEulerAngles(order?: string): Vector3;
  58996. /**
  58997. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  58998. * @param result defines the vector which will be filled with the Euler angles
  58999. * @param order is a reserved parameter and is ignore for now
  59000. * @returns the current unchanged quaternion
  59001. */
  59002. toEulerAnglesToRef(result: Vector3): Quaternion;
  59003. /**
  59004. * Updates the given rotation matrix with the current quaternion values
  59005. * @param result defines the target matrix
  59006. * @returns the current unchanged quaternion
  59007. */
  59008. toRotationMatrix(result: Matrix): Quaternion;
  59009. /**
  59010. * Updates the current quaternion from the given rotation matrix values
  59011. * @param matrix defines the source matrix
  59012. * @returns the current updated quaternion
  59013. */
  59014. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59015. /**
  59016. * Creates a new quaternion from a rotation matrix
  59017. * @param matrix defines the source matrix
  59018. * @returns a new quaternion created from the given rotation matrix values
  59019. */
  59020. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59021. /**
  59022. * Updates the given quaternion with the given rotation matrix values
  59023. * @param matrix defines the source matrix
  59024. * @param result defines the target quaternion
  59025. */
  59026. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59027. /**
  59028. * Returns the dot product (float) between the quaternions "left" and "right"
  59029. * @param left defines the left operand
  59030. * @param right defines the right operand
  59031. * @returns the dot product
  59032. */
  59033. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59034. /**
  59035. * Checks if the two quaternions are close to each other
  59036. * @param quat0 defines the first quaternion to check
  59037. * @param quat1 defines the second quaternion to check
  59038. * @returns true if the two quaternions are close to each other
  59039. */
  59040. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59041. /**
  59042. * Creates an empty quaternion
  59043. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59044. */
  59045. static Zero(): Quaternion;
  59046. /**
  59047. * Inverse a given quaternion
  59048. * @param q defines the source quaternion
  59049. * @returns a new quaternion as the inverted current quaternion
  59050. */
  59051. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59052. /**
  59053. * Inverse a given quaternion
  59054. * @param q defines the source quaternion
  59055. * @param result the quaternion the result will be stored in
  59056. * @returns the result quaternion
  59057. */
  59058. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59059. /**
  59060. * Creates an identity quaternion
  59061. * @returns the identity quaternion
  59062. */
  59063. static Identity(): Quaternion;
  59064. /**
  59065. * Gets a boolean indicating if the given quaternion is identity
  59066. * @param quaternion defines the quaternion to check
  59067. * @returns true if the quaternion is identity
  59068. */
  59069. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59070. /**
  59071. * Creates a quaternion from a rotation around an axis
  59072. * @param axis defines the axis to use
  59073. * @param angle defines the angle to use
  59074. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59075. */
  59076. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59077. /**
  59078. * Creates a rotation around an axis and stores it into the given quaternion
  59079. * @param axis defines the axis to use
  59080. * @param angle defines the angle to use
  59081. * @param result defines the target quaternion
  59082. * @returns the target quaternion
  59083. */
  59084. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59085. /**
  59086. * Creates a new quaternion from data stored into an array
  59087. * @param array defines the data source
  59088. * @param offset defines the offset in the source array where the data starts
  59089. * @returns a new quaternion
  59090. */
  59091. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59092. /**
  59093. * Create a quaternion from Euler rotation angles
  59094. * @param x Pitch
  59095. * @param y Yaw
  59096. * @param z Roll
  59097. * @returns the new Quaternion
  59098. */
  59099. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59100. /**
  59101. * Updates a quaternion from Euler rotation angles
  59102. * @param x Pitch
  59103. * @param y Yaw
  59104. * @param z Roll
  59105. * @param result the quaternion to store the result
  59106. * @returns the updated quaternion
  59107. */
  59108. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59109. /**
  59110. * Create a quaternion from Euler rotation vector
  59111. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59112. * @returns the new Quaternion
  59113. */
  59114. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59115. /**
  59116. * Updates a quaternion from Euler rotation vector
  59117. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59118. * @param result the quaternion to store the result
  59119. * @returns the updated quaternion
  59120. */
  59121. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59122. /**
  59123. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59124. * @param yaw defines the rotation around Y axis
  59125. * @param pitch defines the rotation around X axis
  59126. * @param roll defines the rotation around Z axis
  59127. * @returns the new quaternion
  59128. */
  59129. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59130. /**
  59131. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59132. * @param yaw defines the rotation around Y axis
  59133. * @param pitch defines the rotation around X axis
  59134. * @param roll defines the rotation around Z axis
  59135. * @param result defines the target quaternion
  59136. */
  59137. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59138. /**
  59139. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59140. * @param alpha defines the rotation around first axis
  59141. * @param beta defines the rotation around second axis
  59142. * @param gamma defines the rotation around third axis
  59143. * @returns the new quaternion
  59144. */
  59145. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59146. /**
  59147. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59148. * @param alpha defines the rotation around first axis
  59149. * @param beta defines the rotation around second axis
  59150. * @param gamma defines the rotation around third axis
  59151. * @param result defines the target quaternion
  59152. */
  59153. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59154. /**
  59155. * 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)
  59156. * @param axis1 defines the first axis
  59157. * @param axis2 defines the second axis
  59158. * @param axis3 defines the third axis
  59159. * @returns the new quaternion
  59160. */
  59161. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59162. /**
  59163. * 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
  59164. * @param axis1 defines the first axis
  59165. * @param axis2 defines the second axis
  59166. * @param axis3 defines the third axis
  59167. * @param ref defines the target quaternion
  59168. */
  59169. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59170. /**
  59171. * Interpolates between two quaternions
  59172. * @param left defines first quaternion
  59173. * @param right defines second quaternion
  59174. * @param amount defines the gradient to use
  59175. * @returns the new interpolated quaternion
  59176. */
  59177. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59178. /**
  59179. * Interpolates between two quaternions and stores it into a target quaternion
  59180. * @param left defines first quaternion
  59181. * @param right defines second quaternion
  59182. * @param amount defines the gradient to use
  59183. * @param result defines the target quaternion
  59184. */
  59185. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59186. /**
  59187. * Interpolate between two quaternions using Hermite interpolation
  59188. * @param value1 defines first quaternion
  59189. * @param tangent1 defines the incoming tangent
  59190. * @param value2 defines second quaternion
  59191. * @param tangent2 defines the outgoing tangent
  59192. * @param amount defines the target quaternion
  59193. * @returns the new interpolated quaternion
  59194. */
  59195. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59196. }
  59197. /**
  59198. * Class used to store matrix data (4x4)
  59199. */
  59200. export class Matrix {
  59201. private static _updateFlagSeed;
  59202. private static _identityReadOnly;
  59203. private _isIdentity;
  59204. private _isIdentityDirty;
  59205. private _isIdentity3x2;
  59206. private _isIdentity3x2Dirty;
  59207. /**
  59208. * Gets the update flag of the matrix which is an unique number for the matrix.
  59209. * It will be incremented every time the matrix data change.
  59210. * You can use it to speed the comparison between two versions of the same matrix.
  59211. */
  59212. updateFlag: number;
  59213. private readonly _m;
  59214. /**
  59215. * Gets the internal data of the matrix
  59216. */
  59217. readonly m: DeepImmutable<Float32Array>;
  59218. /** @hidden */
  59219. _markAsUpdated(): void;
  59220. /** @hidden */
  59221. private _updateIdentityStatus;
  59222. /**
  59223. * Creates an empty matrix (filled with zeros)
  59224. */
  59225. constructor();
  59226. /**
  59227. * Check if the current matrix is identity
  59228. * @returns true is the matrix is the identity matrix
  59229. */
  59230. isIdentity(): boolean;
  59231. /**
  59232. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59233. * @returns true is the matrix is the identity matrix
  59234. */
  59235. isIdentityAs3x2(): boolean;
  59236. /**
  59237. * Gets the determinant of the matrix
  59238. * @returns the matrix determinant
  59239. */
  59240. determinant(): number;
  59241. /**
  59242. * Returns the matrix as a Float32Array
  59243. * @returns the matrix underlying array
  59244. */
  59245. toArray(): DeepImmutable<Float32Array>;
  59246. /**
  59247. * Returns the matrix as a Float32Array
  59248. * @returns the matrix underlying array.
  59249. */
  59250. asArray(): DeepImmutable<Float32Array>;
  59251. /**
  59252. * Inverts the current matrix in place
  59253. * @returns the current inverted matrix
  59254. */
  59255. invert(): Matrix;
  59256. /**
  59257. * Sets all the matrix elements to zero
  59258. * @returns the current matrix
  59259. */
  59260. reset(): Matrix;
  59261. /**
  59262. * Adds the current matrix with a second one
  59263. * @param other defines the matrix to add
  59264. * @returns a new matrix as the addition of the current matrix and the given one
  59265. */
  59266. add(other: DeepImmutable<Matrix>): Matrix;
  59267. /**
  59268. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59269. * @param other defines the matrix to add
  59270. * @param result defines the target matrix
  59271. * @returns the current matrix
  59272. */
  59273. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59274. /**
  59275. * Adds in place the given matrix to the current matrix
  59276. * @param other defines the second operand
  59277. * @returns the current updated matrix
  59278. */
  59279. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59280. /**
  59281. * Sets the given matrix to the current inverted Matrix
  59282. * @param other defines the target matrix
  59283. * @returns the unmodified current matrix
  59284. */
  59285. invertToRef(other: Matrix): Matrix;
  59286. /**
  59287. * add a value at the specified position in the current Matrix
  59288. * @param index the index of the value within the matrix. between 0 and 15.
  59289. * @param value the value to be added
  59290. * @returns the current updated matrix
  59291. */
  59292. addAtIndex(index: number, value: number): Matrix;
  59293. /**
  59294. * mutiply the specified position in the current Matrix by a value
  59295. * @param index the index of the value within the matrix. between 0 and 15.
  59296. * @param value the value to be added
  59297. * @returns the current updated matrix
  59298. */
  59299. multiplyAtIndex(index: number, value: number): Matrix;
  59300. /**
  59301. * Inserts the translation vector (using 3 floats) in the current matrix
  59302. * @param x defines the 1st component of the translation
  59303. * @param y defines the 2nd component of the translation
  59304. * @param z defines the 3rd component of the translation
  59305. * @returns the current updated matrix
  59306. */
  59307. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59308. /**
  59309. * Inserts the translation vector in the current matrix
  59310. * @param vector3 defines the translation to insert
  59311. * @returns the current updated matrix
  59312. */
  59313. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59314. /**
  59315. * Gets the translation value of the current matrix
  59316. * @returns a new Vector3 as the extracted translation from the matrix
  59317. */
  59318. getTranslation(): Vector3;
  59319. /**
  59320. * Fill a Vector3 with the extracted translation from the matrix
  59321. * @param result defines the Vector3 where to store the translation
  59322. * @returns the current matrix
  59323. */
  59324. getTranslationToRef(result: Vector3): Matrix;
  59325. /**
  59326. * Remove rotation and scaling part from the matrix
  59327. * @returns the updated matrix
  59328. */
  59329. removeRotationAndScaling(): Matrix;
  59330. /**
  59331. * Multiply two matrices
  59332. * @param other defines the second operand
  59333. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59334. */
  59335. multiply(other: DeepImmutable<Matrix>): Matrix;
  59336. /**
  59337. * Copy the current matrix from the given one
  59338. * @param other defines the source matrix
  59339. * @returns the current updated matrix
  59340. */
  59341. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59342. /**
  59343. * Populates the given array from the starting index with the current matrix values
  59344. * @param array defines the target array
  59345. * @param offset defines the offset in the target array where to start storing values
  59346. * @returns the current matrix
  59347. */
  59348. copyToArray(array: Float32Array, offset?: number): Matrix;
  59349. /**
  59350. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59351. * @param other defines the second operand
  59352. * @param result defines the matrix where to store the multiplication
  59353. * @returns the current matrix
  59354. */
  59355. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59356. /**
  59357. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59358. * @param other defines the second operand
  59359. * @param result defines the array where to store the multiplication
  59360. * @param offset defines the offset in the target array where to start storing values
  59361. * @returns the current matrix
  59362. */
  59363. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59364. /**
  59365. * Check equality between this matrix and a second one
  59366. * @param value defines the second matrix to compare
  59367. * @returns true is the current matrix and the given one values are strictly equal
  59368. */
  59369. equals(value: DeepImmutable<Matrix>): boolean;
  59370. /**
  59371. * Clone the current matrix
  59372. * @returns a new matrix from the current matrix
  59373. */
  59374. clone(): Matrix;
  59375. /**
  59376. * Returns the name of the current matrix class
  59377. * @returns the string "Matrix"
  59378. */
  59379. getClassName(): string;
  59380. /**
  59381. * Gets the hash code of the current matrix
  59382. * @returns the hash code
  59383. */
  59384. getHashCode(): number;
  59385. /**
  59386. * Decomposes the current Matrix into a translation, rotation and scaling components
  59387. * @param scale defines the scale vector3 given as a reference to update
  59388. * @param rotation defines the rotation quaternion given as a reference to update
  59389. * @param translation defines the translation vector3 given as a reference to update
  59390. * @returns true if operation was successful
  59391. */
  59392. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59393. /**
  59394. * Gets specific row of the matrix
  59395. * @param index defines the number of the row to get
  59396. * @returns the index-th row of the current matrix as a new Vector4
  59397. */
  59398. getRow(index: number): Nullable<Vector4>;
  59399. /**
  59400. * Sets the index-th row of the current matrix to the vector4 values
  59401. * @param index defines the number of the row to set
  59402. * @param row defines the target vector4
  59403. * @returns the updated current matrix
  59404. */
  59405. setRow(index: number, row: Vector4): Matrix;
  59406. /**
  59407. * Compute the transpose of the matrix
  59408. * @returns the new transposed matrix
  59409. */
  59410. transpose(): Matrix;
  59411. /**
  59412. * Compute the transpose of the matrix and store it in a given matrix
  59413. * @param result defines the target matrix
  59414. * @returns the current matrix
  59415. */
  59416. transposeToRef(result: Matrix): Matrix;
  59417. /**
  59418. * Sets the index-th row of the current matrix with the given 4 x float values
  59419. * @param index defines the row index
  59420. * @param x defines the x component to set
  59421. * @param y defines the y component to set
  59422. * @param z defines the z component to set
  59423. * @param w defines the w component to set
  59424. * @returns the updated current matrix
  59425. */
  59426. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59427. /**
  59428. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59429. * @param scale defines the scale factor
  59430. * @returns a new matrix
  59431. */
  59432. scale(scale: number): Matrix;
  59433. /**
  59434. * Scale the current matrix values by a factor to a given result matrix
  59435. * @param scale defines the scale factor
  59436. * @param result defines the matrix to store the result
  59437. * @returns the current matrix
  59438. */
  59439. scaleToRef(scale: number, result: Matrix): Matrix;
  59440. /**
  59441. * Scale the current matrix values by a factor and add the result to a given matrix
  59442. * @param scale defines the scale factor
  59443. * @param result defines the Matrix to store the result
  59444. * @returns the current matrix
  59445. */
  59446. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59447. /**
  59448. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59449. * @param ref matrix to store the result
  59450. */
  59451. toNormalMatrix(ref: Matrix): void;
  59452. /**
  59453. * Gets only rotation part of the current matrix
  59454. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59455. */
  59456. getRotationMatrix(): Matrix;
  59457. /**
  59458. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59459. * @param result defines the target matrix to store data to
  59460. * @returns the current matrix
  59461. */
  59462. getRotationMatrixToRef(result: Matrix): Matrix;
  59463. /**
  59464. * Toggles model matrix from being right handed to left handed in place and vice versa
  59465. */
  59466. toggleModelMatrixHandInPlace(): void;
  59467. /**
  59468. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59469. */
  59470. toggleProjectionMatrixHandInPlace(): void;
  59471. /**
  59472. * Creates a matrix from an array
  59473. * @param array defines the source array
  59474. * @param offset defines an offset in the source array
  59475. * @returns a new Matrix set from the starting index of the given array
  59476. */
  59477. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59478. /**
  59479. * Copy the content of an array into a given matrix
  59480. * @param array defines the source array
  59481. * @param offset defines an offset in the source array
  59482. * @param result defines the target matrix
  59483. */
  59484. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59485. /**
  59486. * Stores an array into a matrix after having multiplied each component by a given factor
  59487. * @param array defines the source array
  59488. * @param offset defines the offset in the source array
  59489. * @param scale defines the scaling factor
  59490. * @param result defines the target matrix
  59491. */
  59492. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59493. /**
  59494. * Gets an identity matrix that must not be updated
  59495. */
  59496. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59497. /**
  59498. * Stores a list of values (16) inside a given matrix
  59499. * @param initialM11 defines 1st value of 1st row
  59500. * @param initialM12 defines 2nd value of 1st row
  59501. * @param initialM13 defines 3rd value of 1st row
  59502. * @param initialM14 defines 4th value of 1st row
  59503. * @param initialM21 defines 1st value of 2nd row
  59504. * @param initialM22 defines 2nd value of 2nd row
  59505. * @param initialM23 defines 3rd value of 2nd row
  59506. * @param initialM24 defines 4th value of 2nd row
  59507. * @param initialM31 defines 1st value of 3rd row
  59508. * @param initialM32 defines 2nd value of 3rd row
  59509. * @param initialM33 defines 3rd value of 3rd row
  59510. * @param initialM34 defines 4th value of 3rd row
  59511. * @param initialM41 defines 1st value of 4th row
  59512. * @param initialM42 defines 2nd value of 4th row
  59513. * @param initialM43 defines 3rd value of 4th row
  59514. * @param initialM44 defines 4th value of 4th row
  59515. * @param result defines the target matrix
  59516. */
  59517. 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;
  59518. /**
  59519. * Creates new matrix from a list of values (16)
  59520. * @param initialM11 defines 1st value of 1st row
  59521. * @param initialM12 defines 2nd value of 1st row
  59522. * @param initialM13 defines 3rd value of 1st row
  59523. * @param initialM14 defines 4th value of 1st row
  59524. * @param initialM21 defines 1st value of 2nd row
  59525. * @param initialM22 defines 2nd value of 2nd row
  59526. * @param initialM23 defines 3rd value of 2nd row
  59527. * @param initialM24 defines 4th value of 2nd row
  59528. * @param initialM31 defines 1st value of 3rd row
  59529. * @param initialM32 defines 2nd value of 3rd row
  59530. * @param initialM33 defines 3rd value of 3rd row
  59531. * @param initialM34 defines 4th value of 3rd row
  59532. * @param initialM41 defines 1st value of 4th row
  59533. * @param initialM42 defines 2nd value of 4th row
  59534. * @param initialM43 defines 3rd value of 4th row
  59535. * @param initialM44 defines 4th value of 4th row
  59536. * @returns the new matrix
  59537. */
  59538. 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;
  59539. /**
  59540. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59541. * @param scale defines the scale vector3
  59542. * @param rotation defines the rotation quaternion
  59543. * @param translation defines the translation vector3
  59544. * @returns a new matrix
  59545. */
  59546. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59547. /**
  59548. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59549. * @param scale defines the scale vector3
  59550. * @param rotation defines the rotation quaternion
  59551. * @param translation defines the translation vector3
  59552. * @param result defines the target matrix
  59553. */
  59554. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59555. /**
  59556. * Creates a new identity matrix
  59557. * @returns a new identity matrix
  59558. */
  59559. static Identity(): Matrix;
  59560. /**
  59561. * Creates a new identity matrix and stores the result in a given matrix
  59562. * @param result defines the target matrix
  59563. */
  59564. static IdentityToRef(result: Matrix): void;
  59565. /**
  59566. * Creates a new zero matrix
  59567. * @returns a new zero matrix
  59568. */
  59569. static Zero(): Matrix;
  59570. /**
  59571. * Creates a new rotation matrix for "angle" radians around the X axis
  59572. * @param angle defines the angle (in radians) to use
  59573. * @return the new matrix
  59574. */
  59575. static RotationX(angle: number): Matrix;
  59576. /**
  59577. * Creates a new matrix as the invert of a given matrix
  59578. * @param source defines the source matrix
  59579. * @returns the new matrix
  59580. */
  59581. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59582. /**
  59583. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59584. * @param angle defines the angle (in radians) to use
  59585. * @param result defines the target matrix
  59586. */
  59587. static RotationXToRef(angle: number, result: Matrix): void;
  59588. /**
  59589. * Creates a new rotation matrix for "angle" radians around the Y axis
  59590. * @param angle defines the angle (in radians) to use
  59591. * @return the new matrix
  59592. */
  59593. static RotationY(angle: number): Matrix;
  59594. /**
  59595. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59596. * @param angle defines the angle (in radians) to use
  59597. * @param result defines the target matrix
  59598. */
  59599. static RotationYToRef(angle: number, result: Matrix): void;
  59600. /**
  59601. * Creates a new rotation matrix for "angle" radians around the Z axis
  59602. * @param angle defines the angle (in radians) to use
  59603. * @return the new matrix
  59604. */
  59605. static RotationZ(angle: number): Matrix;
  59606. /**
  59607. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59608. * @param angle defines the angle (in radians) to use
  59609. * @param result defines the target matrix
  59610. */
  59611. static RotationZToRef(angle: number, result: Matrix): void;
  59612. /**
  59613. * Creates a new rotation matrix for "angle" radians around the given axis
  59614. * @param axis defines the axis to use
  59615. * @param angle defines the angle (in radians) to use
  59616. * @return the new matrix
  59617. */
  59618. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59619. /**
  59620. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59621. * @param axis defines the axis to use
  59622. * @param angle defines the angle (in radians) to use
  59623. * @param result defines the target matrix
  59624. */
  59625. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59626. /**
  59627. * Creates a rotation matrix
  59628. * @param yaw defines the yaw angle in radians (Y axis)
  59629. * @param pitch defines the pitch angle in radians (X axis)
  59630. * @param roll defines the roll angle in radians (X axis)
  59631. * @returns the new rotation matrix
  59632. */
  59633. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59634. /**
  59635. * Creates a rotation matrix and stores it in a given matrix
  59636. * @param yaw defines the yaw angle in radians (Y axis)
  59637. * @param pitch defines the pitch angle in radians (X axis)
  59638. * @param roll defines the roll angle in radians (X axis)
  59639. * @param result defines the target matrix
  59640. */
  59641. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59642. /**
  59643. * Creates a scaling matrix
  59644. * @param x defines the scale factor on X axis
  59645. * @param y defines the scale factor on Y axis
  59646. * @param z defines the scale factor on Z axis
  59647. * @returns the new matrix
  59648. */
  59649. static Scaling(x: number, y: number, z: number): Matrix;
  59650. /**
  59651. * Creates a scaling matrix and stores it in a given matrix
  59652. * @param x defines the scale factor on X axis
  59653. * @param y defines the scale factor on Y axis
  59654. * @param z defines the scale factor on Z axis
  59655. * @param result defines the target matrix
  59656. */
  59657. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59658. /**
  59659. * Creates a translation matrix
  59660. * @param x defines the translation on X axis
  59661. * @param y defines the translation on Y axis
  59662. * @param z defines the translationon Z axis
  59663. * @returns the new matrix
  59664. */
  59665. static Translation(x: number, y: number, z: number): Matrix;
  59666. /**
  59667. * Creates a translation matrix and stores it in a given matrix
  59668. * @param x defines the translation on X axis
  59669. * @param y defines the translation on Y axis
  59670. * @param z defines the translationon Z axis
  59671. * @param result defines the target matrix
  59672. */
  59673. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59674. /**
  59675. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59676. * @param startValue defines the start value
  59677. * @param endValue defines the end value
  59678. * @param gradient defines the gradient factor
  59679. * @returns the new matrix
  59680. */
  59681. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59682. /**
  59683. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59684. * @param startValue defines the start value
  59685. * @param endValue defines the end value
  59686. * @param gradient defines the gradient factor
  59687. * @param result defines the Matrix object where to store data
  59688. */
  59689. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59690. /**
  59691. * Builds a new matrix whose values are computed by:
  59692. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59693. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59694. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59695. * @param startValue defines the first matrix
  59696. * @param endValue defines the second matrix
  59697. * @param gradient defines the gradient between the two matrices
  59698. * @returns the new matrix
  59699. */
  59700. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59701. /**
  59702. * Update a matrix to values which are computed by:
  59703. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59704. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59705. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59706. * @param startValue defines the first matrix
  59707. * @param endValue defines the second matrix
  59708. * @param gradient defines the gradient between the two matrices
  59709. * @param result defines the target matrix
  59710. */
  59711. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59712. /**
  59713. * 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"
  59714. * This function works in left handed mode
  59715. * @param eye defines the final position of the entity
  59716. * @param target defines where the entity should look at
  59717. * @param up defines the up vector for the entity
  59718. * @returns the new matrix
  59719. */
  59720. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59721. /**
  59722. * 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".
  59723. * This function works in left handed mode
  59724. * @param eye defines the final position of the entity
  59725. * @param target defines where the entity should look at
  59726. * @param up defines the up vector for the entity
  59727. * @param result defines the target matrix
  59728. */
  59729. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59730. /**
  59731. * 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"
  59732. * This function works in right handed mode
  59733. * @param eye defines the final position of the entity
  59734. * @param target defines where the entity should look at
  59735. * @param up defines the up vector for the entity
  59736. * @returns the new matrix
  59737. */
  59738. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59739. /**
  59740. * 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".
  59741. * This function works in right handed mode
  59742. * @param eye defines the final position of the entity
  59743. * @param target defines where the entity should look at
  59744. * @param up defines the up vector for the entity
  59745. * @param result defines the target matrix
  59746. */
  59747. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59748. /**
  59749. * Create a left-handed orthographic projection matrix
  59750. * @param width defines the viewport width
  59751. * @param height defines the viewport height
  59752. * @param znear defines the near clip plane
  59753. * @param zfar defines the far clip plane
  59754. * @returns a new matrix as a left-handed orthographic projection matrix
  59755. */
  59756. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59757. /**
  59758. * Store a left-handed orthographic projection to a given matrix
  59759. * @param width defines the viewport width
  59760. * @param height defines the viewport height
  59761. * @param znear defines the near clip plane
  59762. * @param zfar defines the far clip plane
  59763. * @param result defines the target matrix
  59764. */
  59765. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59766. /**
  59767. * Create a left-handed orthographic projection matrix
  59768. * @param left defines the viewport left coordinate
  59769. * @param right defines the viewport right coordinate
  59770. * @param bottom defines the viewport bottom coordinate
  59771. * @param top defines the viewport top coordinate
  59772. * @param znear defines the near clip plane
  59773. * @param zfar defines the far clip plane
  59774. * @returns a new matrix as a left-handed orthographic projection matrix
  59775. */
  59776. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59777. /**
  59778. * Stores a left-handed orthographic projection into a given matrix
  59779. * @param left defines the viewport left coordinate
  59780. * @param right defines the viewport right coordinate
  59781. * @param bottom defines the viewport bottom coordinate
  59782. * @param top defines the viewport top coordinate
  59783. * @param znear defines the near clip plane
  59784. * @param zfar defines the far clip plane
  59785. * @param result defines the target matrix
  59786. */
  59787. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59788. /**
  59789. * Creates a right-handed orthographic projection matrix
  59790. * @param left defines the viewport left coordinate
  59791. * @param right defines the viewport right coordinate
  59792. * @param bottom defines the viewport bottom coordinate
  59793. * @param top defines the viewport top coordinate
  59794. * @param znear defines the near clip plane
  59795. * @param zfar defines the far clip plane
  59796. * @returns a new matrix as a right-handed orthographic projection matrix
  59797. */
  59798. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59799. /**
  59800. * Stores a right-handed orthographic projection into a given matrix
  59801. * @param left defines the viewport left coordinate
  59802. * @param right defines the viewport right coordinate
  59803. * @param bottom defines the viewport bottom coordinate
  59804. * @param top defines the viewport top coordinate
  59805. * @param znear defines the near clip plane
  59806. * @param zfar defines the far clip plane
  59807. * @param result defines the target matrix
  59808. */
  59809. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59810. /**
  59811. * Creates a left-handed perspective projection matrix
  59812. * @param width defines the viewport width
  59813. * @param height defines the viewport height
  59814. * @param znear defines the near clip plane
  59815. * @param zfar defines the far clip plane
  59816. * @returns a new matrix as a left-handed perspective projection matrix
  59817. */
  59818. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59819. /**
  59820. * Creates a left-handed perspective projection matrix
  59821. * @param fov defines the horizontal field of view
  59822. * @param aspect defines the aspect ratio
  59823. * @param znear defines the near clip plane
  59824. * @param zfar defines the far clip plane
  59825. * @returns a new matrix as a left-handed perspective projection matrix
  59826. */
  59827. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59828. /**
  59829. * Stores a left-handed perspective projection into a given matrix
  59830. * @param fov defines the horizontal field of view
  59831. * @param aspect defines the aspect ratio
  59832. * @param znear defines the near clip plane
  59833. * @param zfar defines the far clip plane
  59834. * @param result defines the target matrix
  59835. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59836. */
  59837. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59838. /**
  59839. * Creates a right-handed perspective projection matrix
  59840. * @param fov defines the horizontal field of view
  59841. * @param aspect defines the aspect ratio
  59842. * @param znear defines the near clip plane
  59843. * @param zfar defines the far clip plane
  59844. * @returns a new matrix as a right-handed perspective projection matrix
  59845. */
  59846. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59847. /**
  59848. * Stores a right-handed perspective projection into a given matrix
  59849. * @param fov defines the horizontal field of view
  59850. * @param aspect defines the aspect ratio
  59851. * @param znear defines the near clip plane
  59852. * @param zfar defines the far clip plane
  59853. * @param result defines the target matrix
  59854. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59855. */
  59856. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59857. /**
  59858. * Stores a perspective projection for WebVR info a given matrix
  59859. * @param fov defines the field of view
  59860. * @param znear defines the near clip plane
  59861. * @param zfar defines the far clip plane
  59862. * @param result defines the target matrix
  59863. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  59864. */
  59865. static PerspectiveFovWebVRToRef(fov: {
  59866. upDegrees: number;
  59867. downDegrees: number;
  59868. leftDegrees: number;
  59869. rightDegrees: number;
  59870. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  59871. /**
  59872. * Computes a complete transformation matrix
  59873. * @param viewport defines the viewport to use
  59874. * @param world defines the world matrix
  59875. * @param view defines the view matrix
  59876. * @param projection defines the projection matrix
  59877. * @param zmin defines the near clip plane
  59878. * @param zmax defines the far clip plane
  59879. * @returns the transformation matrix
  59880. */
  59881. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  59882. /**
  59883. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  59884. * @param matrix defines the matrix to use
  59885. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  59886. */
  59887. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  59888. /**
  59889. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  59890. * @param matrix defines the matrix to use
  59891. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  59892. */
  59893. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  59894. /**
  59895. * Compute the transpose of a given matrix
  59896. * @param matrix defines the matrix to transpose
  59897. * @returns the new matrix
  59898. */
  59899. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  59900. /**
  59901. * Compute the transpose of a matrix and store it in a target matrix
  59902. * @param matrix defines the matrix to transpose
  59903. * @param result defines the target matrix
  59904. */
  59905. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  59906. /**
  59907. * Computes a reflection matrix from a plane
  59908. * @param plane defines the reflection plane
  59909. * @returns a new matrix
  59910. */
  59911. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  59912. /**
  59913. * Computes a reflection matrix from a plane
  59914. * @param plane defines the reflection plane
  59915. * @param result defines the target matrix
  59916. */
  59917. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  59918. /**
  59919. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  59920. * @param xaxis defines the value of the 1st axis
  59921. * @param yaxis defines the value of the 2nd axis
  59922. * @param zaxis defines the value of the 3rd axis
  59923. * @param result defines the target matrix
  59924. */
  59925. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  59926. /**
  59927. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  59928. * @param quat defines the quaternion to use
  59929. * @param result defines the target matrix
  59930. */
  59931. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  59932. }
  59933. /**
  59934. * Represens a plane by the equation ax + by + cz + d = 0
  59935. */
  59936. export class Plane {
  59937. /**
  59938. * Normal of the plane (a,b,c)
  59939. */
  59940. normal: Vector3;
  59941. /**
  59942. * d component of the plane
  59943. */
  59944. d: number;
  59945. /**
  59946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  59947. * @param a a component of the plane
  59948. * @param b b component of the plane
  59949. * @param c c component of the plane
  59950. * @param d d component of the plane
  59951. */
  59952. constructor(a: number, b: number, c: number, d: number);
  59953. /**
  59954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  59955. */
  59956. asArray(): number[];
  59957. /**
  59958. * @returns a new plane copied from the current Plane.
  59959. */
  59960. clone(): Plane;
  59961. /**
  59962. * @returns the string "Plane".
  59963. */
  59964. getClassName(): string;
  59965. /**
  59966. * @returns the Plane hash code.
  59967. */
  59968. getHashCode(): number;
  59969. /**
  59970. * Normalize the current Plane in place.
  59971. * @returns the updated Plane.
  59972. */
  59973. normalize(): Plane;
  59974. /**
  59975. * Applies a transformation the plane and returns the result
  59976. * @param transformation the transformation matrix to be applied to the plane
  59977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  59978. */
  59979. transform(transformation: DeepImmutable<Matrix>): Plane;
  59980. /**
  59981. * Calcualtte the dot product between the point and the plane normal
  59982. * @param point point to calculate the dot product with
  59983. * @returns the dot product (float) of the point coordinates and the plane normal.
  59984. */
  59985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  59986. /**
  59987. * Updates the current Plane from the plane defined by the three given points.
  59988. * @param point1 one of the points used to contruct the plane
  59989. * @param point2 one of the points used to contruct the plane
  59990. * @param point3 one of the points used to contruct the plane
  59991. * @returns the updated Plane.
  59992. */
  59993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  59994. /**
  59995. * Checks if the plane is facing a given direction
  59996. * @param direction the direction to check if the plane is facing
  59997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  59998. * @returns True is the vector "direction" is the same side than the plane normal.
  59999. */
  60000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60001. /**
  60002. * Calculates the distance to a point
  60003. * @param point point to calculate distance to
  60004. * @returns the signed distance (float) from the given point to the Plane.
  60005. */
  60006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60007. /**
  60008. * Creates a plane from an array
  60009. * @param array the array to create a plane from
  60010. * @returns a new Plane from the given array.
  60011. */
  60012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60013. /**
  60014. * Creates a plane from three points
  60015. * @param point1 point used to create the plane
  60016. * @param point2 point used to create the plane
  60017. * @param point3 point used to create the plane
  60018. * @returns a new Plane defined by the three given points.
  60019. */
  60020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60021. /**
  60022. * Creates a plane from an origin point and a normal
  60023. * @param origin origin of the plane to be constructed
  60024. * @param normal normal of the plane to be constructed
  60025. * @returns a new Plane the normal vector to this plane at the given origin point.
  60026. * Note : the vector "normal" is updated because normalized.
  60027. */
  60028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60029. /**
  60030. * Calculates the distance from a plane and a point
  60031. * @param origin origin of the plane to be constructed
  60032. * @param normal normal of the plane to be constructed
  60033. * @param point point to calculate distance to
  60034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60035. */
  60036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60037. }
  60038. /**
  60039. * Class used to represent a viewport on screen
  60040. */
  60041. export class Viewport {
  60042. /** viewport left coordinate */
  60043. x: number;
  60044. /** viewport top coordinate */
  60045. y: number;
  60046. /**viewport width */
  60047. width: number;
  60048. /** viewport height */
  60049. height: number;
  60050. /**
  60051. * Creates a Viewport object located at (x, y) and sized (width, height)
  60052. * @param x defines viewport left coordinate
  60053. * @param y defines viewport top coordinate
  60054. * @param width defines the viewport width
  60055. * @param height defines the viewport height
  60056. */
  60057. constructor(
  60058. /** viewport left coordinate */
  60059. x: number,
  60060. /** viewport top coordinate */
  60061. y: number,
  60062. /**viewport width */
  60063. width: number,
  60064. /** viewport height */
  60065. height: number);
  60066. /**
  60067. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60068. * @param renderWidth defines the rendering width
  60069. * @param renderHeight defines the rendering height
  60070. * @returns a new Viewport
  60071. */
  60072. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60073. /**
  60074. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60075. * @param renderWidth defines the rendering width
  60076. * @param renderHeight defines the rendering height
  60077. * @param ref defines the target viewport
  60078. * @returns the current viewport
  60079. */
  60080. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60081. /**
  60082. * Returns a new Viewport copied from the current one
  60083. * @returns a new Viewport
  60084. */
  60085. clone(): Viewport;
  60086. }
  60087. /**
  60088. * Reprasents a camera frustum
  60089. */
  60090. export class Frustum {
  60091. /**
  60092. * Gets the planes representing the frustum
  60093. * @param transform matrix to be applied to the returned planes
  60094. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60095. */
  60096. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60097. /**
  60098. * Gets the near frustum plane transformed by the transform matrix
  60099. * @param transform transformation matrix to be applied to the resulting frustum plane
  60100. * @param frustumPlane the resuling frustum plane
  60101. */
  60102. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60103. /**
  60104. * Gets the far frustum plane transformed by the transform matrix
  60105. * @param transform transformation matrix to be applied to the resulting frustum plane
  60106. * @param frustumPlane the resuling frustum plane
  60107. */
  60108. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60109. /**
  60110. * Gets the left frustum plane transformed by the transform matrix
  60111. * @param transform transformation matrix to be applied to the resulting frustum plane
  60112. * @param frustumPlane the resuling frustum plane
  60113. */
  60114. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60115. /**
  60116. * Gets the right frustum plane transformed by the transform matrix
  60117. * @param transform transformation matrix to be applied to the resulting frustum plane
  60118. * @param frustumPlane the resuling frustum plane
  60119. */
  60120. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60121. /**
  60122. * Gets the top frustum plane transformed by the transform matrix
  60123. * @param transform transformation matrix to be applied to the resulting frustum plane
  60124. * @param frustumPlane the resuling frustum plane
  60125. */
  60126. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60127. /**
  60128. * Gets the bottom frustum plane transformed by the transform matrix
  60129. * @param transform transformation matrix to be applied to the resulting frustum plane
  60130. * @param frustumPlane the resuling frustum plane
  60131. */
  60132. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60133. /**
  60134. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60135. * @param transform transformation matrix to be applied to the resulting frustum planes
  60136. * @param frustumPlanes the resuling frustum planes
  60137. */
  60138. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60139. }
  60140. /** Defines supported spaces */
  60141. export enum Space {
  60142. /** Local (object) space */
  60143. LOCAL = 0,
  60144. /** World space */
  60145. WORLD = 1,
  60146. /** Bone space */
  60147. BONE = 2
  60148. }
  60149. /** Defines the 3 main axes */
  60150. export class Axis {
  60151. /** X axis */
  60152. static X: Vector3;
  60153. /** Y axis */
  60154. static Y: Vector3;
  60155. /** Z axis */
  60156. static Z: Vector3;
  60157. }
  60158. /** Class used to represent a Bezier curve */
  60159. export class BezierCurve {
  60160. /**
  60161. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60162. * @param t defines the time
  60163. * @param x1 defines the left coordinate on X axis
  60164. * @param y1 defines the left coordinate on Y axis
  60165. * @param x2 defines the right coordinate on X axis
  60166. * @param y2 defines the right coordinate on Y axis
  60167. * @returns the interpolated value
  60168. */
  60169. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60170. }
  60171. /**
  60172. * Defines potential orientation for back face culling
  60173. */
  60174. export enum Orientation {
  60175. /**
  60176. * Clockwise
  60177. */
  60178. CW = 0,
  60179. /** Counter clockwise */
  60180. CCW = 1
  60181. }
  60182. /**
  60183. * Defines angle representation
  60184. */
  60185. export class Angle {
  60186. private _radians;
  60187. /**
  60188. * Creates an Angle object of "radians" radians (float).
  60189. * @param radians the angle in radians
  60190. */
  60191. constructor(radians: number);
  60192. /**
  60193. * Get value in degrees
  60194. * @returns the Angle value in degrees (float)
  60195. */
  60196. degrees(): number;
  60197. /**
  60198. * Get value in radians
  60199. * @returns the Angle value in radians (float)
  60200. */
  60201. radians(): number;
  60202. /**
  60203. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60204. * @param a defines first vector
  60205. * @param b defines second vector
  60206. * @returns a new Angle
  60207. */
  60208. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60209. /**
  60210. * Gets a new Angle object from the given float in radians
  60211. * @param radians defines the angle value in radians
  60212. * @returns a new Angle
  60213. */
  60214. static FromRadians(radians: number): Angle;
  60215. /**
  60216. * Gets a new Angle object from the given float in degrees
  60217. * @param degrees defines the angle value in degrees
  60218. * @returns a new Angle
  60219. */
  60220. static FromDegrees(degrees: number): Angle;
  60221. }
  60222. /**
  60223. * This represents an arc in a 2d space.
  60224. */
  60225. export class Arc2 {
  60226. /** Defines the start point of the arc */
  60227. startPoint: Vector2;
  60228. /** Defines the mid point of the arc */
  60229. midPoint: Vector2;
  60230. /** Defines the end point of the arc */
  60231. endPoint: Vector2;
  60232. /**
  60233. * Defines the center point of the arc.
  60234. */
  60235. centerPoint: Vector2;
  60236. /**
  60237. * Defines the radius of the arc.
  60238. */
  60239. radius: number;
  60240. /**
  60241. * Defines the angle of the arc (from mid point to end point).
  60242. */
  60243. angle: Angle;
  60244. /**
  60245. * Defines the start angle of the arc (from start point to middle point).
  60246. */
  60247. startAngle: Angle;
  60248. /**
  60249. * Defines the orientation of the arc (clock wise/counter clock wise).
  60250. */
  60251. orientation: Orientation;
  60252. /**
  60253. * Creates an Arc object from the three given points : start, middle and end.
  60254. * @param startPoint Defines the start point of the arc
  60255. * @param midPoint Defines the midlle point of the arc
  60256. * @param endPoint Defines the end point of the arc
  60257. */
  60258. constructor(
  60259. /** Defines the start point of the arc */
  60260. startPoint: Vector2,
  60261. /** Defines the mid point of the arc */
  60262. midPoint: Vector2,
  60263. /** Defines the end point of the arc */
  60264. endPoint: Vector2);
  60265. }
  60266. /**
  60267. * Represents a 2D path made up of multiple 2D points
  60268. */
  60269. export class Path2 {
  60270. private _points;
  60271. private _length;
  60272. /**
  60273. * If the path start and end point are the same
  60274. */
  60275. closed: boolean;
  60276. /**
  60277. * Creates a Path2 object from the starting 2D coordinates x and y.
  60278. * @param x the starting points x value
  60279. * @param y the starting points y value
  60280. */
  60281. constructor(x: number, y: number);
  60282. /**
  60283. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60284. * @param x the added points x value
  60285. * @param y the added points y value
  60286. * @returns the updated Path2.
  60287. */
  60288. addLineTo(x: number, y: number): Path2;
  60289. /**
  60290. * 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.
  60291. * @param midX middle point x value
  60292. * @param midY middle point y value
  60293. * @param endX end point x value
  60294. * @param endY end point y value
  60295. * @param numberOfSegments (default: 36)
  60296. * @returns the updated Path2.
  60297. */
  60298. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60299. /**
  60300. * Closes the Path2.
  60301. * @returns the Path2.
  60302. */
  60303. close(): Path2;
  60304. /**
  60305. * Gets the sum of the distance between each sequential point in the path
  60306. * @returns the Path2 total length (float).
  60307. */
  60308. length(): number;
  60309. /**
  60310. * Gets the points which construct the path
  60311. * @returns the Path2 internal array of points.
  60312. */
  60313. getPoints(): Vector2[];
  60314. /**
  60315. * Retreives the point at the distance aways from the starting point
  60316. * @param normalizedLengthPosition the length along the path to retreive the point from
  60317. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60318. */
  60319. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60320. /**
  60321. * Creates a new path starting from an x and y position
  60322. * @param x starting x value
  60323. * @param y starting y value
  60324. * @returns a new Path2 starting at the coordinates (x, y).
  60325. */
  60326. static StartingAt(x: number, y: number): Path2;
  60327. }
  60328. /**
  60329. * Represents a 3D path made up of multiple 3D points
  60330. */
  60331. export class Path3D {
  60332. /**
  60333. * an array of Vector3, the curve axis of the Path3D
  60334. */
  60335. path: Vector3[];
  60336. private _curve;
  60337. private _distances;
  60338. private _tangents;
  60339. private _normals;
  60340. private _binormals;
  60341. private _raw;
  60342. /**
  60343. * new Path3D(path, normal, raw)
  60344. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60345. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60346. * @param path an array of Vector3, the curve axis of the Path3D
  60347. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60348. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60349. */
  60350. constructor(
  60351. /**
  60352. * an array of Vector3, the curve axis of the Path3D
  60353. */
  60354. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60355. /**
  60356. * Returns the Path3D array of successive Vector3 designing its curve.
  60357. * @returns the Path3D array of successive Vector3 designing its curve.
  60358. */
  60359. getCurve(): Vector3[];
  60360. /**
  60361. * Returns an array populated with tangent vectors on each Path3D curve point.
  60362. * @returns an array populated with tangent vectors on each Path3D curve point.
  60363. */
  60364. getTangents(): Vector3[];
  60365. /**
  60366. * Returns an array populated with normal vectors on each Path3D curve point.
  60367. * @returns an array populated with normal vectors on each Path3D curve point.
  60368. */
  60369. getNormals(): Vector3[];
  60370. /**
  60371. * Returns an array populated with binormal vectors on each Path3D curve point.
  60372. * @returns an array populated with binormal vectors on each Path3D curve point.
  60373. */
  60374. getBinormals(): Vector3[];
  60375. /**
  60376. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60377. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60378. */
  60379. getDistances(): number[];
  60380. /**
  60381. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60382. * @param path path which all values are copied into the curves points
  60383. * @param firstNormal which should be projected onto the curve
  60384. * @returns the same object updated.
  60385. */
  60386. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60387. private _compute;
  60388. private _getFirstNonNullVector;
  60389. private _getLastNonNullVector;
  60390. private _normalVector;
  60391. }
  60392. /**
  60393. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60394. * A Curve3 is designed from a series of successive Vector3.
  60395. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60396. */
  60397. export class Curve3 {
  60398. private _points;
  60399. private _length;
  60400. /**
  60401. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60402. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60403. * @param v1 (Vector3) the control point
  60404. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60405. * @param nbPoints (integer) the wanted number of points in the curve
  60406. * @returns the created Curve3
  60407. */
  60408. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60409. /**
  60410. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60411. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60412. * @param v1 (Vector3) the first control point
  60413. * @param v2 (Vector3) the second control point
  60414. * @param v3 (Vector3) the end point of the Cubic Bezier
  60415. * @param nbPoints (integer) the wanted number of points in the curve
  60416. * @returns the created Curve3
  60417. */
  60418. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60419. /**
  60420. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60421. * @param p1 (Vector3) the origin point of the Hermite Spline
  60422. * @param t1 (Vector3) the tangent vector at the origin point
  60423. * @param p2 (Vector3) the end point of the Hermite Spline
  60424. * @param t2 (Vector3) the tangent vector at the end point
  60425. * @param nbPoints (integer) the wanted number of points in the curve
  60426. * @returns the created Curve3
  60427. */
  60428. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60429. /**
  60430. * Returns a Curve3 object along a CatmullRom Spline curve :
  60431. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60432. * @param nbPoints (integer) the wanted number of points between each curve control points
  60433. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60434. * @returns the created Curve3
  60435. */
  60436. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60437. /**
  60438. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60439. * A Curve3 is designed from a series of successive Vector3.
  60440. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60441. * @param points points which make up the curve
  60442. */
  60443. constructor(points: Vector3[]);
  60444. /**
  60445. * @returns the Curve3 stored array of successive Vector3
  60446. */
  60447. getPoints(): Vector3[];
  60448. /**
  60449. * @returns the computed length (float) of the curve.
  60450. */
  60451. length(): number;
  60452. /**
  60453. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60454. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60455. * curveA and curveB keep unchanged.
  60456. * @param curve the curve to continue from this curve
  60457. * @returns the newly constructed curve
  60458. */
  60459. continue(curve: DeepImmutable<Curve3>): Curve3;
  60460. private _computeLength;
  60461. }
  60462. /**
  60463. * Contains position and normal vectors for a vertex
  60464. */
  60465. export class PositionNormalVertex {
  60466. /** the position of the vertex (defaut: 0,0,0) */
  60467. position: Vector3;
  60468. /** the normal of the vertex (defaut: 0,1,0) */
  60469. normal: Vector3;
  60470. /**
  60471. * Creates a PositionNormalVertex
  60472. * @param position the position of the vertex (defaut: 0,0,0)
  60473. * @param normal the normal of the vertex (defaut: 0,1,0)
  60474. */
  60475. constructor(
  60476. /** the position of the vertex (defaut: 0,0,0) */
  60477. position?: Vector3,
  60478. /** the normal of the vertex (defaut: 0,1,0) */
  60479. normal?: Vector3);
  60480. /**
  60481. * Clones the PositionNormalVertex
  60482. * @returns the cloned PositionNormalVertex
  60483. */
  60484. clone(): PositionNormalVertex;
  60485. }
  60486. /**
  60487. * Contains position, normal and uv vectors for a vertex
  60488. */
  60489. export class PositionNormalTextureVertex {
  60490. /** the position of the vertex (defaut: 0,0,0) */
  60491. position: Vector3;
  60492. /** the normal of the vertex (defaut: 0,1,0) */
  60493. normal: Vector3;
  60494. /** the uv of the vertex (default: 0,0) */
  60495. uv: Vector2;
  60496. /**
  60497. * Creates a PositionNormalTextureVertex
  60498. * @param position the position of the vertex (defaut: 0,0,0)
  60499. * @param normal the normal of the vertex (defaut: 0,1,0)
  60500. * @param uv the uv of the vertex (default: 0,0)
  60501. */
  60502. constructor(
  60503. /** the position of the vertex (defaut: 0,0,0) */
  60504. position?: Vector3,
  60505. /** the normal of the vertex (defaut: 0,1,0) */
  60506. normal?: Vector3,
  60507. /** the uv of the vertex (default: 0,0) */
  60508. uv?: Vector2);
  60509. /**
  60510. * Clones the PositionNormalTextureVertex
  60511. * @returns the cloned PositionNormalTextureVertex
  60512. */
  60513. clone(): PositionNormalTextureVertex;
  60514. }
  60515. /**
  60516. * @hidden
  60517. */
  60518. export class Tmp {
  60519. static Color3: Color3[];
  60520. static Color4: Color4[];
  60521. static Vector2: Vector2[];
  60522. static Vector3: Vector3[];
  60523. static Vector4: Vector4[];
  60524. static Quaternion: Quaternion[];
  60525. static Matrix: Matrix[];
  60526. }
  60527. }
  60528. declare module BABYLON {
  60529. /**
  60530. * Class used to enable access to offline support
  60531. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60532. */
  60533. export interface IOfflineProvider {
  60534. /**
  60535. * Gets a boolean indicating if scene must be saved in the database
  60536. */
  60537. enableSceneOffline: boolean;
  60538. /**
  60539. * Gets a boolean indicating if textures must be saved in the database
  60540. */
  60541. enableTexturesOffline: boolean;
  60542. /**
  60543. * Open the offline support and make it available
  60544. * @param successCallback defines the callback to call on success
  60545. * @param errorCallback defines the callback to call on error
  60546. */
  60547. open(successCallback: () => void, errorCallback: () => void): void;
  60548. /**
  60549. * Loads an image from the offline support
  60550. * @param url defines the url to load from
  60551. * @param image defines the target DOM image
  60552. */
  60553. loadImage(url: string, image: HTMLImageElement): void;
  60554. /**
  60555. * Loads a file from offline support
  60556. * @param url defines the URL to load from
  60557. * @param sceneLoaded defines a callback to call on success
  60558. * @param progressCallBack defines a callback to call when progress changed
  60559. * @param errorCallback defines a callback to call on error
  60560. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60561. */
  60562. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60563. }
  60564. }
  60565. declare module BABYLON {
  60566. /**
  60567. * A class serves as a medium between the observable and its observers
  60568. */
  60569. export class EventState {
  60570. /**
  60571. * Create a new EventState
  60572. * @param mask defines the mask associated with this state
  60573. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60574. * @param target defines the original target of the state
  60575. * @param currentTarget defines the current target of the state
  60576. */
  60577. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60578. /**
  60579. * Initialize the current event state
  60580. * @param mask defines the mask associated with this state
  60581. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60582. * @param target defines the original target of the state
  60583. * @param currentTarget defines the current target of the state
  60584. * @returns the current event state
  60585. */
  60586. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60587. /**
  60588. * An Observer can set this property to true to prevent subsequent observers of being notified
  60589. */
  60590. skipNextObservers: boolean;
  60591. /**
  60592. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60593. */
  60594. mask: number;
  60595. /**
  60596. * The object that originally notified the event
  60597. */
  60598. target?: any;
  60599. /**
  60600. * The current object in the bubbling phase
  60601. */
  60602. currentTarget?: any;
  60603. /**
  60604. * This will be populated with the return value of the last function that was executed.
  60605. * If it is the first function in the callback chain it will be the event data.
  60606. */
  60607. lastReturnValue?: any;
  60608. }
  60609. /**
  60610. * Represent an Observer registered to a given Observable object.
  60611. */
  60612. export class Observer<T> {
  60613. /**
  60614. * Defines the callback to call when the observer is notified
  60615. */
  60616. callback: (eventData: T, eventState: EventState) => void;
  60617. /**
  60618. * Defines the mask of the observer (used to filter notifications)
  60619. */
  60620. mask: number;
  60621. /**
  60622. * Defines the current scope used to restore the JS context
  60623. */
  60624. scope: any;
  60625. /** @hidden */
  60626. _willBeUnregistered: boolean;
  60627. /**
  60628. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60629. */
  60630. unregisterOnNextCall: boolean;
  60631. /**
  60632. * Creates a new observer
  60633. * @param callback defines the callback to call when the observer is notified
  60634. * @param mask defines the mask of the observer (used to filter notifications)
  60635. * @param scope defines the current scope used to restore the JS context
  60636. */
  60637. constructor(
  60638. /**
  60639. * Defines the callback to call when the observer is notified
  60640. */
  60641. callback: (eventData: T, eventState: EventState) => void,
  60642. /**
  60643. * Defines the mask of the observer (used to filter notifications)
  60644. */
  60645. mask: number,
  60646. /**
  60647. * Defines the current scope used to restore the JS context
  60648. */
  60649. scope?: any);
  60650. }
  60651. /**
  60652. * Represent a list of observers registered to multiple Observables object.
  60653. */
  60654. export class MultiObserver<T> {
  60655. private _observers;
  60656. private _observables;
  60657. /**
  60658. * Release associated resources
  60659. */
  60660. dispose(): void;
  60661. /**
  60662. * Raise a callback when one of the observable will notify
  60663. * @param observables defines a list of observables to watch
  60664. * @param callback defines the callback to call on notification
  60665. * @param mask defines the mask used to filter notifications
  60666. * @param scope defines the current scope used to restore the JS context
  60667. * @returns the new MultiObserver
  60668. */
  60669. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60670. }
  60671. /**
  60672. * The Observable class is a simple implementation of the Observable pattern.
  60673. *
  60674. * 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.
  60675. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60676. * 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).
  60677. * 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.
  60678. */
  60679. export class Observable<T> {
  60680. private _observers;
  60681. private _eventState;
  60682. private _onObserverAdded;
  60683. /**
  60684. * Creates a new observable
  60685. * @param onObserverAdded defines a callback to call when a new observer is added
  60686. */
  60687. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60688. /**
  60689. * Create a new Observer with the specified callback
  60690. * @param callback the callback that will be executed for that Observer
  60691. * @param mask the mask used to filter observers
  60692. * @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.
  60693. * @param scope optional scope for the callback to be called from
  60694. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60695. * @returns the new observer created for the callback
  60696. */
  60697. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60698. /**
  60699. * Create a new Observer with the specified callback and unregisters after the next notification
  60700. * @param callback the callback that will be executed for that Observer
  60701. * @returns the new observer created for the callback
  60702. */
  60703. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60704. /**
  60705. * Remove an Observer from the Observable object
  60706. * @param observer the instance of the Observer to remove
  60707. * @returns false if it doesn't belong to this Observable
  60708. */
  60709. remove(observer: Nullable<Observer<T>>): boolean;
  60710. /**
  60711. * Remove a callback from the Observable object
  60712. * @param callback the callback to remove
  60713. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60714. * @returns false if it doesn't belong to this Observable
  60715. */
  60716. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60717. private _deferUnregister;
  60718. private _remove;
  60719. /**
  60720. * Notify all Observers by calling their respective callback with the given data
  60721. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60722. * @param eventData defines the data to send to all observers
  60723. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60724. * @param target defines the original target of the state
  60725. * @param currentTarget defines the current target of the state
  60726. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60727. */
  60728. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60729. /**
  60730. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60731. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60732. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60733. * and it is crucial that all callbacks will be executed.
  60734. * The order of the callbacks is kept, callbacks are not executed parallel.
  60735. *
  60736. * @param eventData The data to be sent to each callback
  60737. * @param mask is used to filter observers defaults to -1
  60738. * @param target defines the callback target (see EventState)
  60739. * @param currentTarget defines he current object in the bubbling phase
  60740. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60741. */
  60742. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60743. /**
  60744. * Notify a specific observer
  60745. * @param observer defines the observer to notify
  60746. * @param eventData defines the data to be sent to each callback
  60747. * @param mask is used to filter observers defaults to -1
  60748. */
  60749. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60750. /**
  60751. * Gets a boolean indicating if the observable has at least one observer
  60752. * @returns true is the Observable has at least one Observer registered
  60753. */
  60754. hasObservers(): boolean;
  60755. /**
  60756. * Clear the list of observers
  60757. */
  60758. clear(): void;
  60759. /**
  60760. * Clone the current observable
  60761. * @returns a new observable
  60762. */
  60763. clone(): Observable<T>;
  60764. /**
  60765. * Does this observable handles observer registered with a given mask
  60766. * @param mask defines the mask to be tested
  60767. * @return whether or not one observer registered with the given mask is handeled
  60768. **/
  60769. hasSpecificMask(mask?: number): boolean;
  60770. }
  60771. }
  60772. declare module BABYLON {
  60773. /**
  60774. * Class used to help managing file picking and drag'n'drop
  60775. * File Storage
  60776. */
  60777. export class FilesInputStore {
  60778. /**
  60779. * List of files ready to be loaded
  60780. */
  60781. static FilesToLoad: {
  60782. [key: string]: File;
  60783. };
  60784. }
  60785. }
  60786. declare module BABYLON {
  60787. /** Defines the cross module used constants to avoid circular dependncies */
  60788. export class Constants {
  60789. /** Defines that alpha blending is disabled */
  60790. static readonly ALPHA_DISABLE: number;
  60791. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60792. static readonly ALPHA_ADD: number;
  60793. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60794. static readonly ALPHA_COMBINE: number;
  60795. /** Defines that alpha blending to DEST - SRC * DEST */
  60796. static readonly ALPHA_SUBTRACT: number;
  60797. /** Defines that alpha blending to SRC * DEST */
  60798. static readonly ALPHA_MULTIPLY: number;
  60799. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60800. static readonly ALPHA_MAXIMIZED: number;
  60801. /** Defines that alpha blending to SRC + DEST */
  60802. static readonly ALPHA_ONEONE: number;
  60803. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60804. static readonly ALPHA_PREMULTIPLIED: number;
  60805. /**
  60806. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60807. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60808. */
  60809. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60810. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60811. static readonly ALPHA_INTERPOLATE: number;
  60812. /**
  60813. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60814. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60815. */
  60816. static readonly ALPHA_SCREENMODE: number;
  60817. /** Defines that the ressource is not delayed*/
  60818. static readonly DELAYLOADSTATE_NONE: number;
  60819. /** Defines that the ressource was successfully delay loaded */
  60820. static readonly DELAYLOADSTATE_LOADED: number;
  60821. /** Defines that the ressource is currently delay loading */
  60822. static readonly DELAYLOADSTATE_LOADING: number;
  60823. /** Defines that the ressource is delayed and has not started loading */
  60824. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60825. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60826. static readonly NEVER: number;
  60827. /** 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 */
  60828. static readonly ALWAYS: number;
  60829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60830. static readonly LESS: number;
  60831. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60832. static readonly EQUAL: number;
  60833. /** 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 */
  60834. static readonly LEQUAL: number;
  60835. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60836. static readonly GREATER: number;
  60837. /** 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 */
  60838. static readonly GEQUAL: number;
  60839. /** 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 */
  60840. static readonly NOTEQUAL: number;
  60841. /** Passed to stencilOperation to specify that stencil value must be kept */
  60842. static readonly KEEP: number;
  60843. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60844. static readonly REPLACE: number;
  60845. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60846. static readonly INCR: number;
  60847. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60848. static readonly DECR: number;
  60849. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60850. static readonly INVERT: number;
  60851. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60852. static readonly INCR_WRAP: number;
  60853. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60854. static readonly DECR_WRAP: number;
  60855. /** Texture is not repeating outside of 0..1 UVs */
  60856. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60857. /** Texture is repeating outside of 0..1 UVs */
  60858. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  60859. /** Texture is repeating and mirrored */
  60860. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  60861. /** ALPHA */
  60862. static readonly TEXTUREFORMAT_ALPHA: number;
  60863. /** LUMINANCE */
  60864. static readonly TEXTUREFORMAT_LUMINANCE: number;
  60865. /** LUMINANCE_ALPHA */
  60866. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  60867. /** RGB */
  60868. static readonly TEXTUREFORMAT_RGB: number;
  60869. /** RGBA */
  60870. static readonly TEXTUREFORMAT_RGBA: number;
  60871. /** RED */
  60872. static readonly TEXTUREFORMAT_RED: number;
  60873. /** RED (2nd reference) */
  60874. static readonly TEXTUREFORMAT_R: number;
  60875. /** RG */
  60876. static readonly TEXTUREFORMAT_RG: number;
  60877. /** RED_INTEGER */
  60878. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  60879. /** RED_INTEGER (2nd reference) */
  60880. static readonly TEXTUREFORMAT_R_INTEGER: number;
  60881. /** RG_INTEGER */
  60882. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  60883. /** RGB_INTEGER */
  60884. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  60885. /** RGBA_INTEGER */
  60886. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  60887. /** UNSIGNED_BYTE */
  60888. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  60889. /** UNSIGNED_BYTE (2nd reference) */
  60890. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  60891. /** FLOAT */
  60892. static readonly TEXTURETYPE_FLOAT: number;
  60893. /** HALF_FLOAT */
  60894. static readonly TEXTURETYPE_HALF_FLOAT: number;
  60895. /** BYTE */
  60896. static readonly TEXTURETYPE_BYTE: number;
  60897. /** SHORT */
  60898. static readonly TEXTURETYPE_SHORT: number;
  60899. /** UNSIGNED_SHORT */
  60900. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  60901. /** INT */
  60902. static readonly TEXTURETYPE_INT: number;
  60903. /** UNSIGNED_INT */
  60904. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  60905. /** UNSIGNED_SHORT_4_4_4_4 */
  60906. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  60907. /** UNSIGNED_SHORT_5_5_5_1 */
  60908. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  60909. /** UNSIGNED_SHORT_5_6_5 */
  60910. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  60911. /** UNSIGNED_INT_2_10_10_10_REV */
  60912. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  60913. /** UNSIGNED_INT_24_8 */
  60914. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  60915. /** UNSIGNED_INT_10F_11F_11F_REV */
  60916. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  60917. /** UNSIGNED_INT_5_9_9_9_REV */
  60918. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  60919. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  60920. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60921. /** nearest is mag = nearest and min = nearest and mip = linear */
  60922. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  60923. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60924. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  60925. /** Trilinear is mag = linear and min = linear and mip = linear */
  60926. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  60927. /** nearest is mag = nearest and min = nearest and mip = linear */
  60928. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  60929. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60930. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  60931. /** Trilinear is mag = linear and min = linear and mip = linear */
  60932. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  60933. /** mag = nearest and min = nearest and mip = nearest */
  60934. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  60935. /** mag = nearest and min = linear and mip = nearest */
  60936. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  60937. /** mag = nearest and min = linear and mip = linear */
  60938. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  60939. /** mag = nearest and min = linear and mip = none */
  60940. static readonly TEXTURE_NEAREST_LINEAR: number;
  60941. /** mag = nearest and min = nearest and mip = none */
  60942. static readonly TEXTURE_NEAREST_NEAREST: number;
  60943. /** mag = linear and min = nearest and mip = nearest */
  60944. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  60945. /** mag = linear and min = nearest and mip = linear */
  60946. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  60947. /** mag = linear and min = linear and mip = none */
  60948. static readonly TEXTURE_LINEAR_LINEAR: number;
  60949. /** mag = linear and min = nearest and mip = none */
  60950. static readonly TEXTURE_LINEAR_NEAREST: number;
  60951. /** Explicit coordinates mode */
  60952. static readonly TEXTURE_EXPLICIT_MODE: number;
  60953. /** Spherical coordinates mode */
  60954. static readonly TEXTURE_SPHERICAL_MODE: number;
  60955. /** Planar coordinates mode */
  60956. static readonly TEXTURE_PLANAR_MODE: number;
  60957. /** Cubic coordinates mode */
  60958. static readonly TEXTURE_CUBIC_MODE: number;
  60959. /** Projection coordinates mode */
  60960. static readonly TEXTURE_PROJECTION_MODE: number;
  60961. /** Skybox coordinates mode */
  60962. static readonly TEXTURE_SKYBOX_MODE: number;
  60963. /** Inverse Cubic coordinates mode */
  60964. static readonly TEXTURE_INVCUBIC_MODE: number;
  60965. /** Equirectangular coordinates mode */
  60966. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  60967. /** Equirectangular Fixed coordinates mode */
  60968. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  60969. /** Equirectangular Fixed Mirrored coordinates mode */
  60970. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  60971. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  60972. static readonly SCALEMODE_FLOOR: number;
  60973. /** Defines that texture rescaling will look for the nearest power of 2 size */
  60974. static readonly SCALEMODE_NEAREST: number;
  60975. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  60976. static readonly SCALEMODE_CEILING: number;
  60977. /**
  60978. * The dirty texture flag value
  60979. */
  60980. static readonly MATERIAL_TextureDirtyFlag: number;
  60981. /**
  60982. * The dirty light flag value
  60983. */
  60984. static readonly MATERIAL_LightDirtyFlag: number;
  60985. /**
  60986. * The dirty fresnel flag value
  60987. */
  60988. static readonly MATERIAL_FresnelDirtyFlag: number;
  60989. /**
  60990. * The dirty attribute flag value
  60991. */
  60992. static readonly MATERIAL_AttributesDirtyFlag: number;
  60993. /**
  60994. * The dirty misc flag value
  60995. */
  60996. static readonly MATERIAL_MiscDirtyFlag: number;
  60997. /**
  60998. * The all dirty flag value
  60999. */
  61000. static readonly MATERIAL_AllDirtyFlag: number;
  61001. /**
  61002. * Returns the triangle fill mode
  61003. */
  61004. static readonly MATERIAL_TriangleFillMode: number;
  61005. /**
  61006. * Returns the wireframe mode
  61007. */
  61008. static readonly MATERIAL_WireFrameFillMode: number;
  61009. /**
  61010. * Returns the point fill mode
  61011. */
  61012. static readonly MATERIAL_PointFillMode: number;
  61013. /**
  61014. * Returns the point list draw mode
  61015. */
  61016. static readonly MATERIAL_PointListDrawMode: number;
  61017. /**
  61018. * Returns the line list draw mode
  61019. */
  61020. static readonly MATERIAL_LineListDrawMode: number;
  61021. /**
  61022. * Returns the line loop draw mode
  61023. */
  61024. static readonly MATERIAL_LineLoopDrawMode: number;
  61025. /**
  61026. * Returns the line strip draw mode
  61027. */
  61028. static readonly MATERIAL_LineStripDrawMode: number;
  61029. /**
  61030. * Returns the triangle strip draw mode
  61031. */
  61032. static readonly MATERIAL_TriangleStripDrawMode: number;
  61033. /**
  61034. * Returns the triangle fan draw mode
  61035. */
  61036. static readonly MATERIAL_TriangleFanDrawMode: number;
  61037. /**
  61038. * Stores the clock-wise side orientation
  61039. */
  61040. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61041. /**
  61042. * Stores the counter clock-wise side orientation
  61043. */
  61044. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61045. /**
  61046. * Nothing
  61047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61048. */
  61049. static readonly ACTION_NothingTrigger: number;
  61050. /**
  61051. * On pick
  61052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61053. */
  61054. static readonly ACTION_OnPickTrigger: number;
  61055. /**
  61056. * On left pick
  61057. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61058. */
  61059. static readonly ACTION_OnLeftPickTrigger: number;
  61060. /**
  61061. * On right pick
  61062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61063. */
  61064. static readonly ACTION_OnRightPickTrigger: number;
  61065. /**
  61066. * On center pick
  61067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61068. */
  61069. static readonly ACTION_OnCenterPickTrigger: number;
  61070. /**
  61071. * On pick down
  61072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61073. */
  61074. static readonly ACTION_OnPickDownTrigger: number;
  61075. /**
  61076. * On double pick
  61077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61078. */
  61079. static readonly ACTION_OnDoublePickTrigger: number;
  61080. /**
  61081. * On pick up
  61082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61083. */
  61084. static readonly ACTION_OnPickUpTrigger: number;
  61085. /**
  61086. * On pick out.
  61087. * This trigger will only be raised if you also declared a OnPickDown
  61088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61089. */
  61090. static readonly ACTION_OnPickOutTrigger: number;
  61091. /**
  61092. * On long press
  61093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61094. */
  61095. static readonly ACTION_OnLongPressTrigger: number;
  61096. /**
  61097. * On pointer over
  61098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61099. */
  61100. static readonly ACTION_OnPointerOverTrigger: number;
  61101. /**
  61102. * On pointer out
  61103. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61104. */
  61105. static readonly ACTION_OnPointerOutTrigger: number;
  61106. /**
  61107. * On every frame
  61108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61109. */
  61110. static readonly ACTION_OnEveryFrameTrigger: number;
  61111. /**
  61112. * On intersection enter
  61113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61114. */
  61115. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61116. /**
  61117. * On intersection exit
  61118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61119. */
  61120. static readonly ACTION_OnIntersectionExitTrigger: number;
  61121. /**
  61122. * On key down
  61123. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61124. */
  61125. static readonly ACTION_OnKeyDownTrigger: number;
  61126. /**
  61127. * On key up
  61128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61129. */
  61130. static readonly ACTION_OnKeyUpTrigger: number;
  61131. /**
  61132. * Billboard mode will only apply to Y axis
  61133. */
  61134. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61135. /**
  61136. * Billboard mode will apply to all axes
  61137. */
  61138. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61139. /**
  61140. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61141. */
  61142. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61143. /**
  61144. * Gets or sets base Assets URL
  61145. */
  61146. static readonly PARTICLES_BaseAssetsUrl: string;
  61147. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61148. * Test order :
  61149. * Is the bounding sphere outside the frustum ?
  61150. * If not, are the bounding box vertices outside the frustum ?
  61151. * It not, then the cullable object is in the frustum.
  61152. */
  61153. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61154. /** Culling strategy : Bounding Sphere Only.
  61155. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61156. * It's also less accurate than the standard because some not visible objects can still be selected.
  61157. * Test : is the bounding sphere outside the frustum ?
  61158. * If not, then the cullable object is in the frustum.
  61159. */
  61160. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61161. /** Culling strategy : Optimistic Inclusion.
  61162. * This in an inclusion test first, then the standard exclusion test.
  61163. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61164. * 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.
  61165. * Anyway, it's as accurate as the standard strategy.
  61166. * Test :
  61167. * Is the cullable object bounding sphere center in the frustum ?
  61168. * If not, apply the default culling strategy.
  61169. */
  61170. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61171. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61172. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61173. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61174. * 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.
  61175. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61176. * Test :
  61177. * Is the cullable object bounding sphere center in the frustum ?
  61178. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61179. */
  61180. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61181. /**
  61182. * No logging while loading
  61183. */
  61184. static readonly SCENELOADER_NO_LOGGING: number;
  61185. /**
  61186. * Minimal logging while loading
  61187. */
  61188. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61189. /**
  61190. * Summary logging while loading
  61191. */
  61192. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61193. /**
  61194. * Detailled logging while loading
  61195. */
  61196. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61197. }
  61198. }
  61199. declare module BABYLON {
  61200. /**
  61201. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61202. * Babylon.js
  61203. */
  61204. export class DomManagement {
  61205. /**
  61206. * Checks if the window object exists
  61207. * @returns true if the window object exists
  61208. */
  61209. static IsWindowObjectExist(): boolean;
  61210. /**
  61211. * Extracts text content from a DOM element hierarchy
  61212. * @param element defines the root element
  61213. * @returns a string
  61214. */
  61215. static GetDOMTextContent(element: HTMLElement): string;
  61216. }
  61217. }
  61218. declare module BABYLON {
  61219. /**
  61220. * Logger used througouht the application to allow configuration of
  61221. * the log level required for the messages.
  61222. */
  61223. export class Logger {
  61224. /**
  61225. * No log
  61226. */
  61227. static readonly NoneLogLevel: number;
  61228. /**
  61229. * Only message logs
  61230. */
  61231. static readonly MessageLogLevel: number;
  61232. /**
  61233. * Only warning logs
  61234. */
  61235. static readonly WarningLogLevel: number;
  61236. /**
  61237. * Only error logs
  61238. */
  61239. static readonly ErrorLogLevel: number;
  61240. /**
  61241. * All logs
  61242. */
  61243. static readonly AllLogLevel: number;
  61244. private static _LogCache;
  61245. /**
  61246. * Gets a value indicating the number of loading errors
  61247. * @ignorenaming
  61248. */
  61249. static errorsCount: number;
  61250. /**
  61251. * Callback called when a new log is added
  61252. */
  61253. static OnNewCacheEntry: (entry: string) => void;
  61254. private static _AddLogEntry;
  61255. private static _FormatMessage;
  61256. private static _LogDisabled;
  61257. private static _LogEnabled;
  61258. private static _WarnDisabled;
  61259. private static _WarnEnabled;
  61260. private static _ErrorDisabled;
  61261. private static _ErrorEnabled;
  61262. /**
  61263. * Log a message to the console
  61264. */
  61265. static Log: (message: string) => void;
  61266. /**
  61267. * Write a warning message to the console
  61268. */
  61269. static Warn: (message: string) => void;
  61270. /**
  61271. * Write an error message to the console
  61272. */
  61273. static Error: (message: string) => void;
  61274. /**
  61275. * Gets current log cache (list of logs)
  61276. */
  61277. static readonly LogCache: string;
  61278. /**
  61279. * Clears the log cache
  61280. */
  61281. static ClearLogCache(): void;
  61282. /**
  61283. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61284. */
  61285. static LogLevels: number;
  61286. }
  61287. }
  61288. declare module BABYLON {
  61289. /** @hidden */
  61290. export class _TypeStore {
  61291. /** @hidden */
  61292. static RegisteredTypes: {
  61293. [key: string]: Object;
  61294. };
  61295. /** @hidden */
  61296. static GetClass(fqdn: string): any;
  61297. }
  61298. }
  61299. declare module BABYLON {
  61300. /**
  61301. * Class containing a set of static utilities functions for deep copy.
  61302. */
  61303. export class DeepCopier {
  61304. /**
  61305. * Tries to copy an object by duplicating every property
  61306. * @param source defines the source object
  61307. * @param destination defines the target object
  61308. * @param doNotCopyList defines a list of properties to avoid
  61309. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61310. */
  61311. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61312. }
  61313. }
  61314. declare module BABYLON {
  61315. /**
  61316. * Class containing a set of static utilities functions for precision date
  61317. */
  61318. export class PrecisionDate {
  61319. /**
  61320. * Gets either window.performance.now() if supported or Date.now() else
  61321. */
  61322. static readonly Now: number;
  61323. }
  61324. }
  61325. declare module BABYLON {
  61326. /**
  61327. * Class used to evalaute queries containing `and` and `or` operators
  61328. */
  61329. export class AndOrNotEvaluator {
  61330. /**
  61331. * Evaluate a query
  61332. * @param query defines the query to evaluate
  61333. * @param evaluateCallback defines the callback used to filter result
  61334. * @returns true if the query matches
  61335. */
  61336. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61337. private static _HandleParenthesisContent;
  61338. private static _SimplifyNegation;
  61339. }
  61340. }
  61341. declare module BABYLON {
  61342. /**
  61343. * Class used to store custom tags
  61344. */
  61345. export class Tags {
  61346. /**
  61347. * Adds support for tags on the given object
  61348. * @param obj defines the object to use
  61349. */
  61350. static EnableFor(obj: any): void;
  61351. /**
  61352. * Removes tags support
  61353. * @param obj defines the object to use
  61354. */
  61355. static DisableFor(obj: any): void;
  61356. /**
  61357. * Gets a boolean indicating if the given object has tags
  61358. * @param obj defines the object to use
  61359. * @returns a boolean
  61360. */
  61361. static HasTags(obj: any): boolean;
  61362. /**
  61363. * Gets the tags available on a given object
  61364. * @param obj defines the object to use
  61365. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61366. * @returns the tags
  61367. */
  61368. static GetTags(obj: any, asString?: boolean): any;
  61369. /**
  61370. * Adds tags to an object
  61371. * @param obj defines the object to use
  61372. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61373. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61374. */
  61375. static AddTagsTo(obj: any, tagsString: string): void;
  61376. /**
  61377. * @hidden
  61378. */
  61379. static _AddTagTo(obj: any, tag: string): void;
  61380. /**
  61381. * Removes specific tags from a specific object
  61382. * @param obj defines the object to use
  61383. * @param tagsString defines the tags to remove
  61384. */
  61385. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61386. /**
  61387. * @hidden
  61388. */
  61389. static _RemoveTagFrom(obj: any, tag: string): void;
  61390. /**
  61391. * Defines if tags hosted on an object match a given query
  61392. * @param obj defines the object to use
  61393. * @param tagsQuery defines the tag query
  61394. * @returns a boolean
  61395. */
  61396. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /**
  61401. * Manages the defines for the Material
  61402. */
  61403. export class MaterialDefines {
  61404. private _keys;
  61405. private _isDirty;
  61406. /** @hidden */
  61407. _renderId: number;
  61408. /** @hidden */
  61409. _areLightsDirty: boolean;
  61410. /** @hidden */
  61411. _areAttributesDirty: boolean;
  61412. /** @hidden */
  61413. _areTexturesDirty: boolean;
  61414. /** @hidden */
  61415. _areFresnelDirty: boolean;
  61416. /** @hidden */
  61417. _areMiscDirty: boolean;
  61418. /** @hidden */
  61419. _areImageProcessingDirty: boolean;
  61420. /** @hidden */
  61421. _normals: boolean;
  61422. /** @hidden */
  61423. _uvs: boolean;
  61424. /** @hidden */
  61425. _needNormals: boolean;
  61426. /** @hidden */
  61427. _needUVs: boolean;
  61428. /**
  61429. * Specifies if the material needs to be re-calculated
  61430. */
  61431. readonly isDirty: boolean;
  61432. /**
  61433. * Marks the material to indicate that it has been re-calculated
  61434. */
  61435. markAsProcessed(): void;
  61436. /**
  61437. * Marks the material to indicate that it needs to be re-calculated
  61438. */
  61439. markAsUnprocessed(): void;
  61440. /**
  61441. * Marks the material to indicate all of its defines need to be re-calculated
  61442. */
  61443. markAllAsDirty(): void;
  61444. /**
  61445. * Marks the material to indicate that image processing needs to be re-calculated
  61446. */
  61447. markAsImageProcessingDirty(): void;
  61448. /**
  61449. * Marks the material to indicate the lights need to be re-calculated
  61450. */
  61451. markAsLightDirty(): void;
  61452. /**
  61453. * Marks the attribute state as changed
  61454. */
  61455. markAsAttributesDirty(): void;
  61456. /**
  61457. * Marks the texture state as changed
  61458. */
  61459. markAsTexturesDirty(): void;
  61460. /**
  61461. * Marks the fresnel state as changed
  61462. */
  61463. markAsFresnelDirty(): void;
  61464. /**
  61465. * Marks the misc state as changed
  61466. */
  61467. markAsMiscDirty(): void;
  61468. /**
  61469. * Rebuilds the material defines
  61470. */
  61471. rebuild(): void;
  61472. /**
  61473. * Specifies if two material defines are equal
  61474. * @param other - A material define instance to compare to
  61475. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61476. */
  61477. isEqual(other: MaterialDefines): boolean;
  61478. /**
  61479. * Clones this instance's defines to another instance
  61480. * @param other - material defines to clone values to
  61481. */
  61482. cloneTo(other: MaterialDefines): void;
  61483. /**
  61484. * Resets the material define values
  61485. */
  61486. reset(): void;
  61487. /**
  61488. * Converts the material define values to a string
  61489. * @returns - String of material define information
  61490. */
  61491. toString(): string;
  61492. }
  61493. }
  61494. declare module BABYLON {
  61495. /**
  61496. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61497. */
  61498. export class PerformanceMonitor {
  61499. private _enabled;
  61500. private _rollingFrameTime;
  61501. private _lastFrameTimeMs;
  61502. /**
  61503. * constructor
  61504. * @param frameSampleSize The number of samples required to saturate the sliding window
  61505. */
  61506. constructor(frameSampleSize?: number);
  61507. /**
  61508. * Samples current frame
  61509. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61510. */
  61511. sampleFrame(timeMs?: number): void;
  61512. /**
  61513. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61514. */
  61515. readonly averageFrameTime: number;
  61516. /**
  61517. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61518. */
  61519. readonly averageFrameTimeVariance: number;
  61520. /**
  61521. * Returns the frame time of the most recent frame
  61522. */
  61523. readonly instantaneousFrameTime: number;
  61524. /**
  61525. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61526. */
  61527. readonly averageFPS: number;
  61528. /**
  61529. * Returns the average framerate in frames per second using the most recent frame time
  61530. */
  61531. readonly instantaneousFPS: number;
  61532. /**
  61533. * Returns true if enough samples have been taken to completely fill the sliding window
  61534. */
  61535. readonly isSaturated: boolean;
  61536. /**
  61537. * Enables contributions to the sliding window sample set
  61538. */
  61539. enable(): void;
  61540. /**
  61541. * Disables contributions to the sliding window sample set
  61542. * Samples will not be interpolated over the disabled period
  61543. */
  61544. disable(): void;
  61545. /**
  61546. * Returns true if sampling is enabled
  61547. */
  61548. readonly isEnabled: boolean;
  61549. /**
  61550. * Resets performance monitor
  61551. */
  61552. reset(): void;
  61553. }
  61554. /**
  61555. * RollingAverage
  61556. *
  61557. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61558. */
  61559. export class RollingAverage {
  61560. /**
  61561. * Current average
  61562. */
  61563. average: number;
  61564. /**
  61565. * Current variance
  61566. */
  61567. variance: number;
  61568. protected _samples: Array<number>;
  61569. protected _sampleCount: number;
  61570. protected _pos: number;
  61571. protected _m2: number;
  61572. /**
  61573. * constructor
  61574. * @param length The number of samples required to saturate the sliding window
  61575. */
  61576. constructor(length: number);
  61577. /**
  61578. * Adds a sample to the sample set
  61579. * @param v The sample value
  61580. */
  61581. add(v: number): void;
  61582. /**
  61583. * Returns previously added values or null if outside of history or outside the sliding window domain
  61584. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61585. * @return Value previously recorded with add() or null if outside of range
  61586. */
  61587. history(i: number): number;
  61588. /**
  61589. * Returns true if enough samples have been taken to completely fill the sliding window
  61590. * @return true if sample-set saturated
  61591. */
  61592. isSaturated(): boolean;
  61593. /**
  61594. * Resets the rolling average (equivalent to 0 samples taken so far)
  61595. */
  61596. reset(): void;
  61597. /**
  61598. * Wraps a value around the sample range boundaries
  61599. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61600. * @return Wrapped position in sample range
  61601. */
  61602. protected _wrapPosition(i: number): number;
  61603. }
  61604. }
  61605. declare module BABYLON {
  61606. /**
  61607. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61608. * The underlying implementation relies on an associative array to ensure the best performances.
  61609. * The value can be anything including 'null' but except 'undefined'
  61610. */
  61611. export class StringDictionary<T> {
  61612. /**
  61613. * This will clear this dictionary and copy the content from the 'source' one.
  61614. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61615. * @param source the dictionary to take the content from and copy to this dictionary
  61616. */
  61617. copyFrom(source: StringDictionary<T>): void;
  61618. /**
  61619. * Get a value based from its key
  61620. * @param key the given key to get the matching value from
  61621. * @return the value if found, otherwise undefined is returned
  61622. */
  61623. get(key: string): T | undefined;
  61624. /**
  61625. * Get a value from its key or add it if it doesn't exist.
  61626. * This method will ensure you that a given key/data will be present in the dictionary.
  61627. * @param key the given key to get the matching value from
  61628. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61629. * The factory will only be invoked if there's no data for the given key.
  61630. * @return the value corresponding to the key.
  61631. */
  61632. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61633. /**
  61634. * Get a value from its key if present in the dictionary otherwise add it
  61635. * @param key the key to get the value from
  61636. * @param val if there's no such key/value pair in the dictionary add it with this value
  61637. * @return the value corresponding to the key
  61638. */
  61639. getOrAdd(key: string, val: T): T;
  61640. /**
  61641. * Check if there's a given key in the dictionary
  61642. * @param key the key to check for
  61643. * @return true if the key is present, false otherwise
  61644. */
  61645. contains(key: string): boolean;
  61646. /**
  61647. * Add a new key and its corresponding value
  61648. * @param key the key to add
  61649. * @param value the value corresponding to the key
  61650. * @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
  61651. */
  61652. add(key: string, value: T): boolean;
  61653. /**
  61654. * Update a specific value associated to a key
  61655. * @param key defines the key to use
  61656. * @param value defines the value to store
  61657. * @returns true if the value was updated (or false if the key was not found)
  61658. */
  61659. set(key: string, value: T): boolean;
  61660. /**
  61661. * Get the element of the given key and remove it from the dictionary
  61662. * @param key defines the key to search
  61663. * @returns the value associated with the key or null if not found
  61664. */
  61665. getAndRemove(key: string): Nullable<T>;
  61666. /**
  61667. * Remove a key/value from the dictionary.
  61668. * @param key the key to remove
  61669. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61670. */
  61671. remove(key: string): boolean;
  61672. /**
  61673. * Clear the whole content of the dictionary
  61674. */
  61675. clear(): void;
  61676. /**
  61677. * Gets the current count
  61678. */
  61679. readonly count: number;
  61680. /**
  61681. * Execute a callback on each key/val of the dictionary.
  61682. * Note that you can remove any element in this dictionary in the callback implementation
  61683. * @param callback the callback to execute on a given key/value pair
  61684. */
  61685. forEach(callback: (key: string, val: T) => void): void;
  61686. /**
  61687. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61688. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61689. * Note that you can remove any element in this dictionary in the callback implementation
  61690. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61691. * @returns the first item
  61692. */
  61693. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61694. private _count;
  61695. private _data;
  61696. }
  61697. }
  61698. declare module BABYLON {
  61699. /**
  61700. * Helper class that provides a small promise polyfill
  61701. */
  61702. export class PromisePolyfill {
  61703. /**
  61704. * Static function used to check if the polyfill is required
  61705. * If this is the case then the function will inject the polyfill to window.Promise
  61706. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61707. */
  61708. static Apply(force?: boolean): void;
  61709. }
  61710. }
  61711. declare module BABYLON {
  61712. /**
  61713. * Class used to store data that will be store in GPU memory
  61714. */
  61715. export class Buffer {
  61716. private _engine;
  61717. private _buffer;
  61718. /** @hidden */
  61719. _data: Nullable<DataArray>;
  61720. private _updatable;
  61721. private _instanced;
  61722. /**
  61723. * Gets the byte stride.
  61724. */
  61725. readonly byteStride: number;
  61726. /**
  61727. * Constructor
  61728. * @param engine the engine
  61729. * @param data the data to use for this buffer
  61730. * @param updatable whether the data is updatable
  61731. * @param stride the stride (optional)
  61732. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61733. * @param instanced whether the buffer is instanced (optional)
  61734. * @param useBytes set to true if the stride in in bytes (optional)
  61735. */
  61736. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61737. /**
  61738. * Create a new VertexBuffer based on the current buffer
  61739. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61740. * @param offset defines offset in the buffer (0 by default)
  61741. * @param size defines the size in floats of attributes (position is 3 for instance)
  61742. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61743. * @param instanced defines if the vertex buffer contains indexed data
  61744. * @param useBytes defines if the offset and stride are in bytes
  61745. * @returns the new vertex buffer
  61746. */
  61747. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61748. /**
  61749. * Gets a boolean indicating if the Buffer is updatable?
  61750. * @returns true if the buffer is updatable
  61751. */
  61752. isUpdatable(): boolean;
  61753. /**
  61754. * Gets current buffer's data
  61755. * @returns a DataArray or null
  61756. */
  61757. getData(): Nullable<DataArray>;
  61758. /**
  61759. * Gets underlying native buffer
  61760. * @returns underlying native buffer
  61761. */
  61762. getBuffer(): Nullable<WebGLBuffer>;
  61763. /**
  61764. * Gets the stride in float32 units (i.e. byte stride / 4).
  61765. * May not be an integer if the byte stride is not divisible by 4.
  61766. * DEPRECATED. Use byteStride instead.
  61767. * @returns the stride in float32 units
  61768. */
  61769. getStrideSize(): number;
  61770. /**
  61771. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61772. * @param data defines the data to store
  61773. */
  61774. create(data?: Nullable<DataArray>): void;
  61775. /** @hidden */
  61776. _rebuild(): void;
  61777. /**
  61778. * Update current buffer data
  61779. * @param data defines the data to store
  61780. */
  61781. update(data: DataArray): void;
  61782. /**
  61783. * Updates the data directly.
  61784. * @param data the new data
  61785. * @param offset the new offset
  61786. * @param vertexCount the vertex count (optional)
  61787. * @param useBytes set to true if the offset is in bytes
  61788. */
  61789. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61790. /**
  61791. * Release all resources
  61792. */
  61793. dispose(): void;
  61794. }
  61795. /**
  61796. * Specialized buffer used to store vertex data
  61797. */
  61798. export class VertexBuffer {
  61799. /** @hidden */
  61800. _buffer: Buffer;
  61801. private _kind;
  61802. private _size;
  61803. private _ownsBuffer;
  61804. private _instanced;
  61805. private _instanceDivisor;
  61806. /**
  61807. * The byte type.
  61808. */
  61809. static readonly BYTE: number;
  61810. /**
  61811. * The unsigned byte type.
  61812. */
  61813. static readonly UNSIGNED_BYTE: number;
  61814. /**
  61815. * The short type.
  61816. */
  61817. static readonly SHORT: number;
  61818. /**
  61819. * The unsigned short type.
  61820. */
  61821. static readonly UNSIGNED_SHORT: number;
  61822. /**
  61823. * The integer type.
  61824. */
  61825. static readonly INT: number;
  61826. /**
  61827. * The unsigned integer type.
  61828. */
  61829. static readonly UNSIGNED_INT: number;
  61830. /**
  61831. * The float type.
  61832. */
  61833. static readonly FLOAT: number;
  61834. /**
  61835. * Gets or sets the instance divisor when in instanced mode
  61836. */
  61837. instanceDivisor: number;
  61838. /**
  61839. * Gets the byte stride.
  61840. */
  61841. readonly byteStride: number;
  61842. /**
  61843. * Gets the byte offset.
  61844. */
  61845. readonly byteOffset: number;
  61846. /**
  61847. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61848. */
  61849. readonly normalized: boolean;
  61850. /**
  61851. * Gets the data type of each component in the array.
  61852. */
  61853. readonly type: number;
  61854. /**
  61855. * Constructor
  61856. * @param engine the engine
  61857. * @param data the data to use for this vertex buffer
  61858. * @param kind the vertex buffer kind
  61859. * @param updatable whether the data is updatable
  61860. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61861. * @param stride the stride (optional)
  61862. * @param instanced whether the buffer is instanced (optional)
  61863. * @param offset the offset of the data (optional)
  61864. * @param size the number of components (optional)
  61865. * @param type the type of the component (optional)
  61866. * @param normalized whether the data contains normalized data (optional)
  61867. * @param useBytes set to true if stride and offset are in bytes (optional)
  61868. */
  61869. 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);
  61870. /** @hidden */
  61871. _rebuild(): void;
  61872. /**
  61873. * Returns the kind of the VertexBuffer (string)
  61874. * @returns a string
  61875. */
  61876. getKind(): string;
  61877. /**
  61878. * Gets a boolean indicating if the VertexBuffer is updatable?
  61879. * @returns true if the buffer is updatable
  61880. */
  61881. isUpdatable(): boolean;
  61882. /**
  61883. * Gets current buffer's data
  61884. * @returns a DataArray or null
  61885. */
  61886. getData(): Nullable<DataArray>;
  61887. /**
  61888. * Gets underlying native buffer
  61889. * @returns underlying native buffer
  61890. */
  61891. getBuffer(): Nullable<WebGLBuffer>;
  61892. /**
  61893. * Gets the stride in float32 units (i.e. byte stride / 4).
  61894. * May not be an integer if the byte stride is not divisible by 4.
  61895. * DEPRECATED. Use byteStride instead.
  61896. * @returns the stride in float32 units
  61897. */
  61898. getStrideSize(): number;
  61899. /**
  61900. * Returns the offset as a multiple of the type byte length.
  61901. * DEPRECATED. Use byteOffset instead.
  61902. * @returns the offset in bytes
  61903. */
  61904. getOffset(): number;
  61905. /**
  61906. * Returns the number of components per vertex attribute (integer)
  61907. * @returns the size in float
  61908. */
  61909. getSize(): number;
  61910. /**
  61911. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  61912. * @returns true if this buffer is instanced
  61913. */
  61914. getIsInstanced(): boolean;
  61915. /**
  61916. * Returns the instancing divisor, zero for non-instanced (integer).
  61917. * @returns a number
  61918. */
  61919. getInstanceDivisor(): number;
  61920. /**
  61921. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61922. * @param data defines the data to store
  61923. */
  61924. create(data?: DataArray): void;
  61925. /**
  61926. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  61927. * This function will create a new buffer if the current one is not updatable
  61928. * @param data defines the data to store
  61929. */
  61930. update(data: DataArray): void;
  61931. /**
  61932. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  61933. * Returns the directly updated WebGLBuffer.
  61934. * @param data the new data
  61935. * @param offset the new offset
  61936. * @param useBytes set to true if the offset is in bytes
  61937. */
  61938. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  61939. /**
  61940. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  61941. */
  61942. dispose(): void;
  61943. /**
  61944. * Enumerates each value of this vertex buffer as numbers.
  61945. * @param count the number of values to enumerate
  61946. * @param callback the callback function called for each value
  61947. */
  61948. forEach(count: number, callback: (value: number, index: number) => void): void;
  61949. /**
  61950. * Positions
  61951. */
  61952. static readonly PositionKind: string;
  61953. /**
  61954. * Normals
  61955. */
  61956. static readonly NormalKind: string;
  61957. /**
  61958. * Tangents
  61959. */
  61960. static readonly TangentKind: string;
  61961. /**
  61962. * Texture coordinates
  61963. */
  61964. static readonly UVKind: string;
  61965. /**
  61966. * Texture coordinates 2
  61967. */
  61968. static readonly UV2Kind: string;
  61969. /**
  61970. * Texture coordinates 3
  61971. */
  61972. static readonly UV3Kind: string;
  61973. /**
  61974. * Texture coordinates 4
  61975. */
  61976. static readonly UV4Kind: string;
  61977. /**
  61978. * Texture coordinates 5
  61979. */
  61980. static readonly UV5Kind: string;
  61981. /**
  61982. * Texture coordinates 6
  61983. */
  61984. static readonly UV6Kind: string;
  61985. /**
  61986. * Colors
  61987. */
  61988. static readonly ColorKind: string;
  61989. /**
  61990. * Matrix indices (for bones)
  61991. */
  61992. static readonly MatricesIndicesKind: string;
  61993. /**
  61994. * Matrix weights (for bones)
  61995. */
  61996. static readonly MatricesWeightsKind: string;
  61997. /**
  61998. * Additional matrix indices (for bones)
  61999. */
  62000. static readonly MatricesIndicesExtraKind: string;
  62001. /**
  62002. * Additional matrix weights (for bones)
  62003. */
  62004. static readonly MatricesWeightsExtraKind: string;
  62005. /**
  62006. * Deduces the stride given a kind.
  62007. * @param kind The kind string to deduce
  62008. * @returns The deduced stride
  62009. */
  62010. static DeduceStride(kind: string): number;
  62011. /**
  62012. * Gets the byte length of the given type.
  62013. * @param type the type
  62014. * @returns the number of bytes
  62015. */
  62016. static GetTypeByteLength(type: number): number;
  62017. /**
  62018. * Enumerates each value of the given parameters as numbers.
  62019. * @param data the data to enumerate
  62020. * @param byteOffset the byte offset of the data
  62021. * @param byteStride the byte stride of the data
  62022. * @param componentCount the number of components per element
  62023. * @param componentType the type of the component
  62024. * @param count the total number of components
  62025. * @param normalized whether the data is normalized
  62026. * @param callback the callback function called for each value
  62027. */
  62028. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62029. private static _GetFloatValue;
  62030. }
  62031. }
  62032. declare module BABYLON {
  62033. /**
  62034. * Class representing spherical polynomial coefficients to the 3rd degree
  62035. */
  62036. export class SphericalPolynomial {
  62037. /**
  62038. * The x coefficients of the spherical polynomial
  62039. */
  62040. x: Vector3;
  62041. /**
  62042. * The y coefficients of the spherical polynomial
  62043. */
  62044. y: Vector3;
  62045. /**
  62046. * The z coefficients of the spherical polynomial
  62047. */
  62048. z: Vector3;
  62049. /**
  62050. * The xx coefficients of the spherical polynomial
  62051. */
  62052. xx: Vector3;
  62053. /**
  62054. * The yy coefficients of the spherical polynomial
  62055. */
  62056. yy: Vector3;
  62057. /**
  62058. * The zz coefficients of the spherical polynomial
  62059. */
  62060. zz: Vector3;
  62061. /**
  62062. * The xy coefficients of the spherical polynomial
  62063. */
  62064. xy: Vector3;
  62065. /**
  62066. * The yz coefficients of the spherical polynomial
  62067. */
  62068. yz: Vector3;
  62069. /**
  62070. * The zx coefficients of the spherical polynomial
  62071. */
  62072. zx: Vector3;
  62073. /**
  62074. * Adds an ambient color to the spherical polynomial
  62075. * @param color the color to add
  62076. */
  62077. addAmbient(color: Color3): void;
  62078. /**
  62079. * Scales the spherical polynomial by the given amount
  62080. * @param scale the amount to scale
  62081. */
  62082. scale(scale: number): void;
  62083. /**
  62084. * Gets the spherical polynomial from harmonics
  62085. * @param harmonics the spherical harmonics
  62086. * @returns the spherical polynomial
  62087. */
  62088. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62089. /**
  62090. * Constructs a spherical polynomial from an array.
  62091. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62092. * @returns the spherical polynomial
  62093. */
  62094. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62095. }
  62096. /**
  62097. * Class representing spherical harmonics coefficients to the 3rd degree
  62098. */
  62099. export class SphericalHarmonics {
  62100. /**
  62101. * The l0,0 coefficients of the spherical harmonics
  62102. */
  62103. l00: Vector3;
  62104. /**
  62105. * The l1,-1 coefficients of the spherical harmonics
  62106. */
  62107. l1_1: Vector3;
  62108. /**
  62109. * The l1,0 coefficients of the spherical harmonics
  62110. */
  62111. l10: Vector3;
  62112. /**
  62113. * The l1,1 coefficients of the spherical harmonics
  62114. */
  62115. l11: Vector3;
  62116. /**
  62117. * The l2,-2 coefficients of the spherical harmonics
  62118. */
  62119. l2_2: Vector3;
  62120. /**
  62121. * The l2,-1 coefficients of the spherical harmonics
  62122. */
  62123. l2_1: Vector3;
  62124. /**
  62125. * The l2,0 coefficients of the spherical harmonics
  62126. */
  62127. l20: Vector3;
  62128. /**
  62129. * The l2,1 coefficients of the spherical harmonics
  62130. */
  62131. l21: Vector3;
  62132. /**
  62133. * The l2,2 coefficients of the spherical harmonics
  62134. */
  62135. lL22: Vector3;
  62136. /**
  62137. * Adds a light to the spherical harmonics
  62138. * @param direction the direction of the light
  62139. * @param color the color of the light
  62140. * @param deltaSolidAngle the delta solid angle of the light
  62141. */
  62142. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62143. /**
  62144. * Scales the spherical harmonics by the given amount
  62145. * @param scale the amount to scale
  62146. */
  62147. scale(scale: number): void;
  62148. /**
  62149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62150. *
  62151. * ```
  62152. * E_lm = A_l * L_lm
  62153. * ```
  62154. *
  62155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62157. * the scaling factors are given in equation 9.
  62158. */
  62159. convertIncidentRadianceToIrradiance(): void;
  62160. /**
  62161. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62162. *
  62163. * ```
  62164. * L = (1/pi) * E * rho
  62165. * ```
  62166. *
  62167. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62168. */
  62169. convertIrradianceToLambertianRadiance(): void;
  62170. /**
  62171. * Gets the spherical harmonics from polynomial
  62172. * @param polynomial the spherical polynomial
  62173. * @returns the spherical harmonics
  62174. */
  62175. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62176. /**
  62177. * Constructs a spherical harmonics from an array.
  62178. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62179. * @returns the spherical harmonics
  62180. */
  62181. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62182. }
  62183. }
  62184. declare module BABYLON {
  62185. /**
  62186. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62187. */
  62188. export interface CubeMapInfo {
  62189. /**
  62190. * The pixel array for the front face.
  62191. * This is stored in format, left to right, up to down format.
  62192. */
  62193. front: Nullable<ArrayBufferView>;
  62194. /**
  62195. * The pixel array for the back face.
  62196. * This is stored in format, left to right, up to down format.
  62197. */
  62198. back: Nullable<ArrayBufferView>;
  62199. /**
  62200. * The pixel array for the left face.
  62201. * This is stored in format, left to right, up to down format.
  62202. */
  62203. left: Nullable<ArrayBufferView>;
  62204. /**
  62205. * The pixel array for the right face.
  62206. * This is stored in format, left to right, up to down format.
  62207. */
  62208. right: Nullable<ArrayBufferView>;
  62209. /**
  62210. * The pixel array for the up face.
  62211. * This is stored in format, left to right, up to down format.
  62212. */
  62213. up: Nullable<ArrayBufferView>;
  62214. /**
  62215. * The pixel array for the down face.
  62216. * This is stored in format, left to right, up to down format.
  62217. */
  62218. down: Nullable<ArrayBufferView>;
  62219. /**
  62220. * The size of the cubemap stored.
  62221. *
  62222. * Each faces will be size * size pixels.
  62223. */
  62224. size: number;
  62225. /**
  62226. * The format of the texture.
  62227. *
  62228. * RGBA, RGB.
  62229. */
  62230. format: number;
  62231. /**
  62232. * The type of the texture data.
  62233. *
  62234. * UNSIGNED_INT, FLOAT.
  62235. */
  62236. type: number;
  62237. /**
  62238. * Specifies whether the texture is in gamma space.
  62239. */
  62240. gammaSpace: boolean;
  62241. }
  62242. /**
  62243. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62244. */
  62245. export class PanoramaToCubeMapTools {
  62246. private static FACE_FRONT;
  62247. private static FACE_BACK;
  62248. private static FACE_RIGHT;
  62249. private static FACE_LEFT;
  62250. private static FACE_DOWN;
  62251. private static FACE_UP;
  62252. /**
  62253. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62254. *
  62255. * @param float32Array The source data.
  62256. * @param inputWidth The width of the input panorama.
  62257. * @param inputHeight The height of the input panorama.
  62258. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62259. * @return The cubemap data
  62260. */
  62261. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62262. private static CreateCubemapTexture;
  62263. private static CalcProjectionSpherical;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /**
  62268. * Helper class dealing with the extraction of spherical polynomial dataArray
  62269. * from a cube map.
  62270. */
  62271. export class CubeMapToSphericalPolynomialTools {
  62272. private static FileFaces;
  62273. /**
  62274. * Converts a texture to the according Spherical Polynomial data.
  62275. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62276. *
  62277. * @param texture The texture to extract the information from.
  62278. * @return The Spherical Polynomial data.
  62279. */
  62280. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62281. /**
  62282. * Converts a cubemap to the according Spherical Polynomial data.
  62283. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62284. *
  62285. * @param cubeInfo The Cube map to extract the information from.
  62286. * @return The Spherical Polynomial data.
  62287. */
  62288. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62289. }
  62290. }
  62291. declare module BABYLON {
  62292. /**
  62293. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62294. * during the life time of the application.
  62295. */
  62296. export class EngineStore {
  62297. /** Gets the list of created engines */
  62298. static Instances: Engine[];
  62299. /**
  62300. * Gets the latest created engine
  62301. */
  62302. static readonly LastCreatedEngine: Nullable<Engine>;
  62303. /**
  62304. * Gets the latest created scene
  62305. */
  62306. static readonly LastCreatedScene: Nullable<Scene>;
  62307. }
  62308. }
  62309. declare module BABYLON {
  62310. /**
  62311. * Define options used to create a render target texture
  62312. */
  62313. export class RenderTargetCreationOptions {
  62314. /**
  62315. * Specifies is mipmaps must be generated
  62316. */
  62317. generateMipMaps?: boolean;
  62318. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62319. generateDepthBuffer?: boolean;
  62320. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62321. generateStencilBuffer?: boolean;
  62322. /** Defines texture type (int by default) */
  62323. type?: number;
  62324. /** Defines sampling mode (trilinear by default) */
  62325. samplingMode?: number;
  62326. /** Defines format (RGBA by default) */
  62327. format?: number;
  62328. }
  62329. }
  62330. declare module BABYLON {
  62331. /**
  62332. * @hidden
  62333. **/
  62334. export class _AlphaState {
  62335. private _isAlphaBlendDirty;
  62336. private _isBlendFunctionParametersDirty;
  62337. private _isBlendEquationParametersDirty;
  62338. private _isBlendConstantsDirty;
  62339. private _alphaBlend;
  62340. private _blendFunctionParameters;
  62341. private _blendEquationParameters;
  62342. private _blendConstants;
  62343. /**
  62344. * Initializes the state.
  62345. */
  62346. constructor();
  62347. readonly isDirty: boolean;
  62348. alphaBlend: boolean;
  62349. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62350. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62351. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62352. reset(): void;
  62353. apply(gl: WebGLRenderingContext): void;
  62354. }
  62355. }
  62356. declare module BABYLON {
  62357. /**
  62358. * @hidden
  62359. **/
  62360. export class _DepthCullingState {
  62361. private _isDepthTestDirty;
  62362. private _isDepthMaskDirty;
  62363. private _isDepthFuncDirty;
  62364. private _isCullFaceDirty;
  62365. private _isCullDirty;
  62366. private _isZOffsetDirty;
  62367. private _isFrontFaceDirty;
  62368. private _depthTest;
  62369. private _depthMask;
  62370. private _depthFunc;
  62371. private _cull;
  62372. private _cullFace;
  62373. private _zOffset;
  62374. private _frontFace;
  62375. /**
  62376. * Initializes the state.
  62377. */
  62378. constructor();
  62379. readonly isDirty: boolean;
  62380. zOffset: number;
  62381. cullFace: Nullable<number>;
  62382. cull: Nullable<boolean>;
  62383. depthFunc: Nullable<number>;
  62384. depthMask: boolean;
  62385. depthTest: boolean;
  62386. frontFace: Nullable<number>;
  62387. reset(): void;
  62388. apply(gl: WebGLRenderingContext): void;
  62389. }
  62390. }
  62391. declare module BABYLON {
  62392. /**
  62393. * @hidden
  62394. **/
  62395. export class _StencilState {
  62396. /** 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 */
  62397. static readonly ALWAYS: number;
  62398. /** Passed to stencilOperation to specify that stencil value must be kept */
  62399. static readonly KEEP: number;
  62400. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62401. static readonly REPLACE: number;
  62402. private _isStencilTestDirty;
  62403. private _isStencilMaskDirty;
  62404. private _isStencilFuncDirty;
  62405. private _isStencilOpDirty;
  62406. private _stencilTest;
  62407. private _stencilMask;
  62408. private _stencilFunc;
  62409. private _stencilFuncRef;
  62410. private _stencilFuncMask;
  62411. private _stencilOpStencilFail;
  62412. private _stencilOpDepthFail;
  62413. private _stencilOpStencilDepthPass;
  62414. readonly isDirty: boolean;
  62415. stencilFunc: number;
  62416. stencilFuncRef: number;
  62417. stencilFuncMask: number;
  62418. stencilOpStencilFail: number;
  62419. stencilOpDepthFail: number;
  62420. stencilOpStencilDepthPass: number;
  62421. stencilMask: number;
  62422. stencilTest: boolean;
  62423. constructor();
  62424. reset(): void;
  62425. apply(gl: WebGLRenderingContext): void;
  62426. }
  62427. }
  62428. declare module BABYLON {
  62429. /**
  62430. * @hidden
  62431. **/
  62432. export class _TimeToken {
  62433. _startTimeQuery: Nullable<WebGLQuery>;
  62434. _endTimeQuery: Nullable<WebGLQuery>;
  62435. _timeElapsedQuery: Nullable<WebGLQuery>;
  62436. _timeElapsedQueryEnded: boolean;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Internal interface used to track InternalTexture already bound to the GL context
  62442. */
  62443. export interface IInternalTextureTracker {
  62444. /**
  62445. * Gets or set the previous tracker in the list
  62446. */
  62447. previous: Nullable<IInternalTextureTracker>;
  62448. /**
  62449. * Gets or set the next tracker in the list
  62450. */
  62451. next: Nullable<IInternalTextureTracker>;
  62452. }
  62453. /**
  62454. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62455. */
  62456. export class DummyInternalTextureTracker {
  62457. /**
  62458. * Gets or set the previous tracker in the list
  62459. */
  62460. previous: Nullable<IInternalTextureTracker>;
  62461. /**
  62462. * Gets or set the next tracker in the list
  62463. */
  62464. next: Nullable<IInternalTextureTracker>;
  62465. }
  62466. }
  62467. declare module BABYLON {
  62468. /**
  62469. * Class used to store data associated with WebGL texture data for the engine
  62470. * This class should not be used directly
  62471. */
  62472. export class InternalTexture implements IInternalTextureTracker {
  62473. /** hidden */
  62474. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62475. /**
  62476. * The source of the texture data is unknown
  62477. */
  62478. static DATASOURCE_UNKNOWN: number;
  62479. /**
  62480. * Texture data comes from an URL
  62481. */
  62482. static DATASOURCE_URL: number;
  62483. /**
  62484. * Texture data is only used for temporary storage
  62485. */
  62486. static DATASOURCE_TEMP: number;
  62487. /**
  62488. * Texture data comes from raw data (ArrayBuffer)
  62489. */
  62490. static DATASOURCE_RAW: number;
  62491. /**
  62492. * Texture content is dynamic (video or dynamic texture)
  62493. */
  62494. static DATASOURCE_DYNAMIC: number;
  62495. /**
  62496. * Texture content is generated by rendering to it
  62497. */
  62498. static DATASOURCE_RENDERTARGET: number;
  62499. /**
  62500. * Texture content is part of a multi render target process
  62501. */
  62502. static DATASOURCE_MULTIRENDERTARGET: number;
  62503. /**
  62504. * Texture data comes from a cube data file
  62505. */
  62506. static DATASOURCE_CUBE: number;
  62507. /**
  62508. * Texture data comes from a raw cube data
  62509. */
  62510. static DATASOURCE_CUBERAW: number;
  62511. /**
  62512. * Texture data come from a prefiltered cube data file
  62513. */
  62514. static DATASOURCE_CUBEPREFILTERED: number;
  62515. /**
  62516. * Texture content is raw 3D data
  62517. */
  62518. static DATASOURCE_RAW3D: number;
  62519. /**
  62520. * Texture content is a depth texture
  62521. */
  62522. static DATASOURCE_DEPTHTEXTURE: number;
  62523. /**
  62524. * Texture data comes from a raw cube data encoded with RGBD
  62525. */
  62526. static DATASOURCE_CUBERAW_RGBD: number;
  62527. /**
  62528. * Defines if the texture is ready
  62529. */
  62530. isReady: boolean;
  62531. /**
  62532. * Defines if the texture is a cube texture
  62533. */
  62534. isCube: boolean;
  62535. /**
  62536. * Defines if the texture contains 3D data
  62537. */
  62538. is3D: boolean;
  62539. /**
  62540. * Gets the URL used to load this texture
  62541. */
  62542. url: string;
  62543. /**
  62544. * Gets the sampling mode of the texture
  62545. */
  62546. samplingMode: number;
  62547. /**
  62548. * Gets a boolean indicating if the texture needs mipmaps generation
  62549. */
  62550. generateMipMaps: boolean;
  62551. /**
  62552. * Gets the number of samples used by the texture (WebGL2+ only)
  62553. */
  62554. samples: number;
  62555. /**
  62556. * Gets the type of the texture (int, float...)
  62557. */
  62558. type: number;
  62559. /**
  62560. * Gets the format of the texture (RGB, RGBA...)
  62561. */
  62562. format: number;
  62563. /**
  62564. * Observable called when the texture is loaded
  62565. */
  62566. onLoadedObservable: Observable<InternalTexture>;
  62567. /**
  62568. * Gets the width of the texture
  62569. */
  62570. width: number;
  62571. /**
  62572. * Gets the height of the texture
  62573. */
  62574. height: number;
  62575. /**
  62576. * Gets the depth of the texture
  62577. */
  62578. depth: number;
  62579. /**
  62580. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62581. */
  62582. baseWidth: number;
  62583. /**
  62584. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62585. */
  62586. baseHeight: number;
  62587. /**
  62588. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62589. */
  62590. baseDepth: number;
  62591. /**
  62592. * Gets a boolean indicating if the texture is inverted on Y axis
  62593. */
  62594. invertY: boolean;
  62595. /**
  62596. * Gets or set the previous tracker in the list
  62597. */
  62598. previous: Nullable<IInternalTextureTracker>;
  62599. /**
  62600. * Gets or set the next tracker in the list
  62601. */
  62602. next: Nullable<IInternalTextureTracker>;
  62603. /** @hidden */
  62604. _invertVScale: boolean;
  62605. /** @hidden */
  62606. _initialSlot: number;
  62607. /** @hidden */
  62608. _designatedSlot: number;
  62609. /** @hidden */
  62610. _dataSource: number;
  62611. /** @hidden */
  62612. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62613. /** @hidden */
  62614. _bufferView: Nullable<ArrayBufferView>;
  62615. /** @hidden */
  62616. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62617. /** @hidden */
  62618. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62619. /** @hidden */
  62620. _size: number;
  62621. /** @hidden */
  62622. _extension: string;
  62623. /** @hidden */
  62624. _files: Nullable<string[]>;
  62625. /** @hidden */
  62626. _workingCanvas: HTMLCanvasElement;
  62627. /** @hidden */
  62628. _workingContext: CanvasRenderingContext2D;
  62629. /** @hidden */
  62630. _framebuffer: Nullable<WebGLFramebuffer>;
  62631. /** @hidden */
  62632. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62633. /** @hidden */
  62634. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62635. /** @hidden */
  62636. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62637. /** @hidden */
  62638. _attachments: Nullable<number[]>;
  62639. /** @hidden */
  62640. _cachedCoordinatesMode: Nullable<number>;
  62641. /** @hidden */
  62642. _cachedWrapU: Nullable<number>;
  62643. /** @hidden */
  62644. _cachedWrapV: Nullable<number>;
  62645. /** @hidden */
  62646. _cachedWrapR: Nullable<number>;
  62647. /** @hidden */
  62648. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62649. /** @hidden */
  62650. _isDisabled: boolean;
  62651. /** @hidden */
  62652. _compression: Nullable<string>;
  62653. /** @hidden */
  62654. _generateStencilBuffer: boolean;
  62655. /** @hidden */
  62656. _generateDepthBuffer: boolean;
  62657. /** @hidden */
  62658. _comparisonFunction: number;
  62659. /** @hidden */
  62660. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62661. /** @hidden */
  62662. _lodGenerationScale: number;
  62663. /** @hidden */
  62664. _lodGenerationOffset: number;
  62665. /** @hidden */
  62666. _lodTextureHigh: BaseTexture;
  62667. /** @hidden */
  62668. _lodTextureMid: BaseTexture;
  62669. /** @hidden */
  62670. _lodTextureLow: BaseTexture;
  62671. /** @hidden */
  62672. _isRGBD: boolean;
  62673. /** @hidden */
  62674. _webGLTexture: Nullable<WebGLTexture>;
  62675. /** @hidden */
  62676. _references: number;
  62677. private _engine;
  62678. /**
  62679. * Gets the Engine the texture belongs to.
  62680. * @returns The babylon engine
  62681. */
  62682. getEngine(): Engine;
  62683. /**
  62684. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62685. */
  62686. readonly dataSource: number;
  62687. /**
  62688. * Creates a new InternalTexture
  62689. * @param engine defines the engine to use
  62690. * @param dataSource defines the type of data that will be used
  62691. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62692. */
  62693. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62694. /**
  62695. * Increments the number of references (ie. the number of Texture that point to it)
  62696. */
  62697. incrementReferences(): void;
  62698. /**
  62699. * Change the size of the texture (not the size of the content)
  62700. * @param width defines the new width
  62701. * @param height defines the new height
  62702. * @param depth defines the new depth (1 by default)
  62703. */
  62704. updateSize(width: int, height: int, depth?: int): void;
  62705. /** @hidden */
  62706. _rebuild(): void;
  62707. /** @hidden */
  62708. _swapAndDie(target: InternalTexture): void;
  62709. /**
  62710. * Dispose the current allocated resources
  62711. */
  62712. dispose(): void;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * This represents the main contract an easing function should follow.
  62718. * Easing functions are used throughout the animation system.
  62719. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62720. */
  62721. export interface IEasingFunction {
  62722. /**
  62723. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62724. * of the easing function.
  62725. * The link below provides some of the most common examples of easing functions.
  62726. * @see https://easings.net/
  62727. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62728. * @returns the corresponding value on the curve defined by the easing function
  62729. */
  62730. ease(gradient: number): number;
  62731. }
  62732. /**
  62733. * Base class used for every default easing function.
  62734. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62735. */
  62736. export class EasingFunction implements IEasingFunction {
  62737. /**
  62738. * Interpolation follows the mathematical formula associated with the easing function.
  62739. */
  62740. static readonly EASINGMODE_EASEIN: number;
  62741. /**
  62742. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62743. */
  62744. static readonly EASINGMODE_EASEOUT: number;
  62745. /**
  62746. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62747. */
  62748. static readonly EASINGMODE_EASEINOUT: number;
  62749. private _easingMode;
  62750. /**
  62751. * Sets the easing mode of the current function.
  62752. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62753. */
  62754. setEasingMode(easingMode: number): void;
  62755. /**
  62756. * Gets the current easing mode.
  62757. * @returns the easing mode
  62758. */
  62759. getEasingMode(): number;
  62760. /**
  62761. * @hidden
  62762. */
  62763. easeInCore(gradient: number): number;
  62764. /**
  62765. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62766. * of the easing function.
  62767. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62768. * @returns the corresponding value on the curve defined by the easing function
  62769. */
  62770. ease(gradient: number): number;
  62771. }
  62772. /**
  62773. * Easing function with a circle shape (see link below).
  62774. * @see https://easings.net/#easeInCirc
  62775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62776. */
  62777. export class CircleEase extends EasingFunction implements IEasingFunction {
  62778. /** @hidden */
  62779. easeInCore(gradient: number): number;
  62780. }
  62781. /**
  62782. * Easing function with a ease back shape (see link below).
  62783. * @see https://easings.net/#easeInBack
  62784. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62785. */
  62786. export class BackEase extends EasingFunction implements IEasingFunction {
  62787. /** Defines the amplitude of the function */
  62788. amplitude: number;
  62789. /**
  62790. * Instantiates a back ease easing
  62791. * @see https://easings.net/#easeInBack
  62792. * @param amplitude Defines the amplitude of the function
  62793. */
  62794. constructor(
  62795. /** Defines the amplitude of the function */
  62796. amplitude?: number);
  62797. /** @hidden */
  62798. easeInCore(gradient: number): number;
  62799. }
  62800. /**
  62801. * Easing function with a bouncing shape (see link below).
  62802. * @see https://easings.net/#easeInBounce
  62803. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62804. */
  62805. export class BounceEase extends EasingFunction implements IEasingFunction {
  62806. /** Defines the number of bounces */
  62807. bounces: number;
  62808. /** Defines the amplitude of the bounce */
  62809. bounciness: number;
  62810. /**
  62811. * Instantiates a bounce easing
  62812. * @see https://easings.net/#easeInBounce
  62813. * @param bounces Defines the number of bounces
  62814. * @param bounciness Defines the amplitude of the bounce
  62815. */
  62816. constructor(
  62817. /** Defines the number of bounces */
  62818. bounces?: number,
  62819. /** Defines the amplitude of the bounce */
  62820. bounciness?: number);
  62821. /** @hidden */
  62822. easeInCore(gradient: number): number;
  62823. }
  62824. /**
  62825. * Easing function with a power of 3 shape (see link below).
  62826. * @see https://easings.net/#easeInCubic
  62827. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62828. */
  62829. export class CubicEase extends EasingFunction implements IEasingFunction {
  62830. /** @hidden */
  62831. easeInCore(gradient: number): number;
  62832. }
  62833. /**
  62834. * Easing function with an elastic shape (see link below).
  62835. * @see https://easings.net/#easeInElastic
  62836. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62837. */
  62838. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62839. /** Defines the number of oscillations*/
  62840. oscillations: number;
  62841. /** Defines the amplitude of the oscillations*/
  62842. springiness: number;
  62843. /**
  62844. * Instantiates an elastic easing function
  62845. * @see https://easings.net/#easeInElastic
  62846. * @param oscillations Defines the number of oscillations
  62847. * @param springiness Defines the amplitude of the oscillations
  62848. */
  62849. constructor(
  62850. /** Defines the number of oscillations*/
  62851. oscillations?: number,
  62852. /** Defines the amplitude of the oscillations*/
  62853. springiness?: number);
  62854. /** @hidden */
  62855. easeInCore(gradient: number): number;
  62856. }
  62857. /**
  62858. * Easing function with an exponential shape (see link below).
  62859. * @see https://easings.net/#easeInExpo
  62860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62861. */
  62862. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  62863. /** Defines the exponent of the function */
  62864. exponent: number;
  62865. /**
  62866. * Instantiates an exponential easing function
  62867. * @see https://easings.net/#easeInExpo
  62868. * @param exponent Defines the exponent of the function
  62869. */
  62870. constructor(
  62871. /** Defines the exponent of the function */
  62872. exponent?: number);
  62873. /** @hidden */
  62874. easeInCore(gradient: number): number;
  62875. }
  62876. /**
  62877. * Easing function with a power shape (see link below).
  62878. * @see https://easings.net/#easeInQuad
  62879. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62880. */
  62881. export class PowerEase extends EasingFunction implements IEasingFunction {
  62882. /** Defines the power of the function */
  62883. power: number;
  62884. /**
  62885. * Instantiates an power base easing function
  62886. * @see https://easings.net/#easeInQuad
  62887. * @param power Defines the power of the function
  62888. */
  62889. constructor(
  62890. /** Defines the power of the function */
  62891. power?: number);
  62892. /** @hidden */
  62893. easeInCore(gradient: number): number;
  62894. }
  62895. /**
  62896. * Easing function with a power of 2 shape (see link below).
  62897. * @see https://easings.net/#easeInQuad
  62898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62899. */
  62900. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  62901. /** @hidden */
  62902. easeInCore(gradient: number): number;
  62903. }
  62904. /**
  62905. * Easing function with a power of 4 shape (see link below).
  62906. * @see https://easings.net/#easeInQuart
  62907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62908. */
  62909. export class QuarticEase extends EasingFunction implements IEasingFunction {
  62910. /** @hidden */
  62911. easeInCore(gradient: number): number;
  62912. }
  62913. /**
  62914. * Easing function with a power of 5 shape (see link below).
  62915. * @see https://easings.net/#easeInQuint
  62916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62917. */
  62918. export class QuinticEase extends EasingFunction implements IEasingFunction {
  62919. /** @hidden */
  62920. easeInCore(gradient: number): number;
  62921. }
  62922. /**
  62923. * Easing function with a sin shape (see link below).
  62924. * @see https://easings.net/#easeInSine
  62925. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62926. */
  62927. export class SineEase extends EasingFunction implements IEasingFunction {
  62928. /** @hidden */
  62929. easeInCore(gradient: number): number;
  62930. }
  62931. /**
  62932. * Easing function with a bezier shape (see link below).
  62933. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  62934. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62935. */
  62936. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  62937. /** Defines the x component of the start tangent in the bezier curve */
  62938. x1: number;
  62939. /** Defines the y component of the start tangent in the bezier curve */
  62940. y1: number;
  62941. /** Defines the x component of the end tangent in the bezier curve */
  62942. x2: number;
  62943. /** Defines the y component of the end tangent in the bezier curve */
  62944. y2: number;
  62945. /**
  62946. * Instantiates a bezier function
  62947. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  62948. * @param x1 Defines the x component of the start tangent in the bezier curve
  62949. * @param y1 Defines the y component of the start tangent in the bezier curve
  62950. * @param x2 Defines the x component of the end tangent in the bezier curve
  62951. * @param y2 Defines the y component of the end tangent in the bezier curve
  62952. */
  62953. constructor(
  62954. /** Defines the x component of the start tangent in the bezier curve */
  62955. x1?: number,
  62956. /** Defines the y component of the start tangent in the bezier curve */
  62957. y1?: number,
  62958. /** Defines the x component of the end tangent in the bezier curve */
  62959. x2?: number,
  62960. /** Defines the y component of the end tangent in the bezier curve */
  62961. y2?: number);
  62962. /** @hidden */
  62963. easeInCore(gradient: number): number;
  62964. }
  62965. }
  62966. declare module BABYLON {
  62967. /**
  62968. * Interface used to define a behavior
  62969. */
  62970. export interface Behavior<T> {
  62971. /** gets or sets behavior's name */
  62972. name: string;
  62973. /**
  62974. * Function called when the behavior needs to be initialized (after attaching it to a target)
  62975. */
  62976. init(): void;
  62977. /**
  62978. * Called when the behavior is attached to a target
  62979. * @param target defines the target where the behavior is attached to
  62980. */
  62981. attach(target: T): void;
  62982. /**
  62983. * Called when the behavior is detached from its target
  62984. */
  62985. detach(): void;
  62986. }
  62987. /**
  62988. * Interface implemented by classes supporting behaviors
  62989. */
  62990. export interface IBehaviorAware<T> {
  62991. /**
  62992. * Attach a behavior
  62993. * @param behavior defines the behavior to attach
  62994. * @returns the current host
  62995. */
  62996. addBehavior(behavior: Behavior<T>): T;
  62997. /**
  62998. * Remove a behavior from the current object
  62999. * @param behavior defines the behavior to detach
  63000. * @returns the current host
  63001. */
  63002. removeBehavior(behavior: Behavior<T>): T;
  63003. /**
  63004. * Gets a behavior using its name to search
  63005. * @param name defines the name to search
  63006. * @returns the behavior or null if not found
  63007. */
  63008. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63009. }
  63010. }
  63011. declare module BABYLON {
  63012. /**
  63013. * Defines a runtime animation
  63014. */
  63015. export class RuntimeAnimation {
  63016. private _events;
  63017. /**
  63018. * The current frame of the runtime animation
  63019. */
  63020. private _currentFrame;
  63021. /**
  63022. * The animation used by the runtime animation
  63023. */
  63024. private _animation;
  63025. /**
  63026. * The target of the runtime animation
  63027. */
  63028. private _target;
  63029. /**
  63030. * The initiating animatable
  63031. */
  63032. private _host;
  63033. /**
  63034. * The original value of the runtime animation
  63035. */
  63036. private _originalValue;
  63037. /**
  63038. * The original blend value of the runtime animation
  63039. */
  63040. private _originalBlendValue;
  63041. /**
  63042. * The offsets cache of the runtime animation
  63043. */
  63044. private _offsetsCache;
  63045. /**
  63046. * The high limits cache of the runtime animation
  63047. */
  63048. private _highLimitsCache;
  63049. /**
  63050. * Specifies if the runtime animation has been stopped
  63051. */
  63052. private _stopped;
  63053. /**
  63054. * The blending factor of the runtime animation
  63055. */
  63056. private _blendingFactor;
  63057. /**
  63058. * The BabylonJS scene
  63059. */
  63060. private _scene;
  63061. /**
  63062. * The current value of the runtime animation
  63063. */
  63064. private _currentValue;
  63065. /** @hidden */
  63066. _workValue: any;
  63067. /**
  63068. * The active target of the runtime animation
  63069. */
  63070. private _activeTarget;
  63071. /**
  63072. * The target path of the runtime animation
  63073. */
  63074. private _targetPath;
  63075. /**
  63076. * The weight of the runtime animation
  63077. */
  63078. private _weight;
  63079. /**
  63080. * The ratio offset of the runtime animation
  63081. */
  63082. private _ratioOffset;
  63083. /**
  63084. * The previous delay of the runtime animation
  63085. */
  63086. private _previousDelay;
  63087. /**
  63088. * The previous ratio of the runtime animation
  63089. */
  63090. private _previousRatio;
  63091. /**
  63092. * Gets the current frame of the runtime animation
  63093. */
  63094. readonly currentFrame: number;
  63095. /**
  63096. * Gets the weight of the runtime animation
  63097. */
  63098. readonly weight: number;
  63099. /**
  63100. * Gets the current value of the runtime animation
  63101. */
  63102. readonly currentValue: any;
  63103. /**
  63104. * Gets the target path of the runtime animation
  63105. */
  63106. readonly targetPath: string;
  63107. /**
  63108. * Gets the actual target of the runtime animation
  63109. */
  63110. readonly target: any;
  63111. /**
  63112. * Create a new RuntimeAnimation object
  63113. * @param target defines the target of the animation
  63114. * @param animation defines the source animation object
  63115. * @param scene defines the hosting scene
  63116. * @param host defines the initiating Animatable
  63117. */
  63118. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  63119. /**
  63120. * Gets the animation from the runtime animation
  63121. */
  63122. readonly animation: Animation;
  63123. /**
  63124. * Resets the runtime animation to the beginning
  63125. * @param restoreOriginal defines whether to restore the target property to the original value
  63126. */
  63127. reset(restoreOriginal?: boolean): void;
  63128. /**
  63129. * Specifies if the runtime animation is stopped
  63130. * @returns Boolean specifying if the runtime animation is stopped
  63131. */
  63132. isStopped(): boolean;
  63133. /**
  63134. * Disposes of the runtime animation
  63135. */
  63136. dispose(): void;
  63137. /**
  63138. * Interpolates the animation from the current frame
  63139. * @param currentFrame The frame to interpolate the animation to
  63140. * @param repeatCount The number of times that the animation should loop
  63141. * @param loopMode The type of looping mode to use
  63142. * @param offsetValue Animation offset value
  63143. * @param highLimitValue The high limit value
  63144. * @returns The interpolated value
  63145. */
  63146. private _interpolate;
  63147. /**
  63148. * Apply the interpolated value to the target
  63149. * @param currentValue defines the value computed by the animation
  63150. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  63151. */
  63152. setValue(currentValue: any, weight?: number): void;
  63153. private _setValue;
  63154. /**
  63155. * Gets the loop pmode of the runtime animation
  63156. * @returns Loop Mode
  63157. */
  63158. private _getCorrectLoopMode;
  63159. /**
  63160. * Move the current animation to a given frame
  63161. * @param frame defines the frame to move to
  63162. */
  63163. goToFrame(frame: number): void;
  63164. /**
  63165. * @hidden Internal use only
  63166. */
  63167. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  63168. /**
  63169. * Execute the current animation
  63170. * @param delay defines the delay to add to the current frame
  63171. * @param from defines the lower bound of the animation range
  63172. * @param to defines the upper bound of the animation range
  63173. * @param loop defines if the current animation must loop
  63174. * @param speedRatio defines the current speed ratio
  63175. * @param weight defines the weight of the animation (default is -1 so no weight)
  63176. * @param onLoop optional callback called when animation loops
  63177. * @returns a boolean indicating if the animation is running
  63178. */
  63179. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  63180. }
  63181. }
  63182. declare module BABYLON {
  63183. /**
  63184. * Class used to store an actual running animation
  63185. */
  63186. export class Animatable {
  63187. /** defines the target object */
  63188. target: any;
  63189. /** defines the starting frame number (default is 0) */
  63190. fromFrame: number;
  63191. /** defines the ending frame number (default is 100) */
  63192. toFrame: number;
  63193. /** defines if the animation must loop (default is false) */
  63194. loopAnimation: boolean;
  63195. /** defines a callback to call when animation ends if it is not looping */
  63196. onAnimationEnd?: (() => void) | null | undefined;
  63197. /** defines a callback to call when animation loops */
  63198. onAnimationLoop?: (() => void) | null | undefined;
  63199. private _localDelayOffset;
  63200. private _pausedDelay;
  63201. private _runtimeAnimations;
  63202. private _paused;
  63203. private _scene;
  63204. private _speedRatio;
  63205. private _weight;
  63206. private _syncRoot;
  63207. /**
  63208. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  63209. * This will only apply for non looping animation (default is true)
  63210. */
  63211. disposeOnEnd: boolean;
  63212. /**
  63213. * Gets a boolean indicating if the animation has started
  63214. */
  63215. animationStarted: boolean;
  63216. /**
  63217. * Observer raised when the animation ends
  63218. */
  63219. onAnimationEndObservable: Observable<Animatable>;
  63220. /**
  63221. * Observer raised when the animation loops
  63222. */
  63223. onAnimationLoopObservable: Observable<Animatable>;
  63224. /**
  63225. * Gets the root Animatable used to synchronize and normalize animations
  63226. */
  63227. readonly syncRoot: Animatable;
  63228. /**
  63229. * Gets the current frame of the first RuntimeAnimation
  63230. * Used to synchronize Animatables
  63231. */
  63232. readonly masterFrame: number;
  63233. /**
  63234. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  63235. */
  63236. weight: number;
  63237. /**
  63238. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  63239. */
  63240. speedRatio: number;
  63241. /**
  63242. * Creates a new Animatable
  63243. * @param scene defines the hosting scene
  63244. * @param target defines the target object
  63245. * @param fromFrame defines the starting frame number (default is 0)
  63246. * @param toFrame defines the ending frame number (default is 100)
  63247. * @param loopAnimation defines if the animation must loop (default is false)
  63248. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  63249. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  63250. * @param animations defines a group of animation to add to the new Animatable
  63251. * @param onAnimationLoop defines a callback to call when animation loops
  63252. */
  63253. constructor(scene: Scene,
  63254. /** defines the target object */
  63255. target: any,
  63256. /** defines the starting frame number (default is 0) */
  63257. fromFrame?: number,
  63258. /** defines the ending frame number (default is 100) */
  63259. toFrame?: number,
  63260. /** defines if the animation must loop (default is false) */
  63261. loopAnimation?: boolean, speedRatio?: number,
  63262. /** defines a callback to call when animation ends if it is not looping */
  63263. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  63264. /** defines a callback to call when animation loops */
  63265. onAnimationLoop?: (() => void) | null | undefined);
  63266. /**
  63267. * Synchronize and normalize current Animatable with a source Animatable
  63268. * This is useful when using animation weights and when animations are not of the same length
  63269. * @param root defines the root Animatable to synchronize with
  63270. * @returns the current Animatable
  63271. */
  63272. syncWith(root: Animatable): Animatable;
  63273. /**
  63274. * Gets the list of runtime animations
  63275. * @returns an array of RuntimeAnimation
  63276. */
  63277. getAnimations(): RuntimeAnimation[];
  63278. /**
  63279. * Adds more animations to the current animatable
  63280. * @param target defines the target of the animations
  63281. * @param animations defines the new animations to add
  63282. */
  63283. appendAnimations(target: any, animations: Animation[]): void;
  63284. /**
  63285. * Gets the source animation for a specific property
  63286. * @param property defines the propertyu to look for
  63287. * @returns null or the source animation for the given property
  63288. */
  63289. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  63290. /**
  63291. * Gets the runtime animation for a specific property
  63292. * @param property defines the propertyu to look for
  63293. * @returns null or the runtime animation for the given property
  63294. */
  63295. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  63296. /**
  63297. * Resets the animatable to its original state
  63298. */
  63299. reset(): void;
  63300. /**
  63301. * Allows the animatable to blend with current running animations
  63302. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  63303. * @param blendingSpeed defines the blending speed to use
  63304. */
  63305. enableBlending(blendingSpeed: number): void;
  63306. /**
  63307. * Disable animation blending
  63308. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  63309. */
  63310. disableBlending(): void;
  63311. /**
  63312. * Jump directly to a given frame
  63313. * @param frame defines the frame to jump to
  63314. */
  63315. goToFrame(frame: number): void;
  63316. /**
  63317. * Pause the animation
  63318. */
  63319. pause(): void;
  63320. /**
  63321. * Restart the animation
  63322. */
  63323. restart(): void;
  63324. private _raiseOnAnimationEnd;
  63325. /**
  63326. * Stop and delete the current animation
  63327. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  63328. * @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)
  63329. */
  63330. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  63331. /**
  63332. * Wait asynchronously for the animation to end
  63333. * @returns a promise which will be fullfilled when the animation ends
  63334. */
  63335. waitAsync(): Promise<Animatable>;
  63336. /** @hidden */
  63337. _animate(delay: number): boolean;
  63338. }
  63339. }
  63340. declare module BABYLON {
  63341. /**
  63342. * Class used to override all child animations of a given target
  63343. */
  63344. export class AnimationPropertiesOverride {
  63345. /**
  63346. * Gets or sets a value indicating if animation blending must be used
  63347. */
  63348. enableBlending: boolean;
  63349. /**
  63350. * Gets or sets the blending speed to use when enableBlending is true
  63351. */
  63352. blendingSpeed: number;
  63353. /**
  63354. * Gets or sets the default loop mode to use
  63355. */
  63356. loopMode: number;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * @hidden
  63362. */
  63363. export class IntersectionInfo {
  63364. bu: Nullable<number>;
  63365. bv: Nullable<number>;
  63366. distance: number;
  63367. faceId: number;
  63368. subMeshId: number;
  63369. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63370. }
  63371. }
  63372. declare module BABYLON {
  63373. /**
  63374. * Interface used to define ActionEvent
  63375. */
  63376. export interface IActionEvent {
  63377. /** The mesh or sprite that triggered the action */
  63378. source: any;
  63379. /** The X mouse cursor position at the time of the event */
  63380. pointerX: number;
  63381. /** The Y mouse cursor position at the time of the event */
  63382. pointerY: number;
  63383. /** The mesh that is currently pointed at (can be null) */
  63384. meshUnderPointer: Nullable<AbstractMesh>;
  63385. /** the original (browser) event that triggered the ActionEvent */
  63386. sourceEvent?: any;
  63387. /** additional data for the event */
  63388. additionalData?: any;
  63389. }
  63390. /**
  63391. * ActionEvent is the event being sent when an action is triggered.
  63392. */
  63393. export class ActionEvent implements IActionEvent {
  63394. /** The mesh or sprite that triggered the action */
  63395. source: any;
  63396. /** The X mouse cursor position at the time of the event */
  63397. pointerX: number;
  63398. /** The Y mouse cursor position at the time of the event */
  63399. pointerY: number;
  63400. /** The mesh that is currently pointed at (can be null) */
  63401. meshUnderPointer: Nullable<AbstractMesh>;
  63402. /** the original (browser) event that triggered the ActionEvent */
  63403. sourceEvent?: any;
  63404. /** additional data for the event */
  63405. additionalData?: any;
  63406. /**
  63407. * Creates a new ActionEvent
  63408. * @param source The mesh or sprite that triggered the action
  63409. * @param pointerX The X mouse cursor position at the time of the event
  63410. * @param pointerY The Y mouse cursor position at the time of the event
  63411. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  63412. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  63413. * @param additionalData additional data for the event
  63414. */
  63415. constructor(
  63416. /** The mesh or sprite that triggered the action */
  63417. source: any,
  63418. /** The X mouse cursor position at the time of the event */
  63419. pointerX: number,
  63420. /** The Y mouse cursor position at the time of the event */
  63421. pointerY: number,
  63422. /** The mesh that is currently pointed at (can be null) */
  63423. meshUnderPointer: Nullable<AbstractMesh>,
  63424. /** the original (browser) event that triggered the ActionEvent */
  63425. sourceEvent?: any,
  63426. /** additional data for the event */
  63427. additionalData?: any);
  63428. /**
  63429. * Helper function to auto-create an ActionEvent from a source mesh.
  63430. * @param source The source mesh that triggered the event
  63431. * @param evt The original (browser) event
  63432. * @param additionalData additional data for the event
  63433. * @returns the new ActionEvent
  63434. */
  63435. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  63436. /**
  63437. * Helper function to auto-create an ActionEvent from a source sprite
  63438. * @param source The source sprite that triggered the event
  63439. * @param scene Scene associated with the sprite
  63440. * @param evt The original (browser) event
  63441. * @param additionalData additional data for the event
  63442. * @returns the new ActionEvent
  63443. */
  63444. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  63445. /**
  63446. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  63447. * @param scene the scene where the event occurred
  63448. * @param evt The original (browser) event
  63449. * @returns the new ActionEvent
  63450. */
  63451. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  63452. /**
  63453. * Helper function to auto-create an ActionEvent from a primitive
  63454. * @param prim defines the target primitive
  63455. * @param pointerPos defines the pointer position
  63456. * @param evt The original (browser) event
  63457. * @param additionalData additional data for the event
  63458. * @returns the new ActionEvent
  63459. */
  63460. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  63461. }
  63462. }
  63463. declare module BABYLON {
  63464. /**
  63465. * Class used to store bounding sphere information
  63466. */
  63467. export class BoundingSphere {
  63468. /**
  63469. * Gets the center of the bounding sphere in local space
  63470. */
  63471. readonly center: Vector3;
  63472. /**
  63473. * Radius of the bounding sphere in local space
  63474. */
  63475. radius: number;
  63476. /**
  63477. * Gets the center of the bounding sphere in world space
  63478. */
  63479. readonly centerWorld: Vector3;
  63480. /**
  63481. * Radius of the bounding sphere in world space
  63482. */
  63483. radiusWorld: number;
  63484. /**
  63485. * Gets the minimum vector in local space
  63486. */
  63487. readonly minimum: Vector3;
  63488. /**
  63489. * Gets the maximum vector in local space
  63490. */
  63491. readonly maximum: Vector3;
  63492. private _worldMatrix;
  63493. private static readonly TmpVector3;
  63494. /**
  63495. * Creates a new bounding sphere
  63496. * @param min defines the minimum vector (in local space)
  63497. * @param max defines the maximum vector (in local space)
  63498. * @param worldMatrix defines the new world matrix
  63499. */
  63500. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63501. /**
  63502. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63503. * @param min defines the new minimum vector (in local space)
  63504. * @param max defines the new maximum vector (in local space)
  63505. * @param worldMatrix defines the new world matrix
  63506. */
  63507. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63508. /**
  63509. * Scale the current bounding sphere by applying a scale factor
  63510. * @param factor defines the scale factor to apply
  63511. * @returns the current bounding box
  63512. */
  63513. scale(factor: number): BoundingSphere;
  63514. /**
  63515. * Gets the world matrix of the bounding box
  63516. * @returns a matrix
  63517. */
  63518. getWorldMatrix(): DeepImmutable<Matrix>;
  63519. /** @hidden */
  63520. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63521. /**
  63522. * Tests if the bounding sphere is intersecting the frustum planes
  63523. * @param frustumPlanes defines the frustum planes to test
  63524. * @returns true if there is an intersection
  63525. */
  63526. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63527. /**
  63528. * Tests if the bounding sphere center is in between the frustum planes.
  63529. * Used for optimistic fast inclusion.
  63530. * @param frustumPlanes defines the frustum planes to test
  63531. * @returns true if the sphere center is in between the frustum planes
  63532. */
  63533. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63534. /**
  63535. * Tests if a point is inside the bounding sphere
  63536. * @param point defines the point to test
  63537. * @returns true if the point is inside the bounding sphere
  63538. */
  63539. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63540. /**
  63541. * Checks if two sphere intersct
  63542. * @param sphere0 sphere 0
  63543. * @param sphere1 sphere 1
  63544. * @returns true if the speres intersect
  63545. */
  63546. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63547. }
  63548. }
  63549. declare module BABYLON {
  63550. /**
  63551. * Class used to store bounding box information
  63552. */
  63553. export class BoundingBox implements ICullable {
  63554. /**
  63555. * Gets the 8 vectors representing the bounding box in local space
  63556. */
  63557. readonly vectors: Vector3[];
  63558. /**
  63559. * Gets the center of the bounding box in local space
  63560. */
  63561. readonly center: Vector3;
  63562. /**
  63563. * Gets the center of the bounding box in world space
  63564. */
  63565. readonly centerWorld: Vector3;
  63566. /**
  63567. * Gets the extend size in local space
  63568. */
  63569. readonly extendSize: Vector3;
  63570. /**
  63571. * Gets the extend size in world space
  63572. */
  63573. readonly extendSizeWorld: Vector3;
  63574. /**
  63575. * Gets the OBB (object bounding box) directions
  63576. */
  63577. readonly directions: Vector3[];
  63578. /**
  63579. * Gets the 8 vectors representing the bounding box in world space
  63580. */
  63581. readonly vectorsWorld: Vector3[];
  63582. /**
  63583. * Gets the minimum vector in world space
  63584. */
  63585. readonly minimumWorld: Vector3;
  63586. /**
  63587. * Gets the maximum vector in world space
  63588. */
  63589. readonly maximumWorld: Vector3;
  63590. /**
  63591. * Gets the minimum vector in local space
  63592. */
  63593. readonly minimum: Vector3;
  63594. /**
  63595. * Gets the maximum vector in local space
  63596. */
  63597. readonly maximum: Vector3;
  63598. private _worldMatrix;
  63599. private static readonly TmpVector3;
  63600. /**
  63601. * @hidden
  63602. */
  63603. _tag: number;
  63604. /**
  63605. * Creates a new bounding box
  63606. * @param min defines the minimum vector (in local space)
  63607. * @param max defines the maximum vector (in local space)
  63608. * @param worldMatrix defines the new world matrix
  63609. */
  63610. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63611. /**
  63612. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63613. * @param min defines the new minimum vector (in local space)
  63614. * @param max defines the new maximum vector (in local space)
  63615. * @param worldMatrix defines the new world matrix
  63616. */
  63617. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63618. /**
  63619. * Scale the current bounding box by applying a scale factor
  63620. * @param factor defines the scale factor to apply
  63621. * @returns the current bounding box
  63622. */
  63623. scale(factor: number): BoundingBox;
  63624. /**
  63625. * Gets the world matrix of the bounding box
  63626. * @returns a matrix
  63627. */
  63628. getWorldMatrix(): DeepImmutable<Matrix>;
  63629. /** @hidden */
  63630. _update(world: DeepImmutable<Matrix>): void;
  63631. /**
  63632. * Tests if the bounding box is intersecting the frustum planes
  63633. * @param frustumPlanes defines the frustum planes to test
  63634. * @returns true if there is an intersection
  63635. */
  63636. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63637. /**
  63638. * Tests if the bounding box is entirely inside the frustum planes
  63639. * @param frustumPlanes defines the frustum planes to test
  63640. * @returns true if there is an inclusion
  63641. */
  63642. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63643. /**
  63644. * Tests if a point is inside the bounding box
  63645. * @param point defines the point to test
  63646. * @returns true if the point is inside the bounding box
  63647. */
  63648. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63649. /**
  63650. * Tests if the bounding box intersects with a bounding sphere
  63651. * @param sphere defines the sphere to test
  63652. * @returns true if there is an intersection
  63653. */
  63654. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63655. /**
  63656. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63657. * @param min defines the min vector to use
  63658. * @param max defines the max vector to use
  63659. * @returns true if there is an intersection
  63660. */
  63661. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63662. /**
  63663. * Tests if two bounding boxes are intersections
  63664. * @param box0 defines the first box to test
  63665. * @param box1 defines the second box to test
  63666. * @returns true if there is an intersection
  63667. */
  63668. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63669. /**
  63670. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63671. * @param minPoint defines the minimum vector of the bounding box
  63672. * @param maxPoint defines the maximum vector of the bounding box
  63673. * @param sphereCenter defines the sphere center
  63674. * @param sphereRadius defines the sphere radius
  63675. * @returns true if there is an intersection
  63676. */
  63677. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63678. /**
  63679. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63680. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63681. * @param frustumPlanes defines the frustum planes to test
  63682. * @return true if there is an inclusion
  63683. */
  63684. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63685. /**
  63686. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63687. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63688. * @param frustumPlanes defines the frustum planes to test
  63689. * @return true if there is an intersection
  63690. */
  63691. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63692. }
  63693. }
  63694. declare module BABYLON {
  63695. /** @hidden */
  63696. export class Collider {
  63697. /** Define if a collision was found */
  63698. collisionFound: boolean;
  63699. /**
  63700. * Define last intersection point in local space
  63701. */
  63702. intersectionPoint: Vector3;
  63703. /**
  63704. * Define last collided mesh
  63705. */
  63706. collidedMesh: Nullable<AbstractMesh>;
  63707. private _collisionPoint;
  63708. private _planeIntersectionPoint;
  63709. private _tempVector;
  63710. private _tempVector2;
  63711. private _tempVector3;
  63712. private _tempVector4;
  63713. private _edge;
  63714. private _baseToVertex;
  63715. private _destinationPoint;
  63716. private _slidePlaneNormal;
  63717. private _displacementVector;
  63718. /** @hidden */
  63719. _radius: Vector3;
  63720. /** @hidden */
  63721. _retry: number;
  63722. private _velocity;
  63723. private _basePoint;
  63724. private _epsilon;
  63725. /** @hidden */
  63726. _velocityWorldLength: number;
  63727. /** @hidden */
  63728. _basePointWorld: Vector3;
  63729. private _velocityWorld;
  63730. private _normalizedVelocity;
  63731. /** @hidden */
  63732. _initialVelocity: Vector3;
  63733. /** @hidden */
  63734. _initialPosition: Vector3;
  63735. private _nearestDistance;
  63736. private _collisionMask;
  63737. collisionMask: number;
  63738. /**
  63739. * Gets the plane normal used to compute the sliding response (in local space)
  63740. */
  63741. readonly slidePlaneNormal: Vector3;
  63742. /** @hidden */
  63743. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63744. /** @hidden */
  63745. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63746. /** @hidden */
  63747. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63748. /** @hidden */
  63749. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63750. /** @hidden */
  63751. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63752. /** @hidden */
  63753. _getResponse(pos: Vector3, vel: Vector3): void;
  63754. }
  63755. }
  63756. declare module BABYLON {
  63757. /**
  63758. * Interface for cullable objects
  63759. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63760. */
  63761. export interface ICullable {
  63762. /**
  63763. * Checks if the object or part of the object is in the frustum
  63764. * @param frustumPlanes Camera near/planes
  63765. * @returns true if the object is in frustum otherwise false
  63766. */
  63767. isInFrustum(frustumPlanes: Plane[]): boolean;
  63768. /**
  63769. * Checks if a cullable object (mesh...) is in the camera frustum
  63770. * Unlike isInFrustum this cheks the full bounding box
  63771. * @param frustumPlanes Camera near/planes
  63772. * @returns true if the object is in frustum otherwise false
  63773. */
  63774. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63775. }
  63776. /**
  63777. * Info for a bounding data of a mesh
  63778. */
  63779. export class BoundingInfo implements ICullable {
  63780. /**
  63781. * Bounding box for the mesh
  63782. */
  63783. readonly boundingBox: BoundingBox;
  63784. /**
  63785. * Bounding sphere for the mesh
  63786. */
  63787. readonly boundingSphere: BoundingSphere;
  63788. private _isLocked;
  63789. private static readonly TmpVector3;
  63790. /**
  63791. * Constructs bounding info
  63792. * @param minimum min vector of the bounding box/sphere
  63793. * @param maximum max vector of the bounding box/sphere
  63794. * @param worldMatrix defines the new world matrix
  63795. */
  63796. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63797. /**
  63798. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63799. * @param min defines the new minimum vector (in local space)
  63800. * @param max defines the new maximum vector (in local space)
  63801. * @param worldMatrix defines the new world matrix
  63802. */
  63803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63804. /**
  63805. * min vector of the bounding box/sphere
  63806. */
  63807. readonly minimum: Vector3;
  63808. /**
  63809. * max vector of the bounding box/sphere
  63810. */
  63811. readonly maximum: Vector3;
  63812. /**
  63813. * If the info is locked and won't be updated to avoid perf overhead
  63814. */
  63815. isLocked: boolean;
  63816. /**
  63817. * Updates the bounding sphere and box
  63818. * @param world world matrix to be used to update
  63819. */
  63820. update(world: DeepImmutable<Matrix>): void;
  63821. /**
  63822. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63823. * @param center New center of the bounding info
  63824. * @param extend New extend of the bounding info
  63825. * @returns the current bounding info
  63826. */
  63827. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63828. /**
  63829. * Scale the current bounding info by applying a scale factor
  63830. * @param factor defines the scale factor to apply
  63831. * @returns the current bounding info
  63832. */
  63833. scale(factor: number): BoundingInfo;
  63834. /**
  63835. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63836. * @param frustumPlanes defines the frustum to test
  63837. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63838. * @returns true if the bounding info is in the frustum planes
  63839. */
  63840. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63841. /**
  63842. * Gets the world distance between the min and max points of the bounding box
  63843. */
  63844. readonly diagonalLength: number;
  63845. /**
  63846. * Checks if a cullable object (mesh...) is in the camera frustum
  63847. * Unlike isInFrustum this cheks the full bounding box
  63848. * @param frustumPlanes Camera near/planes
  63849. * @returns true if the object is in frustum otherwise false
  63850. */
  63851. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63852. /** @hidden */
  63853. _checkCollision(collider: Collider): boolean;
  63854. /**
  63855. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63856. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63857. * @param point the point to check intersection with
  63858. * @returns if the point intersects
  63859. */
  63860. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63861. /**
  63862. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63863. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63864. * @param boundingInfo the bounding info to check intersection with
  63865. * @param precise if the intersection should be done using OBB
  63866. * @returns if the bounding info intersects
  63867. */
  63868. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63869. }
  63870. }
  63871. declare module BABYLON {
  63872. /**
  63873. * Defines an array and its length.
  63874. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63875. */
  63876. export interface ISmartArrayLike<T> {
  63877. /**
  63878. * The data of the array.
  63879. */
  63880. data: Array<T>;
  63881. /**
  63882. * The active length of the array.
  63883. */
  63884. length: number;
  63885. }
  63886. /**
  63887. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63888. */
  63889. export class SmartArray<T> implements ISmartArrayLike<T> {
  63890. /**
  63891. * The full set of data from the array.
  63892. */
  63893. data: Array<T>;
  63894. /**
  63895. * The active length of the array.
  63896. */
  63897. length: number;
  63898. protected _id: number;
  63899. /**
  63900. * Instantiates a Smart Array.
  63901. * @param capacity defines the default capacity of the array.
  63902. */
  63903. constructor(capacity: number);
  63904. /**
  63905. * Pushes a value at the end of the active data.
  63906. * @param value defines the object to push in the array.
  63907. */
  63908. push(value: T): void;
  63909. /**
  63910. * Iterates over the active data and apply the lambda to them.
  63911. * @param func defines the action to apply on each value.
  63912. */
  63913. forEach(func: (content: T) => void): void;
  63914. /**
  63915. * Sorts the full sets of data.
  63916. * @param compareFn defines the comparison function to apply.
  63917. */
  63918. sort(compareFn: (a: T, b: T) => number): void;
  63919. /**
  63920. * Resets the active data to an empty array.
  63921. */
  63922. reset(): void;
  63923. /**
  63924. * Releases all the data from the array as well as the array.
  63925. */
  63926. dispose(): void;
  63927. /**
  63928. * Concats the active data with a given array.
  63929. * @param array defines the data to concatenate with.
  63930. */
  63931. concat(array: any): void;
  63932. /**
  63933. * Returns the position of a value in the active data.
  63934. * @param value defines the value to find the index for
  63935. * @returns the index if found in the active data otherwise -1
  63936. */
  63937. indexOf(value: T): number;
  63938. /**
  63939. * Returns whether an element is part of the active data.
  63940. * @param value defines the value to look for
  63941. * @returns true if found in the active data otherwise false
  63942. */
  63943. contains(value: T): boolean;
  63944. private static _GlobalId;
  63945. }
  63946. /**
  63947. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63948. * The data in this array can only be present once
  63949. */
  63950. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63951. private _duplicateId;
  63952. /**
  63953. * Pushes a value at the end of the active data.
  63954. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63955. * @param value defines the object to push in the array.
  63956. */
  63957. push(value: T): void;
  63958. /**
  63959. * Pushes a value at the end of the active data.
  63960. * If the data is already present, it won t be added again
  63961. * @param value defines the object to push in the array.
  63962. * @returns true if added false if it was already present
  63963. */
  63964. pushNoDuplicate(value: T): boolean;
  63965. /**
  63966. * Resets the active data to an empty array.
  63967. */
  63968. reset(): void;
  63969. /**
  63970. * Concats the active data with a given array.
  63971. * This ensures no dupplicate will be present in the result.
  63972. * @param array defines the data to concatenate with.
  63973. */
  63974. concatWithNoDuplicate(array: any): void;
  63975. }
  63976. }
  63977. declare module BABYLON {
  63978. /**
  63979. * Class for creating a cube texture
  63980. */
  63981. export class CubeTexture extends BaseTexture {
  63982. private _delayedOnLoad;
  63983. /**
  63984. * The url of the texture
  63985. */
  63986. url: string;
  63987. /**
  63988. * Gets or sets the center of the bounding box associated with the cube texture.
  63989. * It must define where the camera used to render the texture was set
  63990. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  63991. */
  63992. boundingBoxPosition: Vector3;
  63993. private _boundingBoxSize;
  63994. /**
  63995. * Gets or sets the size of the bounding box associated with the cube texture
  63996. * When defined, the cubemap will switch to local mode
  63997. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63998. * @example https://www.babylonjs-playground.com/#RNASML
  63999. */
  64000. /**
  64001. * Returns the bounding box size
  64002. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  64003. */
  64004. boundingBoxSize: Vector3;
  64005. protected _rotationY: number;
  64006. /**
  64007. * Sets texture matrix rotation angle around Y axis in radians.
  64008. */
  64009. /**
  64010. * Gets texture matrix rotation angle around Y axis radians.
  64011. */
  64012. rotationY: number;
  64013. /**
  64014. * Are mip maps generated for this texture or not.
  64015. */
  64016. readonly noMipmap: boolean;
  64017. private _noMipmap;
  64018. private _files;
  64019. private _extensions;
  64020. private _textureMatrix;
  64021. private _format;
  64022. private _createPolynomials;
  64023. /** @hidden */
  64024. _prefiltered: boolean;
  64025. /**
  64026. * Creates a cube texture from an array of image urls
  64027. * @param files defines an array of image urls
  64028. * @param scene defines the hosting scene
  64029. * @param noMipmap specifies if mip maps are not used
  64030. * @returns a cube texture
  64031. */
  64032. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  64033. /**
  64034. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  64035. * @param url defines the url of the prefiltered texture
  64036. * @param scene defines the scene the texture is attached to
  64037. * @param forcedExtension defines the extension of the file if different from the url
  64038. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64039. * @return the prefiltered texture
  64040. */
  64041. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  64042. /**
  64043. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  64044. * as prefiltered data.
  64045. * @param rootUrl defines the url of the texture or the root name of the six images
  64046. * @param scene defines the scene the texture is attached to
  64047. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  64048. * @param noMipmap defines if mipmaps should be created or not
  64049. * @param files defines the six files to load for the different faces
  64050. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  64051. * @param onError defines a callback triggered in case of error during load
  64052. * @param format defines the internal format to use for the texture once loaded
  64053. * @param prefiltered defines whether or not the texture is created from prefiltered data
  64054. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  64055. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64056. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64057. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64058. * @return the cube texture
  64059. */
  64060. 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);
  64061. /**
  64062. * Get the current class name of the texture useful for serialization or dynamic coding.
  64063. * @returns "CubeTexture"
  64064. */
  64065. getClassName(): string;
  64066. /**
  64067. * Update the url (and optional buffer) of this texture if url was null during construction.
  64068. * @param url the url of the texture
  64069. * @param forcedExtension defines the extension to use
  64070. * @param onLoad callback called when the texture is loaded (defaults to null)
  64071. */
  64072. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  64073. /**
  64074. * Delays loading of the cube texture
  64075. * @param forcedExtension defines the extension to use
  64076. */
  64077. delayLoad(forcedExtension?: string): void;
  64078. /**
  64079. * Returns the reflection texture matrix
  64080. * @returns the reflection texture matrix
  64081. */
  64082. getReflectionTextureMatrix(): Matrix;
  64083. /**
  64084. * Sets the reflection texture matrix
  64085. * @param value Reflection texture matrix
  64086. */
  64087. setReflectionTextureMatrix(value: Matrix): void;
  64088. /**
  64089. * Parses text to create a cube texture
  64090. * @param parsedTexture define the serialized text to read from
  64091. * @param scene defines the hosting scene
  64092. * @param rootUrl defines the root url of the cube texture
  64093. * @returns a cube texture
  64094. */
  64095. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  64096. /**
  64097. * Makes a clone, or deep copy, of the cube texture
  64098. * @returns a new cube texture
  64099. */
  64100. clone(): CubeTexture;
  64101. }
  64102. }
  64103. declare module BABYLON {
  64104. /** @hidden */
  64105. export var postprocessVertexShader: {
  64106. name: string;
  64107. shader: string;
  64108. };
  64109. }
  64110. declare module BABYLON {
  64111. /**
  64112. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  64113. * This is the base of the follow, arc rotate cameras and Free camera
  64114. * @see http://doc.babylonjs.com/features/cameras
  64115. */
  64116. export class TargetCamera extends Camera {
  64117. private static _RigCamTransformMatrix;
  64118. private static _TargetTransformMatrix;
  64119. private static _TargetFocalPoint;
  64120. /**
  64121. * Define the current direction the camera is moving to
  64122. */
  64123. cameraDirection: Vector3;
  64124. /**
  64125. * Define the current rotation the camera is rotating to
  64126. */
  64127. cameraRotation: Vector2;
  64128. /**
  64129. * When set, the up vector of the camera will be updated by the rotation of the camera
  64130. */
  64131. updateUpVectorFromRotation: boolean;
  64132. private _tmpQuaternion;
  64133. /**
  64134. * Define the current rotation of the camera
  64135. */
  64136. rotation: Vector3;
  64137. /**
  64138. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  64139. */
  64140. rotationQuaternion: Quaternion;
  64141. /**
  64142. * Define the current speed of the camera
  64143. */
  64144. speed: number;
  64145. /**
  64146. * Add cconstraint to the camera to prevent it to move freely in all directions and
  64147. * around all axis.
  64148. */
  64149. noRotationConstraint: boolean;
  64150. /**
  64151. * Define the current target of the camera as an object or a position.
  64152. */
  64153. lockedTarget: any;
  64154. /** @hidden */
  64155. _currentTarget: Vector3;
  64156. /** @hidden */
  64157. _initialFocalDistance: number;
  64158. /** @hidden */
  64159. _viewMatrix: Matrix;
  64160. /** @hidden */
  64161. _camMatrix: Matrix;
  64162. /** @hidden */
  64163. _cameraTransformMatrix: Matrix;
  64164. /** @hidden */
  64165. _cameraRotationMatrix: Matrix;
  64166. /** @hidden */
  64167. _referencePoint: Vector3;
  64168. /** @hidden */
  64169. _transformedReferencePoint: Vector3;
  64170. protected _globalCurrentTarget: Vector3;
  64171. protected _globalCurrentUpVector: Vector3;
  64172. /** @hidden */
  64173. _reset: () => void;
  64174. private _defaultUp;
  64175. /**
  64176. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  64177. * This is the base of the follow, arc rotate cameras and Free camera
  64178. * @see http://doc.babylonjs.com/features/cameras
  64179. * @param name Defines the name of the camera in the scene
  64180. * @param position Defines the start position of the camera in the scene
  64181. * @param scene Defines the scene the camera belongs to
  64182. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64183. */
  64184. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64185. /**
  64186. * Gets the position in front of the camera at a given distance.
  64187. * @param distance The distance from the camera we want the position to be
  64188. * @returns the position
  64189. */
  64190. getFrontPosition(distance: number): Vector3;
  64191. /** @hidden */
  64192. _getLockedTargetPosition(): Nullable<Vector3>;
  64193. private _storedPosition;
  64194. private _storedRotation;
  64195. private _storedRotationQuaternion;
  64196. /**
  64197. * Store current camera state of the camera (fov, position, rotation, etc..)
  64198. * @returns the camera
  64199. */
  64200. storeState(): Camera;
  64201. /**
  64202. * Restored camera state. You must call storeState() first
  64203. * @returns whether it was successful or not
  64204. * @hidden
  64205. */
  64206. _restoreStateValues(): boolean;
  64207. /** @hidden */
  64208. _initCache(): void;
  64209. /** @hidden */
  64210. _updateCache(ignoreParentClass?: boolean): void;
  64211. /** @hidden */
  64212. _isSynchronizedViewMatrix(): boolean;
  64213. /** @hidden */
  64214. _computeLocalCameraSpeed(): number;
  64215. /** @hidden */
  64216. setTarget(target: Vector3): void;
  64217. /**
  64218. * Return the current target position of the camera. This value is expressed in local space.
  64219. * @returns the target position
  64220. */
  64221. getTarget(): Vector3;
  64222. /** @hidden */
  64223. _decideIfNeedsToMove(): boolean;
  64224. /** @hidden */
  64225. _updatePosition(): void;
  64226. /** @hidden */
  64227. _checkInputs(): void;
  64228. protected _updateCameraRotationMatrix(): void;
  64229. /**
  64230. * 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)
  64231. * @returns the current camera
  64232. */
  64233. private _rotateUpVectorWithCameraRotationMatrix;
  64234. private _cachedRotationZ;
  64235. private _cachedQuaternionRotationZ;
  64236. /** @hidden */
  64237. _getViewMatrix(): Matrix;
  64238. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  64239. /**
  64240. * @hidden
  64241. */
  64242. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  64243. /**
  64244. * @hidden
  64245. */
  64246. _updateRigCameras(): void;
  64247. private _getRigCamPositionAndTarget;
  64248. /**
  64249. * Gets the current object class name.
  64250. * @return the class name
  64251. */
  64252. getClassName(): string;
  64253. }
  64254. }
  64255. declare module BABYLON {
  64256. /**
  64257. * @ignore
  64258. * This is a list of all the different input types that are available in the application.
  64259. * Fo instance: ArcRotateCameraGamepadInput...
  64260. */
  64261. export var CameraInputTypes: {};
  64262. /**
  64263. * This is the contract to implement in order to create a new input class.
  64264. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  64265. */
  64266. export interface ICameraInput<TCamera extends Camera> {
  64267. /**
  64268. * Defines the camera the input is attached to.
  64269. */
  64270. camera: Nullable<TCamera>;
  64271. /**
  64272. * Gets the class name of the current intput.
  64273. * @returns the class name
  64274. */
  64275. getClassName(): string;
  64276. /**
  64277. * Get the friendly name associated with the input class.
  64278. * @returns the input friendly name
  64279. */
  64280. getSimpleName(): string;
  64281. /**
  64282. * Attach the input controls to a specific dom element to get the input from.
  64283. * @param element Defines the element the controls should be listened from
  64284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64285. */
  64286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64287. /**
  64288. * Detach the current controls from the specified dom element.
  64289. * @param element Defines the element to stop listening the inputs from
  64290. */
  64291. detachControl(element: Nullable<HTMLElement>): void;
  64292. /**
  64293. * Update the current camera state depending on the inputs that have been used this frame.
  64294. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64295. */
  64296. checkInputs?: () => void;
  64297. }
  64298. /**
  64299. * Represents a map of input types to input instance or input index to input instance.
  64300. */
  64301. export interface CameraInputsMap<TCamera extends Camera> {
  64302. /**
  64303. * Accessor to the input by input type.
  64304. */
  64305. [name: string]: ICameraInput<TCamera>;
  64306. /**
  64307. * Accessor to the input by input index.
  64308. */
  64309. [idx: number]: ICameraInput<TCamera>;
  64310. }
  64311. /**
  64312. * This represents the input manager used within a camera.
  64313. * It helps dealing with all the different kind of input attached to a camera.
  64314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64315. */
  64316. export class CameraInputsManager<TCamera extends Camera> {
  64317. /**
  64318. * Defines the list of inputs attahed to the camera.
  64319. */
  64320. attached: CameraInputsMap<TCamera>;
  64321. /**
  64322. * Defines the dom element the camera is collecting inputs from.
  64323. * This is null if the controls have not been attached.
  64324. */
  64325. attachedElement: Nullable<HTMLElement>;
  64326. /**
  64327. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64328. */
  64329. noPreventDefault: boolean;
  64330. /**
  64331. * Defined the camera the input manager belongs to.
  64332. */
  64333. camera: TCamera;
  64334. /**
  64335. * Update the current camera state depending on the inputs that have been used this frame.
  64336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64337. */
  64338. checkInputs: () => void;
  64339. /**
  64340. * Instantiate a new Camera Input Manager.
  64341. * @param camera Defines the camera the input manager blongs to
  64342. */
  64343. constructor(camera: TCamera);
  64344. /**
  64345. * Add an input method to a camera
  64346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64347. * @param input camera input method
  64348. */
  64349. add(input: ICameraInput<TCamera>): void;
  64350. /**
  64351. * Remove a specific input method from a camera
  64352. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  64353. * @param inputToRemove camera input method
  64354. */
  64355. remove(inputToRemove: ICameraInput<TCamera>): void;
  64356. /**
  64357. * Remove a specific input type from a camera
  64358. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  64359. * @param inputType the type of the input to remove
  64360. */
  64361. removeByType(inputType: string): void;
  64362. private _addCheckInputs;
  64363. /**
  64364. * Attach the input controls to the currently attached dom element to listen the events from.
  64365. * @param input Defines the input to attach
  64366. */
  64367. attachInput(input: ICameraInput<TCamera>): void;
  64368. /**
  64369. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  64370. * @param element Defines the dom element to collect the events from
  64371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64372. */
  64373. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  64374. /**
  64375. * Detach the current manager inputs controls from a specific dom element.
  64376. * @param element Defines the dom element to collect the events from
  64377. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  64378. */
  64379. detachElement(element: HTMLElement, disconnect?: boolean): void;
  64380. /**
  64381. * Rebuild the dynamic inputCheck function from the current list of
  64382. * defined inputs in the manager.
  64383. */
  64384. rebuildInputCheck(): void;
  64385. /**
  64386. * Remove all attached input methods from a camera
  64387. */
  64388. clear(): void;
  64389. /**
  64390. * Serialize the current input manager attached to a camera.
  64391. * This ensures than once parsed,
  64392. * the input associated to the camera will be identical to the current ones
  64393. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  64394. */
  64395. serialize(serializedCamera: any): void;
  64396. /**
  64397. * Parses an input manager serialized JSON to restore the previous list of inputs
  64398. * and states associated to a camera.
  64399. * @param parsedCamera Defines the JSON to parse
  64400. */
  64401. parse(parsedCamera: any): void;
  64402. }
  64403. }
  64404. declare module BABYLON {
  64405. /**
  64406. * Gather the list of keyboard event types as constants.
  64407. */
  64408. export class KeyboardEventTypes {
  64409. /**
  64410. * The keydown event is fired when a key becomes active (pressed).
  64411. */
  64412. static readonly KEYDOWN: number;
  64413. /**
  64414. * The keyup event is fired when a key has been released.
  64415. */
  64416. static readonly KEYUP: number;
  64417. }
  64418. /**
  64419. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64420. */
  64421. export class KeyboardInfo {
  64422. /**
  64423. * Defines the type of event (KeyboardEventTypes)
  64424. */
  64425. type: number;
  64426. /**
  64427. * Defines the related dom event
  64428. */
  64429. event: KeyboardEvent;
  64430. /**
  64431. * Instantiates a new keyboard info.
  64432. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64433. * @param type Defines the type of event (KeyboardEventTypes)
  64434. * @param event Defines the related dom event
  64435. */
  64436. constructor(
  64437. /**
  64438. * Defines the type of event (KeyboardEventTypes)
  64439. */
  64440. type: number,
  64441. /**
  64442. * Defines the related dom event
  64443. */
  64444. event: KeyboardEvent);
  64445. }
  64446. /**
  64447. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64448. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  64449. */
  64450. export class KeyboardInfoPre extends KeyboardInfo {
  64451. /**
  64452. * Defines the type of event (KeyboardEventTypes)
  64453. */
  64454. type: number;
  64455. /**
  64456. * Defines the related dom event
  64457. */
  64458. event: KeyboardEvent;
  64459. /**
  64460. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  64461. */
  64462. skipOnPointerObservable: boolean;
  64463. /**
  64464. * Instantiates a new keyboard pre info.
  64465. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64466. * @param type Defines the type of event (KeyboardEventTypes)
  64467. * @param event Defines the related dom event
  64468. */
  64469. constructor(
  64470. /**
  64471. * Defines the type of event (KeyboardEventTypes)
  64472. */
  64473. type: number,
  64474. /**
  64475. * Defines the related dom event
  64476. */
  64477. event: KeyboardEvent);
  64478. }
  64479. }
  64480. declare module BABYLON {
  64481. /**
  64482. * Manage the keyboard inputs to control the movement of a free camera.
  64483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64484. */
  64485. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64486. /**
  64487. * Defines the camera the input is attached to.
  64488. */
  64489. camera: FreeCamera;
  64490. /**
  64491. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64492. */
  64493. keysUp: number[];
  64494. /**
  64495. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64496. */
  64497. keysDown: number[];
  64498. /**
  64499. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64500. */
  64501. keysLeft: number[];
  64502. /**
  64503. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64504. */
  64505. keysRight: number[];
  64506. private _keys;
  64507. private _onCanvasBlurObserver;
  64508. private _onKeyboardObserver;
  64509. private _engine;
  64510. private _scene;
  64511. /**
  64512. * Attach the input controls to a specific dom element to get the input from.
  64513. * @param element Defines the element the controls should be listened from
  64514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64515. */
  64516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64517. /**
  64518. * Detach the current controls from the specified dom element.
  64519. * @param element Defines the element to stop listening the inputs from
  64520. */
  64521. detachControl(element: Nullable<HTMLElement>): void;
  64522. /**
  64523. * Update the current camera state depending on the inputs that have been used this frame.
  64524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64525. */
  64526. checkInputs(): void;
  64527. /**
  64528. * Gets the class name of the current intput.
  64529. * @returns the class name
  64530. */
  64531. getClassName(): string;
  64532. /** @hidden */
  64533. _onLostFocus(): void;
  64534. /**
  64535. * Get the friendly name associated with the input class.
  64536. * @returns the input friendly name
  64537. */
  64538. getSimpleName(): string;
  64539. }
  64540. }
  64541. declare module BABYLON {
  64542. /**
  64543. * Gather the list of pointer event types as constants.
  64544. */
  64545. export class PointerEventTypes {
  64546. /**
  64547. * 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.
  64548. */
  64549. static readonly POINTERDOWN: number;
  64550. /**
  64551. * The pointerup event is fired when a pointer is no longer active.
  64552. */
  64553. static readonly POINTERUP: number;
  64554. /**
  64555. * The pointermove event is fired when a pointer changes coordinates.
  64556. */
  64557. static readonly POINTERMOVE: number;
  64558. /**
  64559. * The pointerwheel event is fired when a mouse wheel has been rotated.
  64560. */
  64561. static readonly POINTERWHEEL: number;
  64562. /**
  64563. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  64564. */
  64565. static readonly POINTERPICK: number;
  64566. /**
  64567. * The pointertap event is fired when a the object has been touched and released without drag.
  64568. */
  64569. static readonly POINTERTAP: number;
  64570. /**
  64571. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  64572. */
  64573. static readonly POINTERDOUBLETAP: number;
  64574. }
  64575. /**
  64576. * Base class of pointer info types.
  64577. */
  64578. export class PointerInfoBase {
  64579. /**
  64580. * Defines the type of event (PointerEventTypes)
  64581. */
  64582. type: number;
  64583. /**
  64584. * Defines the related dom event
  64585. */
  64586. event: PointerEvent | MouseWheelEvent;
  64587. /**
  64588. * Instantiates the base class of pointers info.
  64589. * @param type Defines the type of event (PointerEventTypes)
  64590. * @param event Defines the related dom event
  64591. */
  64592. constructor(
  64593. /**
  64594. * Defines the type of event (PointerEventTypes)
  64595. */
  64596. type: number,
  64597. /**
  64598. * Defines the related dom event
  64599. */
  64600. event: PointerEvent | MouseWheelEvent);
  64601. }
  64602. /**
  64603. * This class is used to store pointer related info for the onPrePointerObservable event.
  64604. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  64605. */
  64606. export class PointerInfoPre extends PointerInfoBase {
  64607. /**
  64608. * Ray from a pointer if availible (eg. 6dof controller)
  64609. */
  64610. ray: Nullable<Ray>;
  64611. /**
  64612. * Defines the local position of the pointer on the canvas.
  64613. */
  64614. localPosition: Vector2;
  64615. /**
  64616. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  64617. */
  64618. skipOnPointerObservable: boolean;
  64619. /**
  64620. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  64621. * @param type Defines the type of event (PointerEventTypes)
  64622. * @param event Defines the related dom event
  64623. * @param localX Defines the local x coordinates of the pointer when the event occured
  64624. * @param localY Defines the local y coordinates of the pointer when the event occured
  64625. */
  64626. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  64627. }
  64628. /**
  64629. * This type contains all the data related to a pointer event in Babylon.js.
  64630. * 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.
  64631. */
  64632. export class PointerInfo extends PointerInfoBase {
  64633. /**
  64634. * Defines the picking info associated to the info (if any)\
  64635. */
  64636. pickInfo: Nullable<PickingInfo>;
  64637. /**
  64638. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  64639. * @param type Defines the type of event (PointerEventTypes)
  64640. * @param event Defines the related dom event
  64641. * @param pickInfo Defines the picking info associated to the info (if any)\
  64642. */
  64643. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  64644. /**
  64645. * Defines the picking info associated to the info (if any)\
  64646. */
  64647. pickInfo: Nullable<PickingInfo>);
  64648. }
  64649. }
  64650. declare module BABYLON {
  64651. /**
  64652. * Manage the mouse inputs to control the movement of a free camera.
  64653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64654. */
  64655. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  64656. /**
  64657. * Define if touch is enabled in the mouse input
  64658. */
  64659. touchEnabled: boolean;
  64660. /**
  64661. * Defines the camera the input is attached to.
  64662. */
  64663. camera: FreeCamera;
  64664. /**
  64665. * Defines the buttons associated with the input to handle camera move.
  64666. */
  64667. buttons: number[];
  64668. /**
  64669. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  64670. */
  64671. angularSensibility: number;
  64672. private _pointerInput;
  64673. private _onMouseMove;
  64674. private _observer;
  64675. private previousPosition;
  64676. /**
  64677. * Manage the mouse inputs to control the movement of a free camera.
  64678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64679. * @param touchEnabled Defines if touch is enabled or not
  64680. */
  64681. constructor(
  64682. /**
  64683. * Define if touch is enabled in the mouse input
  64684. */
  64685. touchEnabled?: boolean);
  64686. /**
  64687. * Attach the input controls to a specific dom element to get the input from.
  64688. * @param element Defines the element the controls should be listened from
  64689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64690. */
  64691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64692. /**
  64693. * Detach the current controls from the specified dom element.
  64694. * @param element Defines the element to stop listening the inputs from
  64695. */
  64696. detachControl(element: Nullable<HTMLElement>): void;
  64697. /**
  64698. * Gets the class name of the current intput.
  64699. * @returns the class name
  64700. */
  64701. getClassName(): string;
  64702. /**
  64703. * Get the friendly name associated with the input class.
  64704. * @returns the input friendly name
  64705. */
  64706. getSimpleName(): string;
  64707. }
  64708. }
  64709. declare module BABYLON {
  64710. /**
  64711. * Manage the touch inputs to control the movement of a free camera.
  64712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64713. */
  64714. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  64715. /**
  64716. * Defines the camera the input is attached to.
  64717. */
  64718. camera: FreeCamera;
  64719. /**
  64720. * Defines the touch sensibility for rotation.
  64721. * The higher the faster.
  64722. */
  64723. touchAngularSensibility: number;
  64724. /**
  64725. * Defines the touch sensibility for move.
  64726. * The higher the faster.
  64727. */
  64728. touchMoveSensibility: number;
  64729. private _offsetX;
  64730. private _offsetY;
  64731. private _pointerPressed;
  64732. private _pointerInput;
  64733. private _observer;
  64734. private _onLostFocus;
  64735. /**
  64736. * Attach the input controls to a specific dom element to get the input from.
  64737. * @param element Defines the element the controls should be listened from
  64738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64739. */
  64740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64741. /**
  64742. * Detach the current controls from the specified dom element.
  64743. * @param element Defines the element to stop listening the inputs from
  64744. */
  64745. detachControl(element: Nullable<HTMLElement>): void;
  64746. /**
  64747. * Update the current camera state depending on the inputs that have been used this frame.
  64748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64749. */
  64750. checkInputs(): void;
  64751. /**
  64752. * Gets the class name of the current intput.
  64753. * @returns the class name
  64754. */
  64755. getClassName(): string;
  64756. /**
  64757. * Get the friendly name associated with the input class.
  64758. * @returns the input friendly name
  64759. */
  64760. getSimpleName(): string;
  64761. }
  64762. }
  64763. declare module BABYLON {
  64764. /**
  64765. * Default Inputs manager for the FreeCamera.
  64766. * It groups all the default supported inputs for ease of use.
  64767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64768. */
  64769. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  64770. /**
  64771. * Instantiates a new FreeCameraInputsManager.
  64772. * @param camera Defines the camera the inputs belong to
  64773. */
  64774. constructor(camera: FreeCamera);
  64775. /**
  64776. * Add keyboard input support to the input manager.
  64777. * @returns the current input manager
  64778. */
  64779. addKeyboard(): FreeCameraInputsManager;
  64780. /**
  64781. * Add mouse input support to the input manager.
  64782. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  64783. * @returns the current input manager
  64784. */
  64785. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  64786. /**
  64787. * Add touch input support to the input manager.
  64788. * @returns the current input manager
  64789. */
  64790. addTouch(): FreeCameraInputsManager;
  64791. }
  64792. }
  64793. declare module BABYLON {
  64794. /**
  64795. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  64796. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  64797. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  64798. */
  64799. export class FreeCamera extends TargetCamera {
  64800. /**
  64801. * Define the collision ellipsoid of the camera.
  64802. * This is helpful to simulate a camera body like the player body around the camera
  64803. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  64804. */
  64805. ellipsoid: Vector3;
  64806. /**
  64807. * Define an offset for the position of the ellipsoid around the camera.
  64808. * This can be helpful to determine the center of the body near the gravity center of the body
  64809. * instead of its head.
  64810. */
  64811. ellipsoidOffset: Vector3;
  64812. /**
  64813. * Enable or disable collisions of the camera with the rest of the scene objects.
  64814. */
  64815. checkCollisions: boolean;
  64816. /**
  64817. * Enable or disable gravity on the camera.
  64818. */
  64819. applyGravity: boolean;
  64820. /**
  64821. * Define the input manager associated to the camera.
  64822. */
  64823. inputs: FreeCameraInputsManager;
  64824. /**
  64825. * Gets the input sensibility for a mouse input. (default is 2000.0)
  64826. * Higher values reduce sensitivity.
  64827. */
  64828. /**
  64829. * Sets the input sensibility for a mouse input. (default is 2000.0)
  64830. * Higher values reduce sensitivity.
  64831. */
  64832. angularSensibility: number;
  64833. /**
  64834. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64835. */
  64836. keysUp: number[];
  64837. /**
  64838. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64839. */
  64840. keysDown: number[];
  64841. /**
  64842. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64843. */
  64844. keysLeft: number[];
  64845. /**
  64846. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64847. */
  64848. keysRight: number[];
  64849. /**
  64850. * Event raised when the camera collide with a mesh in the scene.
  64851. */
  64852. onCollide: (collidedMesh: AbstractMesh) => void;
  64853. private _collider;
  64854. private _needMoveForGravity;
  64855. private _oldPosition;
  64856. private _diffPosition;
  64857. private _newPosition;
  64858. /** @hidden */
  64859. _localDirection: Vector3;
  64860. /** @hidden */
  64861. _transformedDirection: Vector3;
  64862. /**
  64863. * Instantiates a Free Camera.
  64864. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  64865. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  64866. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  64867. * @param name Define the name of the camera in the scene
  64868. * @param position Define the start position of the camera in the scene
  64869. * @param scene Define the scene the camera belongs to
  64870. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64871. */
  64872. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64873. /**
  64874. * Attached controls to the current camera.
  64875. * @param element Defines the element the controls should be listened from
  64876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64877. */
  64878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64879. /**
  64880. * Detach the current controls from the camera.
  64881. * The camera will stop reacting to inputs.
  64882. * @param element Defines the element to stop listening the inputs from
  64883. */
  64884. detachControl(element: HTMLElement): void;
  64885. private _collisionMask;
  64886. /**
  64887. * Define a collision mask to limit the list of object the camera can collide with
  64888. */
  64889. collisionMask: number;
  64890. /** @hidden */
  64891. _collideWithWorld(displacement: Vector3): void;
  64892. private _onCollisionPositionChange;
  64893. /** @hidden */
  64894. _checkInputs(): void;
  64895. /** @hidden */
  64896. _decideIfNeedsToMove(): boolean;
  64897. /** @hidden */
  64898. _updatePosition(): void;
  64899. /**
  64900. * Destroy the camera and release the current resources hold by it.
  64901. */
  64902. dispose(): void;
  64903. /**
  64904. * Gets the current object class name.
  64905. * @return the class name
  64906. */
  64907. getClassName(): string;
  64908. }
  64909. }
  64910. declare module BABYLON {
  64911. /**
  64912. * Represents a gamepad control stick position
  64913. */
  64914. export class StickValues {
  64915. /**
  64916. * The x component of the control stick
  64917. */
  64918. x: number;
  64919. /**
  64920. * The y component of the control stick
  64921. */
  64922. y: number;
  64923. /**
  64924. * Initializes the gamepad x and y control stick values
  64925. * @param x The x component of the gamepad control stick value
  64926. * @param y The y component of the gamepad control stick value
  64927. */
  64928. constructor(
  64929. /**
  64930. * The x component of the control stick
  64931. */
  64932. x: number,
  64933. /**
  64934. * The y component of the control stick
  64935. */
  64936. y: number);
  64937. }
  64938. /**
  64939. * An interface which manages callbacks for gamepad button changes
  64940. */
  64941. export interface GamepadButtonChanges {
  64942. /**
  64943. * Called when a gamepad has been changed
  64944. */
  64945. changed: boolean;
  64946. /**
  64947. * Called when a gamepad press event has been triggered
  64948. */
  64949. pressChanged: boolean;
  64950. /**
  64951. * Called when a touch event has been triggered
  64952. */
  64953. touchChanged: boolean;
  64954. /**
  64955. * Called when a value has changed
  64956. */
  64957. valueChanged: boolean;
  64958. }
  64959. /**
  64960. * Represents a gamepad
  64961. */
  64962. export class Gamepad {
  64963. /**
  64964. * The id of the gamepad
  64965. */
  64966. id: string;
  64967. /**
  64968. * The index of the gamepad
  64969. */
  64970. index: number;
  64971. /**
  64972. * The browser gamepad
  64973. */
  64974. browserGamepad: any;
  64975. /**
  64976. * Specifies what type of gamepad this represents
  64977. */
  64978. type: number;
  64979. private _leftStick;
  64980. private _rightStick;
  64981. /** @hidden */
  64982. _isConnected: boolean;
  64983. private _leftStickAxisX;
  64984. private _leftStickAxisY;
  64985. private _rightStickAxisX;
  64986. private _rightStickAxisY;
  64987. /**
  64988. * Triggered when the left control stick has been changed
  64989. */
  64990. private _onleftstickchanged;
  64991. /**
  64992. * Triggered when the right control stick has been changed
  64993. */
  64994. private _onrightstickchanged;
  64995. /**
  64996. * Represents a gamepad controller
  64997. */
  64998. static GAMEPAD: number;
  64999. /**
  65000. * Represents a generic controller
  65001. */
  65002. static GENERIC: number;
  65003. /**
  65004. * Represents an XBox controller
  65005. */
  65006. static XBOX: number;
  65007. /**
  65008. * Represents a pose-enabled controller
  65009. */
  65010. static POSE_ENABLED: number;
  65011. /**
  65012. * Specifies whether the left control stick should be Y-inverted
  65013. */
  65014. protected _invertLeftStickY: boolean;
  65015. /**
  65016. * Specifies if the gamepad has been connected
  65017. */
  65018. readonly isConnected: boolean;
  65019. /**
  65020. * Initializes the gamepad
  65021. * @param id The id of the gamepad
  65022. * @param index The index of the gamepad
  65023. * @param browserGamepad The browser gamepad
  65024. * @param leftStickX The x component of the left joystick
  65025. * @param leftStickY The y component of the left joystick
  65026. * @param rightStickX The x component of the right joystick
  65027. * @param rightStickY The y component of the right joystick
  65028. */
  65029. constructor(
  65030. /**
  65031. * The id of the gamepad
  65032. */
  65033. id: string,
  65034. /**
  65035. * The index of the gamepad
  65036. */
  65037. index: number,
  65038. /**
  65039. * The browser gamepad
  65040. */
  65041. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  65042. /**
  65043. * Callback triggered when the left joystick has changed
  65044. * @param callback
  65045. */
  65046. onleftstickchanged(callback: (values: StickValues) => void): void;
  65047. /**
  65048. * Callback triggered when the right joystick has changed
  65049. * @param callback
  65050. */
  65051. onrightstickchanged(callback: (values: StickValues) => void): void;
  65052. /**
  65053. * Gets the left joystick
  65054. */
  65055. /**
  65056. * Sets the left joystick values
  65057. */
  65058. leftStick: StickValues;
  65059. /**
  65060. * Gets the right joystick
  65061. */
  65062. /**
  65063. * Sets the right joystick value
  65064. */
  65065. rightStick: StickValues;
  65066. /**
  65067. * Updates the gamepad joystick positions
  65068. */
  65069. update(): void;
  65070. /**
  65071. * Disposes the gamepad
  65072. */
  65073. dispose(): void;
  65074. }
  65075. /**
  65076. * Represents a generic gamepad
  65077. */
  65078. export class GenericPad extends Gamepad {
  65079. private _buttons;
  65080. private _onbuttondown;
  65081. private _onbuttonup;
  65082. /**
  65083. * Observable triggered when a button has been pressed
  65084. */
  65085. onButtonDownObservable: Observable<number>;
  65086. /**
  65087. * Observable triggered when a button has been released
  65088. */
  65089. onButtonUpObservable: Observable<number>;
  65090. /**
  65091. * Callback triggered when a button has been pressed
  65092. * @param callback Called when a button has been pressed
  65093. */
  65094. onbuttondown(callback: (buttonPressed: number) => void): void;
  65095. /**
  65096. * Callback triggered when a button has been released
  65097. * @param callback Called when a button has been released
  65098. */
  65099. onbuttonup(callback: (buttonReleased: number) => void): void;
  65100. /**
  65101. * Initializes the generic gamepad
  65102. * @param id The id of the generic gamepad
  65103. * @param index The index of the generic gamepad
  65104. * @param browserGamepad The browser gamepad
  65105. */
  65106. constructor(id: string, index: number, browserGamepad: any);
  65107. private _setButtonValue;
  65108. /**
  65109. * Updates the generic gamepad
  65110. */
  65111. update(): void;
  65112. /**
  65113. * Disposes the generic gamepad
  65114. */
  65115. dispose(): void;
  65116. }
  65117. }
  65118. declare module BABYLON {
  65119. /**
  65120. * Raw texture can help creating a texture directly from an array of data.
  65121. * This can be super useful if you either get the data from an uncompressed source or
  65122. * if you wish to create your texture pixel by pixel.
  65123. */
  65124. export class RawTexture extends Texture {
  65125. /**
  65126. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  65127. */
  65128. format: number;
  65129. private _engine;
  65130. /**
  65131. * Instantiates a new RawTexture.
  65132. * Raw texture can help creating a texture directly from an array of data.
  65133. * This can be super useful if you either get the data from an uncompressed source or
  65134. * if you wish to create your texture pixel by pixel.
  65135. * @param data define the array of data to use to create the texture
  65136. * @param width define the width of the texture
  65137. * @param height define the height of the texture
  65138. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  65139. * @param scene define the scene the texture belongs to
  65140. * @param generateMipMaps define whether mip maps should be generated or not
  65141. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65142. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65143. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  65144. */
  65145. constructor(data: ArrayBufferView, width: number, height: number,
  65146. /**
  65147. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  65148. */
  65149. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  65150. /**
  65151. * Updates the texture underlying data.
  65152. * @param data Define the new data of the texture
  65153. */
  65154. update(data: ArrayBufferView): void;
  65155. /**
  65156. * Creates a luminance texture from some data.
  65157. * @param data Define the texture data
  65158. * @param width Define the width of the texture
  65159. * @param height Define the height of the texture
  65160. * @param scene Define the scene the texture belongs to
  65161. * @param generateMipMaps Define whether or not to create mip maps for the texture
  65162. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65163. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65164. * @returns the luminance texture
  65165. */
  65166. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  65167. /**
  65168. * Creates a luminance alpha texture from some data.
  65169. * @param data Define the texture data
  65170. * @param width Define the width of the texture
  65171. * @param height Define the height of the texture
  65172. * @param scene Define the scene the texture belongs to
  65173. * @param generateMipMaps Define whether or not to create mip maps for the texture
  65174. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65175. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65176. * @returns the luminance alpha texture
  65177. */
  65178. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  65179. /**
  65180. * Creates an alpha texture from some data.
  65181. * @param data Define the texture data
  65182. * @param width Define the width of the texture
  65183. * @param height Define the height of the texture
  65184. * @param scene Define the scene the texture belongs to
  65185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  65186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65188. * @returns the alpha texture
  65189. */
  65190. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  65191. /**
  65192. * Creates a RGB texture from some data.
  65193. * @param data Define the texture data
  65194. * @param width Define the width of the texture
  65195. * @param height Define the height of the texture
  65196. * @param scene Define the scene the texture belongs to
  65197. * @param generateMipMaps Define whether or not to create mip maps for the texture
  65198. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65199. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65200. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  65201. * @returns the RGB alpha texture
  65202. */
  65203. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  65204. /**
  65205. * Creates a RGBA texture from some data.
  65206. * @param data Define the texture data
  65207. * @param width Define the width of the texture
  65208. * @param height Define the height of the texture
  65209. * @param scene Define the scene the texture belongs to
  65210. * @param generateMipMaps Define whether or not to create mip maps for the texture
  65211. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65212. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65213. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  65214. * @returns the RGBA texture
  65215. */
  65216. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  65217. /**
  65218. * Creates a R texture from some data.
  65219. * @param data Define the texture data
  65220. * @param width Define the width of the texture
  65221. * @param height Define the height of the texture
  65222. * @param scene Define the scene the texture belongs to
  65223. * @param generateMipMaps Define whether or not to create mip maps for the texture
  65224. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  65225. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  65226. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  65227. * @returns the R texture
  65228. */
  65229. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  65230. }
  65231. }
  65232. declare module BABYLON {
  65233. /**
  65234. * Class used to handle skinning animations
  65235. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65236. */
  65237. export class Skeleton implements IAnimatable {
  65238. /** defines the skeleton name */
  65239. name: string;
  65240. /** defines the skeleton Id */
  65241. id: string;
  65242. /**
  65243. * Defines the list of child bones
  65244. */
  65245. bones: Bone[];
  65246. /**
  65247. * Defines an estimate of the dimension of the skeleton at rest
  65248. */
  65249. dimensionsAtRest: Vector3;
  65250. /**
  65251. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  65252. */
  65253. needInitialSkinMatrix: boolean;
  65254. /**
  65255. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  65256. */
  65257. overrideMesh: Nullable<AbstractMesh>;
  65258. /**
  65259. * Gets the list of animations attached to this skeleton
  65260. */
  65261. animations: Array<Animation>;
  65262. private _scene;
  65263. private _isDirty;
  65264. private _transformMatrices;
  65265. private _transformMatrixTexture;
  65266. private _meshesWithPoseMatrix;
  65267. private _animatables;
  65268. private _identity;
  65269. private _synchronizedWithMesh;
  65270. private _ranges;
  65271. private _lastAbsoluteTransformsUpdateId;
  65272. private _canUseTextureForBones;
  65273. /** @hidden */
  65274. _numBonesWithLinkedTransformNode: number;
  65275. /**
  65276. * Specifies if the skeleton should be serialized
  65277. */
  65278. doNotSerialize: boolean;
  65279. /**
  65280. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  65281. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  65282. */
  65283. useTextureToStoreBoneMatrices: boolean;
  65284. private _animationPropertiesOverride;
  65285. /**
  65286. * Gets or sets the animation properties override
  65287. */
  65288. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65289. /**
  65290. * An observable triggered before computing the skeleton's matrices
  65291. */
  65292. onBeforeComputeObservable: Observable<Skeleton>;
  65293. /**
  65294. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  65295. */
  65296. readonly isUsingTextureForMatrices: boolean;
  65297. /**
  65298. * Creates a new skeleton
  65299. * @param name defines the skeleton name
  65300. * @param id defines the skeleton Id
  65301. * @param scene defines the hosting scene
  65302. */
  65303. constructor(
  65304. /** defines the skeleton name */
  65305. name: string,
  65306. /** defines the skeleton Id */
  65307. id: string, scene: Scene);
  65308. /**
  65309. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  65310. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  65311. * @returns a Float32Array containing matrices data
  65312. */
  65313. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  65314. /**
  65315. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  65316. * @returns a raw texture containing the data
  65317. */
  65318. getTransformMatrixTexture(): Nullable<RawTexture>;
  65319. /**
  65320. * Gets the current hosting scene
  65321. * @returns a scene object
  65322. */
  65323. getScene(): Scene;
  65324. /**
  65325. * Gets a string representing the current skeleton data
  65326. * @param fullDetails defines a boolean indicating if we want a verbose version
  65327. * @returns a string representing the current skeleton data
  65328. */
  65329. toString(fullDetails?: boolean): string;
  65330. /**
  65331. * Get bone's index searching by name
  65332. * @param name defines bone's name to search for
  65333. * @return the indice of the bone. Returns -1 if not found
  65334. */
  65335. getBoneIndexByName(name: string): number;
  65336. /**
  65337. * Creater a new animation range
  65338. * @param name defines the name of the range
  65339. * @param from defines the start key
  65340. * @param to defines the end key
  65341. */
  65342. createAnimationRange(name: string, from: number, to: number): void;
  65343. /**
  65344. * Delete a specific animation range
  65345. * @param name defines the name of the range
  65346. * @param deleteFrames defines if frames must be removed as well
  65347. */
  65348. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  65349. /**
  65350. * Gets a specific animation range
  65351. * @param name defines the name of the range to look for
  65352. * @returns the requested animation range or null if not found
  65353. */
  65354. getAnimationRange(name: string): Nullable<AnimationRange>;
  65355. /**
  65356. * Gets the list of all animation ranges defined on this skeleton
  65357. * @returns an array
  65358. */
  65359. getAnimationRanges(): Nullable<AnimationRange>[];
  65360. /**
  65361. * Copy animation range from a source skeleton.
  65362. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  65363. * @param source defines the source skeleton
  65364. * @param name defines the name of the range to copy
  65365. * @param rescaleAsRequired defines if rescaling must be applied if required
  65366. * @returns true if operation was successful
  65367. */
  65368. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  65369. /**
  65370. * Forces the skeleton to go to rest pose
  65371. */
  65372. returnToRest(): void;
  65373. private _getHighestAnimationFrame;
  65374. /**
  65375. * Begin a specific animation range
  65376. * @param name defines the name of the range to start
  65377. * @param loop defines if looping must be turned on (false by default)
  65378. * @param speedRatio defines the speed ratio to apply (1 by default)
  65379. * @param onAnimationEnd defines a callback which will be called when animation will end
  65380. * @returns a new animatable
  65381. */
  65382. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  65383. /** @hidden */
  65384. _markAsDirty(): void;
  65385. /** @hidden */
  65386. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  65387. /** @hidden */
  65388. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  65389. private _computeTransformMatrices;
  65390. /**
  65391. * Build all resources required to render a skeleton
  65392. */
  65393. prepare(): void;
  65394. /**
  65395. * Gets the list of animatables currently running for this skeleton
  65396. * @returns an array of animatables
  65397. */
  65398. getAnimatables(): IAnimatable[];
  65399. /**
  65400. * Clone the current skeleton
  65401. * @param name defines the name of the new skeleton
  65402. * @param id defines the id of the enw skeleton
  65403. * @returns the new skeleton
  65404. */
  65405. clone(name: string, id: string): Skeleton;
  65406. /**
  65407. * Enable animation blending for this skeleton
  65408. * @param blendingSpeed defines the blending speed to apply
  65409. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  65410. */
  65411. enableBlending(blendingSpeed?: number): void;
  65412. /**
  65413. * Releases all resources associated with the current skeleton
  65414. */
  65415. dispose(): void;
  65416. /**
  65417. * Serialize the skeleton in a JSON object
  65418. * @returns a JSON object
  65419. */
  65420. serialize(): any;
  65421. /**
  65422. * Creates a new skeleton from serialized data
  65423. * @param parsedSkeleton defines the serialized data
  65424. * @param scene defines the hosting scene
  65425. * @returns a new skeleton
  65426. */
  65427. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  65428. /**
  65429. * Compute all node absolute transforms
  65430. * @param forceUpdate defines if computation must be done even if cache is up to date
  65431. */
  65432. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  65433. /**
  65434. * Gets the root pose matrix
  65435. * @returns a matrix
  65436. */
  65437. getPoseMatrix(): Nullable<Matrix>;
  65438. /**
  65439. * Sorts bones per internal index
  65440. */
  65441. sortBones(): void;
  65442. private _sortBones;
  65443. }
  65444. }
  65445. declare module BABYLON {
  65446. /**
  65447. * Class used to store bone information
  65448. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65449. */
  65450. export class Bone extends Node {
  65451. /**
  65452. * defines the bone name
  65453. */
  65454. name: string;
  65455. private static _tmpVecs;
  65456. private static _tmpQuat;
  65457. private static _tmpMats;
  65458. /**
  65459. * Gets the list of child bones
  65460. */
  65461. children: Bone[];
  65462. /** Gets the animations associated with this bone */
  65463. animations: Animation[];
  65464. /**
  65465. * Gets or sets bone length
  65466. */
  65467. length: number;
  65468. /**
  65469. * @hidden Internal only
  65470. * Set this value to map this bone to a different index in the transform matrices
  65471. * Set this value to -1 to exclude the bone from the transform matrices
  65472. */
  65473. _index: Nullable<number>;
  65474. private _skeleton;
  65475. private _localMatrix;
  65476. private _restPose;
  65477. private _baseMatrix;
  65478. private _absoluteTransform;
  65479. private _invertedAbsoluteTransform;
  65480. private _parent;
  65481. private _scalingDeterminant;
  65482. private _worldTransform;
  65483. private _localScaling;
  65484. private _localRotation;
  65485. private _localPosition;
  65486. private _needToDecompose;
  65487. private _needToCompose;
  65488. /** @hidden */
  65489. _linkedTransformNode: Nullable<TransformNode>;
  65490. /** @hidden */
  65491. /** @hidden */
  65492. _matrix: Matrix;
  65493. /**
  65494. * Create a new bone
  65495. * @param name defines the bone name
  65496. * @param skeleton defines the parent skeleton
  65497. * @param parentBone defines the parent (can be null if the bone is the root)
  65498. * @param localMatrix defines the local matrix
  65499. * @param restPose defines the rest pose matrix
  65500. * @param baseMatrix defines the base matrix
  65501. * @param index defines index of the bone in the hiearchy
  65502. */
  65503. constructor(
  65504. /**
  65505. * defines the bone name
  65506. */
  65507. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65508. /**
  65509. * Gets the parent skeleton
  65510. * @returns a skeleton
  65511. */
  65512. getSkeleton(): Skeleton;
  65513. /**
  65514. * Gets parent bone
  65515. * @returns a bone or null if the bone is the root of the bone hierarchy
  65516. */
  65517. getParent(): Nullable<Bone>;
  65518. /**
  65519. * Sets the parent bone
  65520. * @param parent defines the parent (can be null if the bone is the root)
  65521. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65522. */
  65523. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65524. /**
  65525. * Gets the local matrix
  65526. * @returns a matrix
  65527. */
  65528. getLocalMatrix(): Matrix;
  65529. /**
  65530. * Gets the base matrix (initial matrix which remains unchanged)
  65531. * @returns a matrix
  65532. */
  65533. getBaseMatrix(): Matrix;
  65534. /**
  65535. * Gets the rest pose matrix
  65536. * @returns a matrix
  65537. */
  65538. getRestPose(): Matrix;
  65539. /**
  65540. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65541. */
  65542. getWorldMatrix(): Matrix;
  65543. /**
  65544. * Sets the local matrix to rest pose matrix
  65545. */
  65546. returnToRest(): void;
  65547. /**
  65548. * Gets the inverse of the absolute transform matrix.
  65549. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65550. * @returns a matrix
  65551. */
  65552. getInvertedAbsoluteTransform(): Matrix;
  65553. /**
  65554. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65555. * @returns a matrix
  65556. */
  65557. getAbsoluteTransform(): Matrix;
  65558. /**
  65559. * Links with the given transform node.
  65560. * The local matrix of this bone is copied from the transform node every frame.
  65561. * @param transformNode defines the transform node to link to
  65562. */
  65563. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65564. /** Gets or sets current position (in local space) */
  65565. position: Vector3;
  65566. /** Gets or sets current rotation (in local space) */
  65567. rotation: Vector3;
  65568. /** Gets or sets current rotation quaternion (in local space) */
  65569. rotationQuaternion: Quaternion;
  65570. /** Gets or sets current scaling (in local space) */
  65571. scaling: Vector3;
  65572. /**
  65573. * Gets the animation properties override
  65574. */
  65575. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65576. private _decompose;
  65577. private _compose;
  65578. /**
  65579. * Update the base and local matrices
  65580. * @param matrix defines the new base or local matrix
  65581. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65582. * @param updateLocalMatrix defines if the local matrix should be updated
  65583. */
  65584. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65585. /** @hidden */
  65586. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65587. /**
  65588. * Flag the bone as dirty (Forcing it to update everything)
  65589. */
  65590. markAsDirty(): void;
  65591. private _markAsDirtyAndCompose;
  65592. private _markAsDirtyAndDecompose;
  65593. /**
  65594. * Copy an animation range from another bone
  65595. * @param source defines the source bone
  65596. * @param rangeName defines the range name to copy
  65597. * @param frameOffset defines the frame offset
  65598. * @param rescaleAsRequired defines if rescaling must be applied if required
  65599. * @param skelDimensionsRatio defines the scaling ratio
  65600. * @returns true if operation was successful
  65601. */
  65602. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  65603. /**
  65604. * Translate the bone in local or world space
  65605. * @param vec The amount to translate the bone
  65606. * @param space The space that the translation is in
  65607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65608. */
  65609. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65610. /**
  65611. * Set the postion of the bone in local or world space
  65612. * @param position The position to set the bone
  65613. * @param space The space that the position is in
  65614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65615. */
  65616. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65617. /**
  65618. * Set the absolute position of the bone (world space)
  65619. * @param position The position to set the bone
  65620. * @param mesh The mesh that this bone is attached to
  65621. */
  65622. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65623. /**
  65624. * Scale the bone on the x, y and z axes (in local space)
  65625. * @param x The amount to scale the bone on the x axis
  65626. * @param y The amount to scale the bone on the y axis
  65627. * @param z The amount to scale the bone on the z axis
  65628. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65629. */
  65630. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65631. /**
  65632. * Set the bone scaling in local space
  65633. * @param scale defines the scaling vector
  65634. */
  65635. setScale(scale: Vector3): void;
  65636. /**
  65637. * Gets the current scaling in local space
  65638. * @returns the current scaling vector
  65639. */
  65640. getScale(): Vector3;
  65641. /**
  65642. * Gets the current scaling in local space and stores it in a target vector
  65643. * @param result defines the target vector
  65644. */
  65645. getScaleToRef(result: Vector3): void;
  65646. /**
  65647. * Set the yaw, pitch, and roll of the bone in local or world space
  65648. * @param yaw The rotation of the bone on the y axis
  65649. * @param pitch The rotation of the bone on the x axis
  65650. * @param roll The rotation of the bone on the z axis
  65651. * @param space The space that the axes of rotation are in
  65652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65653. */
  65654. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65655. /**
  65656. * Add a rotation to the bone on an axis in local or world space
  65657. * @param axis The axis to rotate the bone on
  65658. * @param amount The amount to rotate the bone
  65659. * @param space The space that the axis is in
  65660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65661. */
  65662. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65663. /**
  65664. * Set the rotation of the bone to a particular axis angle in local or world space
  65665. * @param axis The axis to rotate the bone on
  65666. * @param angle The angle that the bone should be rotated to
  65667. * @param space The space that the axis is in
  65668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65669. */
  65670. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65671. /**
  65672. * Set the euler rotation of the bone in local of world space
  65673. * @param rotation The euler rotation that the bone should be set to
  65674. * @param space The space that the rotation is in
  65675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65676. */
  65677. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65678. /**
  65679. * Set the quaternion rotation of the bone in local of world space
  65680. * @param quat The quaternion rotation that the bone should be set to
  65681. * @param space The space that the rotation is in
  65682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65683. */
  65684. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65685. /**
  65686. * Set the rotation matrix of the bone in local of world space
  65687. * @param rotMat The rotation matrix that the bone should be set to
  65688. * @param space The space that the rotation is in
  65689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65690. */
  65691. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65692. private _rotateWithMatrix;
  65693. private _getNegativeRotationToRef;
  65694. /**
  65695. * Get the position of the bone in local or world space
  65696. * @param space The space that the returned position is in
  65697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65698. * @returns The position of the bone
  65699. */
  65700. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65701. /**
  65702. * Copy the position of the bone to a vector3 in local or world space
  65703. * @param space The space that the returned position is in
  65704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65705. * @param result The vector3 to copy the position to
  65706. */
  65707. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65708. /**
  65709. * Get the absolute position of the bone (world space)
  65710. * @param mesh The mesh that this bone is attached to
  65711. * @returns The absolute position of the bone
  65712. */
  65713. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65714. /**
  65715. * Copy the absolute position of the bone (world space) to the result param
  65716. * @param mesh The mesh that this bone is attached to
  65717. * @param result The vector3 to copy the absolute position to
  65718. */
  65719. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65720. /**
  65721. * Compute the absolute transforms of this bone and its children
  65722. */
  65723. computeAbsoluteTransforms(): void;
  65724. /**
  65725. * Get the world direction from an axis that is in the local space of the bone
  65726. * @param localAxis The local direction that is used to compute the world direction
  65727. * @param mesh The mesh that this bone is attached to
  65728. * @returns The world direction
  65729. */
  65730. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65731. /**
  65732. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65733. * @param localAxis The local direction that is used to compute the world direction
  65734. * @param mesh The mesh that this bone is attached to
  65735. * @param result The vector3 that the world direction will be copied to
  65736. */
  65737. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65738. /**
  65739. * Get the euler rotation of the bone in local or world space
  65740. * @param space The space that the rotation should be in
  65741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65742. * @returns The euler rotation
  65743. */
  65744. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65745. /**
  65746. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65747. * @param space The space that the rotation should be in
  65748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65749. * @param result The vector3 that the rotation should be copied to
  65750. */
  65751. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65752. /**
  65753. * Get the quaternion rotation of the bone in either local or world space
  65754. * @param space The space that the rotation should be in
  65755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65756. * @returns The quaternion rotation
  65757. */
  65758. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65759. /**
  65760. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65761. * @param space The space that the rotation should be in
  65762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65763. * @param result The quaternion that the rotation should be copied to
  65764. */
  65765. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65766. /**
  65767. * Get the rotation matrix of the bone in local or world space
  65768. * @param space The space that the rotation should be in
  65769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65770. * @returns The rotation matrix
  65771. */
  65772. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65773. /**
  65774. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65775. * @param space The space that the rotation should be in
  65776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65777. * @param result The quaternion that the rotation should be copied to
  65778. */
  65779. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65780. /**
  65781. * Get the world position of a point that is in the local space of the bone
  65782. * @param position The local position
  65783. * @param mesh The mesh that this bone is attached to
  65784. * @returns The world position
  65785. */
  65786. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65787. /**
  65788. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65789. * @param position The local position
  65790. * @param mesh The mesh that this bone is attached to
  65791. * @param result The vector3 that the world position should be copied to
  65792. */
  65793. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65794. /**
  65795. * Get the local position of a point that is in world space
  65796. * @param position The world position
  65797. * @param mesh The mesh that this bone is attached to
  65798. * @returns The local position
  65799. */
  65800. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65801. /**
  65802. * Get the local position of a point that is in world space and copy it to the result param
  65803. * @param position The world position
  65804. * @param mesh The mesh that this bone is attached to
  65805. * @param result The vector3 that the local position should be copied to
  65806. */
  65807. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65808. }
  65809. }
  65810. declare module BABYLON {
  65811. /**
  65812. * 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.
  65813. * @see https://doc.babylonjs.com/how_to/transformnode
  65814. */
  65815. export class TransformNode extends Node {
  65816. /**
  65817. * Object will not rotate to face the camera
  65818. */
  65819. static BILLBOARDMODE_NONE: number;
  65820. /**
  65821. * Object will rotate to face the camera but only on the x axis
  65822. */
  65823. static BILLBOARDMODE_X: number;
  65824. /**
  65825. * Object will rotate to face the camera but only on the y axis
  65826. */
  65827. static BILLBOARDMODE_Y: number;
  65828. /**
  65829. * Object will rotate to face the camera but only on the z axis
  65830. */
  65831. static BILLBOARDMODE_Z: number;
  65832. /**
  65833. * Object will rotate to face the camera
  65834. */
  65835. static BILLBOARDMODE_ALL: number;
  65836. private _forward;
  65837. private _forwardInverted;
  65838. private _up;
  65839. private _right;
  65840. private _rightInverted;
  65841. private _position;
  65842. private _rotation;
  65843. private _rotationQuaternion;
  65844. protected _scaling: Vector3;
  65845. protected _isDirty: boolean;
  65846. private _transformToBoneReferal;
  65847. /**
  65848. * Set the billboard mode. Default is 0.
  65849. *
  65850. * | Value | Type | Description |
  65851. * | --- | --- | --- |
  65852. * | 0 | BILLBOARDMODE_NONE | |
  65853. * | 1 | BILLBOARDMODE_X | |
  65854. * | 2 | BILLBOARDMODE_Y | |
  65855. * | 4 | BILLBOARDMODE_Z | |
  65856. * | 7 | BILLBOARDMODE_ALL | |
  65857. *
  65858. */
  65859. billboardMode: number;
  65860. /**
  65861. * 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
  65862. */
  65863. scalingDeterminant: number;
  65864. /**
  65865. * Sets the distance of the object to max, often used by skybox
  65866. */
  65867. infiniteDistance: boolean;
  65868. /**
  65869. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65870. * By default the system will update normals to compensate
  65871. */
  65872. ignoreNonUniformScaling: boolean;
  65873. /** @hidden */
  65874. _poseMatrix: Matrix;
  65875. /** @hidden */
  65876. _localMatrix: Matrix;
  65877. private _absolutePosition;
  65878. private _pivotMatrix;
  65879. private _pivotMatrixInverse;
  65880. protected _postMultiplyPivotMatrix: boolean;
  65881. protected _isWorldMatrixFrozen: boolean;
  65882. /** @hidden */
  65883. _indexInSceneTransformNodesArray: number;
  65884. /**
  65885. * An event triggered after the world matrix is updated
  65886. */
  65887. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65888. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65889. /**
  65890. * Gets a string identifying the name of the class
  65891. * @returns "TransformNode" string
  65892. */
  65893. getClassName(): string;
  65894. /**
  65895. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65896. */
  65897. position: Vector3;
  65898. /**
  65899. * 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)).
  65900. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65901. */
  65902. rotation: Vector3;
  65903. /**
  65904. * 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)).
  65905. */
  65906. scaling: Vector3;
  65907. /**
  65908. * 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).
  65909. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65910. */
  65911. rotationQuaternion: Nullable<Quaternion>;
  65912. /**
  65913. * The forward direction of that transform in world space.
  65914. */
  65915. readonly forward: Vector3;
  65916. /**
  65917. * The up direction of that transform in world space.
  65918. */
  65919. readonly up: Vector3;
  65920. /**
  65921. * The right direction of that transform in world space.
  65922. */
  65923. readonly right: Vector3;
  65924. /**
  65925. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65926. * @param matrix the matrix to copy the pose from
  65927. * @returns this TransformNode.
  65928. */
  65929. updatePoseMatrix(matrix: Matrix): TransformNode;
  65930. /**
  65931. * Returns the mesh Pose matrix.
  65932. * @returns the pose matrix
  65933. */
  65934. getPoseMatrix(): Matrix;
  65935. /** @hidden */
  65936. _isSynchronized(): boolean;
  65937. /** @hidden */
  65938. _initCache(): void;
  65939. /**
  65940. * Flag the transform node as dirty (Forcing it to update everything)
  65941. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65942. * @returns this transform node
  65943. */
  65944. markAsDirty(property: string): TransformNode;
  65945. /**
  65946. * Returns the current mesh absolute position.
  65947. * Returns a Vector3.
  65948. */
  65949. readonly absolutePosition: Vector3;
  65950. /**
  65951. * Sets a new matrix to apply before all other transformation
  65952. * @param matrix defines the transform matrix
  65953. * @returns the current TransformNode
  65954. */
  65955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65956. /**
  65957. * Sets a new pivot matrix to the current node
  65958. * @param matrix defines the new pivot matrix to use
  65959. * @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
  65960. * @returns the current TransformNode
  65961. */
  65962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65963. /**
  65964. * Returns the mesh pivot matrix.
  65965. * Default : Identity.
  65966. * @returns the matrix
  65967. */
  65968. getPivotMatrix(): Matrix;
  65969. /**
  65970. * Prevents the World matrix to be computed any longer.
  65971. * @returns the TransformNode.
  65972. */
  65973. freezeWorldMatrix(): TransformNode;
  65974. /**
  65975. * Allows back the World matrix computation.
  65976. * @returns the TransformNode.
  65977. */
  65978. unfreezeWorldMatrix(): this;
  65979. /**
  65980. * True if the World matrix has been frozen.
  65981. */
  65982. readonly isWorldMatrixFrozen: boolean;
  65983. /**
  65984. * Retuns the mesh absolute position in the World.
  65985. * @returns a Vector3.
  65986. */
  65987. getAbsolutePosition(): Vector3;
  65988. /**
  65989. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65990. * @param absolutePosition the absolute position to set
  65991. * @returns the TransformNode.
  65992. */
  65993. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65994. /**
  65995. * Sets the mesh position in its local space.
  65996. * @param vector3 the position to set in localspace
  65997. * @returns the TransformNode.
  65998. */
  65999. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66000. /**
  66001. * Returns the mesh position in the local space from the current World matrix values.
  66002. * @returns a new Vector3.
  66003. */
  66004. getPositionExpressedInLocalSpace(): Vector3;
  66005. /**
  66006. * Translates the mesh along the passed Vector3 in its local space.
  66007. * @param vector3 the distance to translate in localspace
  66008. * @returns the TransformNode.
  66009. */
  66010. locallyTranslate(vector3: Vector3): TransformNode;
  66011. private static _lookAtVectorCache;
  66012. /**
  66013. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66014. * @param targetPoint the position (must be in same space as current mesh) to look at
  66015. * @param yawCor optional yaw (y-axis) correction in radians
  66016. * @param pitchCor optional pitch (x-axis) correction in radians
  66017. * @param rollCor optional roll (z-axis) correction in radians
  66018. * @param space the choosen space of the target
  66019. * @returns the TransformNode.
  66020. */
  66021. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66022. /**
  66023. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66024. * This Vector3 is expressed in the World space.
  66025. * @param localAxis axis to rotate
  66026. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66027. */
  66028. getDirection(localAxis: Vector3): Vector3;
  66029. /**
  66030. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66031. * localAxis is expressed in the mesh local space.
  66032. * result is computed in the Wordl space from the mesh World matrix.
  66033. * @param localAxis axis to rotate
  66034. * @param result the resulting transformnode
  66035. * @returns this TransformNode.
  66036. */
  66037. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66038. /**
  66039. * Sets this transform node rotation to the given local axis.
  66040. * @param localAxis the axis in local space
  66041. * @param yawCor optional yaw (y-axis) correction in radians
  66042. * @param pitchCor optional pitch (x-axis) correction in radians
  66043. * @param rollCor optional roll (z-axis) correction in radians
  66044. * @returns this TransformNode
  66045. */
  66046. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66047. /**
  66048. * Sets a new pivot point to the current node
  66049. * @param point defines the new pivot point to use
  66050. * @param space defines if the point is in world or local space (local by default)
  66051. * @returns the current TransformNode
  66052. */
  66053. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66054. /**
  66055. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66056. * @returns the pivot point
  66057. */
  66058. getPivotPoint(): Vector3;
  66059. /**
  66060. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66061. * @param result the vector3 to store the result
  66062. * @returns this TransformNode.
  66063. */
  66064. getPivotPointToRef(result: Vector3): TransformNode;
  66065. /**
  66066. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66067. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66068. */
  66069. getAbsolutePivotPoint(): Vector3;
  66070. /**
  66071. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66072. * @param result vector3 to store the result
  66073. * @returns this TransformNode.
  66074. */
  66075. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66076. /**
  66077. * Defines the passed node as the parent of the current node.
  66078. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66079. * @param node the node ot set as the parent
  66080. * @returns this TransformNode.
  66081. */
  66082. setParent(node: Nullable<Node>): TransformNode;
  66083. private _nonUniformScaling;
  66084. /**
  66085. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66086. */
  66087. readonly nonUniformScaling: boolean;
  66088. /** @hidden */
  66089. _updateNonUniformScalingState(value: boolean): boolean;
  66090. /**
  66091. * Attach the current TransformNode to another TransformNode associated with a bone
  66092. * @param bone Bone affecting the TransformNode
  66093. * @param affectedTransformNode TransformNode associated with the bone
  66094. * @returns this object
  66095. */
  66096. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66097. /**
  66098. * Detach the transform node if its associated with a bone
  66099. * @returns this object
  66100. */
  66101. detachFromBone(): TransformNode;
  66102. private static _rotationAxisCache;
  66103. /**
  66104. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66105. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66106. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66107. * The passed axis is also normalized.
  66108. * @param axis the axis to rotate around
  66109. * @param amount the amount to rotate in radians
  66110. * @param space Space to rotate in (Default: local)
  66111. * @returns the TransformNode.
  66112. */
  66113. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66114. /**
  66115. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66116. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66117. * The passed axis is also normalized. .
  66118. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66119. * @param point the point to rotate around
  66120. * @param axis the axis to rotate around
  66121. * @param amount the amount to rotate in radians
  66122. * @returns the TransformNode
  66123. */
  66124. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66125. /**
  66126. * Translates the mesh along the axis vector for the passed distance in the given space.
  66127. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66128. * @param axis the axis to translate in
  66129. * @param distance the distance to translate
  66130. * @param space Space to rotate in (Default: local)
  66131. * @returns the TransformNode.
  66132. */
  66133. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66134. /**
  66135. * Adds a rotation step to the mesh current rotation.
  66136. * x, y, z are Euler angles expressed in radians.
  66137. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66138. * This means this rotation is made in the mesh local space only.
  66139. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66140. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66141. * ```javascript
  66142. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66143. * ```
  66144. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66145. * 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.
  66146. * @param x Rotation to add
  66147. * @param y Rotation to add
  66148. * @param z Rotation to add
  66149. * @returns the TransformNode.
  66150. */
  66151. addRotation(x: number, y: number, z: number): TransformNode;
  66152. /**
  66153. * Computes the world matrix of the node
  66154. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66155. * @returns the world matrix
  66156. */
  66157. computeWorldMatrix(force?: boolean): Matrix;
  66158. protected _afterComputeWorldMatrix(): void;
  66159. /**
  66160. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66161. * @param func callback function to add
  66162. *
  66163. * @returns the TransformNode.
  66164. */
  66165. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66166. /**
  66167. * Removes a registered callback function.
  66168. * @param func callback function to remove
  66169. * @returns the TransformNode.
  66170. */
  66171. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66172. /**
  66173. * Gets the position of the current mesh in camera space
  66174. * @param camera defines the camera to use
  66175. * @returns a position
  66176. */
  66177. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66178. /**
  66179. * Returns the distance from the mesh to the active camera
  66180. * @param camera defines the camera to use
  66181. * @returns the distance
  66182. */
  66183. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66184. /**
  66185. * Clone the current transform node
  66186. * @param name Name of the new clone
  66187. * @param newParent New parent for the clone
  66188. * @param doNotCloneChildren Do not clone children hierarchy
  66189. * @returns the new transform node
  66190. */
  66191. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66192. /**
  66193. * Serializes the objects information.
  66194. * @param currentSerializationObject defines the object to serialize in
  66195. * @returns the serialized object
  66196. */
  66197. serialize(currentSerializationObject?: any): any;
  66198. /**
  66199. * Returns a new TransformNode object parsed from the source provided.
  66200. * @param parsedTransformNode is the source.
  66201. * @param scene the scne the object belongs to
  66202. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66203. * @returns a new TransformNode object parsed from the source provided.
  66204. */
  66205. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66206. /**
  66207. * Get all child-transformNodes of this node
  66208. * @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
  66209. * @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
  66210. * @returns an array of TransformNode
  66211. */
  66212. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66213. /**
  66214. * Releases resources associated with this transform node.
  66215. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66216. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66217. */
  66218. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66219. }
  66220. }
  66221. declare module BABYLON {
  66222. /**
  66223. * Defines the types of pose enabled controllers that are supported
  66224. */
  66225. export enum PoseEnabledControllerType {
  66226. /**
  66227. * HTC Vive
  66228. */
  66229. VIVE = 0,
  66230. /**
  66231. * Oculus Rift
  66232. */
  66233. OCULUS = 1,
  66234. /**
  66235. * Windows mixed reality
  66236. */
  66237. WINDOWS = 2,
  66238. /**
  66239. * Samsung gear VR
  66240. */
  66241. GEAR_VR = 3,
  66242. /**
  66243. * Google Daydream
  66244. */
  66245. DAYDREAM = 4,
  66246. /**
  66247. * Generic
  66248. */
  66249. GENERIC = 5
  66250. }
  66251. /**
  66252. * Defines the MutableGamepadButton interface for the state of a gamepad button
  66253. */
  66254. export interface MutableGamepadButton {
  66255. /**
  66256. * Value of the button/trigger
  66257. */
  66258. value: number;
  66259. /**
  66260. * If the button/trigger is currently touched
  66261. */
  66262. touched: boolean;
  66263. /**
  66264. * If the button/trigger is currently pressed
  66265. */
  66266. pressed: boolean;
  66267. }
  66268. /**
  66269. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  66270. * @hidden
  66271. */
  66272. export interface ExtendedGamepadButton extends GamepadButton {
  66273. /**
  66274. * If the button/trigger is currently pressed
  66275. */
  66276. readonly pressed: boolean;
  66277. /**
  66278. * If the button/trigger is currently touched
  66279. */
  66280. readonly touched: boolean;
  66281. /**
  66282. * Value of the button/trigger
  66283. */
  66284. readonly value: number;
  66285. }
  66286. /** @hidden */
  66287. export interface _GamePadFactory {
  66288. /**
  66289. * Returns wether or not the current gamepad can be created for this type of controller.
  66290. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  66291. * @returns true if it can be created, otherwise false
  66292. */
  66293. canCreate(gamepadInfo: any): boolean;
  66294. /**
  66295. * Creates a new instance of the Gamepad.
  66296. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  66297. * @returns the new gamepad instance
  66298. */
  66299. create(gamepadInfo: any): Gamepad;
  66300. }
  66301. /**
  66302. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  66303. */
  66304. export class PoseEnabledControllerHelper {
  66305. /** @hidden */
  66306. static _ControllerFactories: _GamePadFactory[];
  66307. /** @hidden */
  66308. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  66309. /**
  66310. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  66311. * @param vrGamepad the gamepad to initialized
  66312. * @returns a vr controller of the type the gamepad identified as
  66313. */
  66314. static InitiateController(vrGamepad: any): Gamepad;
  66315. }
  66316. /**
  66317. * Defines the PoseEnabledController object that contains state of a vr capable controller
  66318. */
  66319. export class PoseEnabledController extends Gamepad implements PoseControlled {
  66320. private _deviceRoomPosition;
  66321. private _deviceRoomRotationQuaternion;
  66322. /**
  66323. * The device position in babylon space
  66324. */
  66325. devicePosition: Vector3;
  66326. /**
  66327. * The device rotation in babylon space
  66328. */
  66329. deviceRotationQuaternion: Quaternion;
  66330. /**
  66331. * The scale factor of the device in babylon space
  66332. */
  66333. deviceScaleFactor: number;
  66334. /**
  66335. * (Likely devicePosition should be used instead) The device position in its room space
  66336. */
  66337. position: Vector3;
  66338. /**
  66339. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  66340. */
  66341. rotationQuaternion: Quaternion;
  66342. /**
  66343. * The type of controller (Eg. Windows mixed reality)
  66344. */
  66345. controllerType: PoseEnabledControllerType;
  66346. protected _calculatedPosition: Vector3;
  66347. private _calculatedRotation;
  66348. /**
  66349. * The raw pose from the device
  66350. */
  66351. rawPose: DevicePose;
  66352. private _trackPosition;
  66353. private _maxRotationDistFromHeadset;
  66354. private _draggedRoomRotation;
  66355. /**
  66356. * @hidden
  66357. */
  66358. _disableTrackPosition(fixedPosition: Vector3): void;
  66359. /**
  66360. * Internal, the mesh attached to the controller
  66361. * @hidden
  66362. */
  66363. _mesh: Nullable<AbstractMesh>;
  66364. private _poseControlledCamera;
  66365. private _leftHandSystemQuaternion;
  66366. /**
  66367. * Internal, matrix used to convert room space to babylon space
  66368. * @hidden
  66369. */
  66370. _deviceToWorld: Matrix;
  66371. /**
  66372. * Node to be used when casting a ray from the controller
  66373. * @hidden
  66374. */
  66375. _pointingPoseNode: Nullable<TransformNode>;
  66376. /**
  66377. * Name of the child mesh that can be used to cast a ray from the controller
  66378. */
  66379. static readonly POINTING_POSE: string;
  66380. /**
  66381. * Creates a new PoseEnabledController from a gamepad
  66382. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  66383. */
  66384. constructor(browserGamepad: any);
  66385. private _workingMatrix;
  66386. /**
  66387. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  66388. */
  66389. update(): void;
  66390. /**
  66391. * Updates only the pose device and mesh without doing any button event checking
  66392. */
  66393. protected _updatePoseAndMesh(): void;
  66394. /**
  66395. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  66396. * @param poseData raw pose fromthe device
  66397. */
  66398. updateFromDevice(poseData: DevicePose): void;
  66399. /**
  66400. * @hidden
  66401. */
  66402. _meshAttachedObservable: Observable<AbstractMesh>;
  66403. /**
  66404. * Attaches a mesh to the controller
  66405. * @param mesh the mesh to be attached
  66406. */
  66407. attachToMesh(mesh: AbstractMesh): void;
  66408. /**
  66409. * Attaches the controllers mesh to a camera
  66410. * @param camera the camera the mesh should be attached to
  66411. */
  66412. attachToPoseControlledCamera(camera: TargetCamera): void;
  66413. /**
  66414. * Disposes of the controller
  66415. */
  66416. dispose(): void;
  66417. /**
  66418. * The mesh that is attached to the controller
  66419. */
  66420. readonly mesh: Nullable<AbstractMesh>;
  66421. /**
  66422. * Gets the ray of the controller in the direction the controller is pointing
  66423. * @param length the length the resulting ray should be
  66424. * @returns a ray in the direction the controller is pointing
  66425. */
  66426. getForwardRay(length?: number): Ray;
  66427. }
  66428. }
  66429. declare module BABYLON {
  66430. /**
  66431. * Defines the WebVRController object that represents controllers tracked in 3D space
  66432. */
  66433. export abstract class WebVRController extends PoseEnabledController {
  66434. /**
  66435. * Internal, the default controller model for the controller
  66436. */
  66437. protected _defaultModel: AbstractMesh;
  66438. /**
  66439. * Fired when the trigger state has changed
  66440. */
  66441. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  66442. /**
  66443. * Fired when the main button state has changed
  66444. */
  66445. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  66446. /**
  66447. * Fired when the secondary button state has changed
  66448. */
  66449. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  66450. /**
  66451. * Fired when the pad state has changed
  66452. */
  66453. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  66454. /**
  66455. * Fired when controllers stick values have changed
  66456. */
  66457. onPadValuesChangedObservable: Observable<StickValues>;
  66458. /**
  66459. * Array of button availible on the controller
  66460. */
  66461. protected _buttons: Array<MutableGamepadButton>;
  66462. private _onButtonStateChange;
  66463. /**
  66464. * Fired when a controller button's state has changed
  66465. * @param callback the callback containing the button that was modified
  66466. */
  66467. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  66468. /**
  66469. * X and Y axis corrisponding to the controllers joystick
  66470. */
  66471. pad: StickValues;
  66472. /**
  66473. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  66474. */
  66475. hand: string;
  66476. /**
  66477. * The default controller model for the controller
  66478. */
  66479. readonly defaultModel: AbstractMesh;
  66480. /**
  66481. * Creates a new WebVRController from a gamepad
  66482. * @param vrGamepad the gamepad that the WebVRController should be created from
  66483. */
  66484. constructor(vrGamepad: any);
  66485. /**
  66486. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  66487. */
  66488. update(): void;
  66489. /**
  66490. * Function to be called when a button is modified
  66491. */
  66492. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  66493. /**
  66494. * Loads a mesh and attaches it to the controller
  66495. * @param scene the scene the mesh should be added to
  66496. * @param meshLoaded callback for when the mesh has been loaded
  66497. */
  66498. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  66499. private _setButtonValue;
  66500. private _changes;
  66501. private _checkChanges;
  66502. /**
  66503. * Disposes of th webVRCOntroller
  66504. */
  66505. dispose(): void;
  66506. }
  66507. }
  66508. declare module BABYLON {
  66509. /**
  66510. * Interface describing all the common properties and methods a shadow light needs to implement.
  66511. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66512. * as well as binding the different shadow properties to the effects.
  66513. */
  66514. export interface IShadowLight extends Light {
  66515. /**
  66516. * The light id in the scene (used in scene.findLighById for instance)
  66517. */
  66518. id: string;
  66519. /**
  66520. * The position the shdow will be casted from.
  66521. */
  66522. position: Vector3;
  66523. /**
  66524. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66525. */
  66526. direction: Vector3;
  66527. /**
  66528. * The transformed position. Position of the light in world space taking parenting in account.
  66529. */
  66530. transformedPosition: Vector3;
  66531. /**
  66532. * The transformed direction. Direction of the light in world space taking parenting in account.
  66533. */
  66534. transformedDirection: Vector3;
  66535. /**
  66536. * The friendly name of the light in the scene.
  66537. */
  66538. name: string;
  66539. /**
  66540. * Defines the shadow projection clipping minimum z value.
  66541. */
  66542. shadowMinZ: number;
  66543. /**
  66544. * Defines the shadow projection clipping maximum z value.
  66545. */
  66546. shadowMaxZ: number;
  66547. /**
  66548. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66549. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66550. */
  66551. computeTransformedInformation(): boolean;
  66552. /**
  66553. * Gets the scene the light belongs to.
  66554. * @returns The scene
  66555. */
  66556. getScene(): Scene;
  66557. /**
  66558. * Callback defining a custom Projection Matrix Builder.
  66559. * This can be used to override the default projection matrix computation.
  66560. */
  66561. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66562. /**
  66563. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66564. * @param matrix The materix to updated with the projection information
  66565. * @param viewMatrix The transform matrix of the light
  66566. * @param renderList The list of mesh to render in the map
  66567. * @returns The current light
  66568. */
  66569. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66570. /**
  66571. * Gets the current depth scale used in ESM.
  66572. * @returns The scale
  66573. */
  66574. getDepthScale(): number;
  66575. /**
  66576. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66577. * @returns true if a cube texture needs to be use
  66578. */
  66579. needCube(): boolean;
  66580. /**
  66581. * Detects if the projection matrix requires to be recomputed this frame.
  66582. * @returns true if it requires to be recomputed otherwise, false.
  66583. */
  66584. needProjectionMatrixCompute(): boolean;
  66585. /**
  66586. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66587. */
  66588. forceProjectionMatrixCompute(): void;
  66589. /**
  66590. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66591. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66592. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66593. */
  66594. getShadowDirection(faceIndex?: number): Vector3;
  66595. /**
  66596. * Gets the minZ used for shadow according to both the scene and the light.
  66597. * @param activeCamera The camera we are returning the min for
  66598. * @returns the depth min z
  66599. */
  66600. getDepthMinZ(activeCamera: Camera): number;
  66601. /**
  66602. * Gets the maxZ used for shadow according to both the scene and the light.
  66603. * @param activeCamera The camera we are returning the max for
  66604. * @returns the depth max z
  66605. */
  66606. getDepthMaxZ(activeCamera: Camera): number;
  66607. }
  66608. /**
  66609. * Base implementation IShadowLight
  66610. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66611. */
  66612. export abstract class ShadowLight extends Light implements IShadowLight {
  66613. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66614. protected _position: Vector3;
  66615. protected _setPosition(value: Vector3): void;
  66616. /**
  66617. * Sets the position the shadow will be casted from. Also use as the light position for both
  66618. * point and spot lights.
  66619. */
  66620. /**
  66621. * Sets the position the shadow will be casted from. Also use as the light position for both
  66622. * point and spot lights.
  66623. */
  66624. position: Vector3;
  66625. protected _direction: Vector3;
  66626. protected _setDirection(value: Vector3): void;
  66627. /**
  66628. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66629. * Also use as the light direction on spot and directional lights.
  66630. */
  66631. /**
  66632. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66633. * Also use as the light direction on spot and directional lights.
  66634. */
  66635. direction: Vector3;
  66636. private _shadowMinZ;
  66637. /**
  66638. * Gets the shadow projection clipping minimum z value.
  66639. */
  66640. /**
  66641. * Sets the shadow projection clipping minimum z value.
  66642. */
  66643. shadowMinZ: number;
  66644. private _shadowMaxZ;
  66645. /**
  66646. * Sets the shadow projection clipping maximum z value.
  66647. */
  66648. /**
  66649. * Gets the shadow projection clipping maximum z value.
  66650. */
  66651. shadowMaxZ: number;
  66652. /**
  66653. * Callback defining a custom Projection Matrix Builder.
  66654. * This can be used to override the default projection matrix computation.
  66655. */
  66656. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66657. /**
  66658. * The transformed position. Position of the light in world space taking parenting in account.
  66659. */
  66660. transformedPosition: Vector3;
  66661. /**
  66662. * The transformed direction. Direction of the light in world space taking parenting in account.
  66663. */
  66664. transformedDirection: Vector3;
  66665. private _needProjectionMatrixCompute;
  66666. /**
  66667. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66668. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66669. */
  66670. computeTransformedInformation(): boolean;
  66671. /**
  66672. * Return the depth scale used for the shadow map.
  66673. * @returns the depth scale.
  66674. */
  66675. getDepthScale(): number;
  66676. /**
  66677. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66678. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66679. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66680. */
  66681. getShadowDirection(faceIndex?: number): Vector3;
  66682. /**
  66683. * Returns the ShadowLight absolute position in the World.
  66684. * @returns the position vector in world space
  66685. */
  66686. getAbsolutePosition(): Vector3;
  66687. /**
  66688. * Sets the ShadowLight direction toward the passed target.
  66689. * @param target The point tot target in local space
  66690. * @returns the updated ShadowLight direction
  66691. */
  66692. setDirectionToTarget(target: Vector3): Vector3;
  66693. /**
  66694. * Returns the light rotation in euler definition.
  66695. * @returns the x y z rotation in local space.
  66696. */
  66697. getRotation(): Vector3;
  66698. /**
  66699. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66700. * @returns true if a cube texture needs to be use
  66701. */
  66702. needCube(): boolean;
  66703. /**
  66704. * Detects if the projection matrix requires to be recomputed this frame.
  66705. * @returns true if it requires to be recomputed otherwise, false.
  66706. */
  66707. needProjectionMatrixCompute(): boolean;
  66708. /**
  66709. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66710. */
  66711. forceProjectionMatrixCompute(): void;
  66712. /** @hidden */
  66713. _initCache(): void;
  66714. /** @hidden */
  66715. _isSynchronized(): boolean;
  66716. /**
  66717. * Computes the world matrix of the node
  66718. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66719. * @returns the world matrix
  66720. */
  66721. computeWorldMatrix(force?: boolean): Matrix;
  66722. /**
  66723. * Gets the minZ used for shadow according to both the scene and the light.
  66724. * @param activeCamera The camera we are returning the min for
  66725. * @returns the depth min z
  66726. */
  66727. getDepthMinZ(activeCamera: Camera): number;
  66728. /**
  66729. * Gets the maxZ used for shadow according to both the scene and the light.
  66730. * @param activeCamera The camera we are returning the max for
  66731. * @returns the depth max z
  66732. */
  66733. getDepthMaxZ(activeCamera: Camera): number;
  66734. /**
  66735. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66736. * @param matrix The materix to updated with the projection information
  66737. * @param viewMatrix The transform matrix of the light
  66738. * @param renderList The list of mesh to render in the map
  66739. * @returns The current light
  66740. */
  66741. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66742. }
  66743. }
  66744. declare module BABYLON {
  66745. /**
  66746. * "Static Class" containing the most commonly used helper while dealing with material for
  66747. * rendering purpose.
  66748. *
  66749. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66750. *
  66751. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66752. */
  66753. export class MaterialHelper {
  66754. /**
  66755. * Bind the current view position to an effect.
  66756. * @param effect The effect to be bound
  66757. * @param scene The scene the eyes position is used from
  66758. */
  66759. static BindEyePosition(effect: Effect, scene: Scene): void;
  66760. /**
  66761. * Helps preparing the defines values about the UVs in used in the effect.
  66762. * UVs are shared as much as we can accross channels in the shaders.
  66763. * @param texture The texture we are preparing the UVs for
  66764. * @param defines The defines to update
  66765. * @param key The channel key "diffuse", "specular"... used in the shader
  66766. */
  66767. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66768. /**
  66769. * Binds a texture matrix value to its corrsponding uniform
  66770. * @param texture The texture to bind the matrix for
  66771. * @param uniformBuffer The uniform buffer receivin the data
  66772. * @param key The channel key "diffuse", "specular"... used in the shader
  66773. */
  66774. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66775. /**
  66776. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66777. * @param mesh defines the current mesh
  66778. * @param scene defines the current scene
  66779. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66780. * @param pointsCloud defines if point cloud rendering has to be turned on
  66781. * @param fogEnabled defines if fog has to be turned on
  66782. * @param alphaTest defines if alpha testing has to be turned on
  66783. * @param defines defines the current list of defines
  66784. */
  66785. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66786. /**
  66787. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66788. * @param scene defines the current scene
  66789. * @param engine defines the current engine
  66790. * @param defines specifies the list of active defines
  66791. * @param useInstances defines if instances have to be turned on
  66792. * @param useClipPlane defines if clip plane have to be turned on
  66793. */
  66794. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66795. /**
  66796. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66797. * @param mesh The mesh containing the geometry data we will draw
  66798. * @param defines The defines to update
  66799. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66800. * @param useBones Precise whether bones should be used or not (override mesh info)
  66801. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66802. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66803. * @returns false if defines are considered not dirty and have not been checked
  66804. */
  66805. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66806. /**
  66807. * Prepares the defines related to the light information passed in parameter
  66808. * @param scene The scene we are intending to draw
  66809. * @param mesh The mesh the effect is compiling for
  66810. * @param defines The defines to update
  66811. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66812. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66813. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66814. * @returns true if normals will be required for the rest of the effect
  66815. */
  66816. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66817. /**
  66818. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66819. * that won t be acctive due to defines being turned off.
  66820. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66821. * @param samplersList The samplers list
  66822. * @param defines The defines helping in the list generation
  66823. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66824. */
  66825. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66826. /**
  66827. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66828. * @param defines The defines to update while falling back
  66829. * @param fallbacks The authorized effect fallbacks
  66830. * @param maxSimultaneousLights The maximum number of lights allowed
  66831. * @param rank the current rank of the Effect
  66832. * @returns The newly affected rank
  66833. */
  66834. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66835. /**
  66836. * Prepares the list of attributes required for morph targets according to the effect defines.
  66837. * @param attribs The current list of supported attribs
  66838. * @param mesh The mesh to prepare the morph targets attributes for
  66839. * @param defines The current Defines of the effect
  66840. */
  66841. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66842. /**
  66843. * Prepares the list of attributes required for bones according to the effect defines.
  66844. * @param attribs The current list of supported attribs
  66845. * @param mesh The mesh to prepare the bones attributes for
  66846. * @param defines The current Defines of the effect
  66847. * @param fallbacks The current efffect fallback strategy
  66848. */
  66849. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66850. /**
  66851. * Prepares the list of attributes required for instances according to the effect defines.
  66852. * @param attribs The current list of supported attribs
  66853. * @param defines The current Defines of the effect
  66854. */
  66855. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66856. /**
  66857. * Binds the light shadow information to the effect for the given mesh.
  66858. * @param light The light containing the generator
  66859. * @param scene The scene the lights belongs to
  66860. * @param mesh The mesh we are binding the information to render
  66861. * @param lightIndex The light index in the effect used to render the mesh
  66862. * @param effect The effect we are binding the data to
  66863. */
  66864. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66865. /**
  66866. * Binds the light information to the effect.
  66867. * @param light The light containing the generator
  66868. * @param effect The effect we are binding the data to
  66869. * @param lightIndex The light index in the effect used to render
  66870. */
  66871. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66872. /**
  66873. * Binds the lights information from the scene to the effect for the given mesh.
  66874. * @param scene The scene the lights belongs to
  66875. * @param mesh The mesh we are binding the information to render
  66876. * @param effect The effect we are binding the data to
  66877. * @param defines The generated defines for the effect
  66878. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66879. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66880. */
  66881. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66882. private static _tempFogColor;
  66883. /**
  66884. * Binds the fog information from the scene to the effect for the given mesh.
  66885. * @param scene The scene the lights belongs to
  66886. * @param mesh The mesh we are binding the information to render
  66887. * @param effect The effect we are binding the data to
  66888. * @param linearSpace Defines if the fog effect is applied in linear space
  66889. */
  66890. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66891. /**
  66892. * Binds the bones information from the mesh to the effect.
  66893. * @param mesh The mesh we are binding the information to render
  66894. * @param effect The effect we are binding the data to
  66895. */
  66896. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66897. /**
  66898. * Binds the morph targets information from the mesh to the effect.
  66899. * @param abstractMesh The mesh we are binding the information to render
  66900. * @param effect The effect we are binding the data to
  66901. */
  66902. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66903. /**
  66904. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66905. * @param defines The generated defines used in the effect
  66906. * @param effect The effect we are binding the data to
  66907. * @param scene The scene we are willing to render with logarithmic scale for
  66908. */
  66909. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66910. /**
  66911. * Binds the clip plane information from the scene to the effect.
  66912. * @param scene The scene the clip plane information are extracted from
  66913. * @param effect The effect we are binding the data to
  66914. */
  66915. static BindClipPlane(effect: Effect, scene: Scene): void;
  66916. }
  66917. }
  66918. declare module BABYLON {
  66919. /** @hidden */
  66920. export var shadowMapPixelShader: {
  66921. name: string;
  66922. shader: string;
  66923. };
  66924. }
  66925. declare module BABYLON {
  66926. /** @hidden */
  66927. export var bonesDeclaration: {
  66928. name: string;
  66929. shader: string;
  66930. };
  66931. }
  66932. declare module BABYLON {
  66933. /** @hidden */
  66934. export var morphTargetsVertexGlobalDeclaration: {
  66935. name: string;
  66936. shader: string;
  66937. };
  66938. }
  66939. declare module BABYLON {
  66940. /** @hidden */
  66941. export var morphTargetsVertexDeclaration: {
  66942. name: string;
  66943. shader: string;
  66944. };
  66945. }
  66946. declare module BABYLON {
  66947. /** @hidden */
  66948. export var instancesDeclaration: {
  66949. name: string;
  66950. shader: string;
  66951. };
  66952. }
  66953. declare module BABYLON {
  66954. /** @hidden */
  66955. export var helperFunctions: {
  66956. name: string;
  66957. shader: string;
  66958. };
  66959. }
  66960. declare module BABYLON {
  66961. /** @hidden */
  66962. export var morphTargetsVertex: {
  66963. name: string;
  66964. shader: string;
  66965. };
  66966. }
  66967. declare module BABYLON {
  66968. /** @hidden */
  66969. export var instancesVertex: {
  66970. name: string;
  66971. shader: string;
  66972. };
  66973. }
  66974. declare module BABYLON {
  66975. /** @hidden */
  66976. export var bonesVertex: {
  66977. name: string;
  66978. shader: string;
  66979. };
  66980. }
  66981. declare module BABYLON {
  66982. /** @hidden */
  66983. export var shadowMapVertexShader: {
  66984. name: string;
  66985. shader: string;
  66986. };
  66987. }
  66988. declare module BABYLON {
  66989. /** @hidden */
  66990. export var depthBoxBlurPixelShader: {
  66991. name: string;
  66992. shader: string;
  66993. };
  66994. }
  66995. declare module BABYLON {
  66996. /**
  66997. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66998. */
  66999. export interface ICustomShaderOptions {
  67000. /**
  67001. * Gets or sets the custom shader name to use
  67002. */
  67003. shaderName: string;
  67004. /**
  67005. * The list of attribute names used in the shader
  67006. */
  67007. attributes?: string[];
  67008. /**
  67009. * The list of unifrom names used in the shader
  67010. */
  67011. uniforms?: string[];
  67012. /**
  67013. * The list of sampler names used in the shader
  67014. */
  67015. samplers?: string[];
  67016. /**
  67017. * The list of defines used in the shader
  67018. */
  67019. defines?: string[];
  67020. }
  67021. /**
  67022. * Interface to implement to create a shadow generator compatible with BJS.
  67023. */
  67024. export interface IShadowGenerator {
  67025. /**
  67026. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67027. * @returns The render target texture if present otherwise, null
  67028. */
  67029. getShadowMap(): Nullable<RenderTargetTexture>;
  67030. /**
  67031. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67032. * @returns The render target texture if the shadow map is present otherwise, null
  67033. */
  67034. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67035. /**
  67036. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67037. * @param subMesh The submesh we want to render in the shadow map
  67038. * @param useInstances Defines wether will draw in the map using instances
  67039. * @returns true if ready otherwise, false
  67040. */
  67041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67042. /**
  67043. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67044. * @param defines Defines of the material we want to update
  67045. * @param lightIndex Index of the light in the enabled light list of the material
  67046. */
  67047. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67048. /**
  67049. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67050. * defined in the generator but impacting the effect).
  67051. * It implies the unifroms available on the materials are the standard BJS ones.
  67052. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67053. * @param effect The effect we are binfing the information for
  67054. */
  67055. bindShadowLight(lightIndex: string, effect: Effect): void;
  67056. /**
  67057. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67058. * (eq to shadow prjection matrix * light transform matrix)
  67059. * @returns The transform matrix used to create the shadow map
  67060. */
  67061. getTransformMatrix(): Matrix;
  67062. /**
  67063. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67064. * Cube and 2D textures for instance.
  67065. */
  67066. recreateShadowMap(): void;
  67067. /**
  67068. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67069. * @param onCompiled Callback triggered at the and of the effects compilation
  67070. * @param options Sets of optional options forcing the compilation with different modes
  67071. */
  67072. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67073. useInstances: boolean;
  67074. }>): void;
  67075. /**
  67076. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67077. * @param options Sets of optional options forcing the compilation with different modes
  67078. * @returns A promise that resolves when the compilation completes
  67079. */
  67080. forceCompilationAsync(options?: Partial<{
  67081. useInstances: boolean;
  67082. }>): Promise<void>;
  67083. /**
  67084. * Serializes the shadow generator setup to a json object.
  67085. * @returns The serialized JSON object
  67086. */
  67087. serialize(): any;
  67088. /**
  67089. * Disposes the Shadow map and related Textures and effects.
  67090. */
  67091. dispose(): void;
  67092. }
  67093. /**
  67094. * Default implementation IShadowGenerator.
  67095. * This is the main object responsible of generating shadows in the framework.
  67096. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67097. */
  67098. export class ShadowGenerator implements IShadowGenerator {
  67099. /**
  67100. * Shadow generator mode None: no filtering applied.
  67101. */
  67102. static readonly FILTER_NONE: number;
  67103. /**
  67104. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67105. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67106. */
  67107. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67108. /**
  67109. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67110. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67111. */
  67112. static readonly FILTER_POISSONSAMPLING: number;
  67113. /**
  67114. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67115. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67116. */
  67117. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67118. /**
  67119. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67120. * edge artifacts on steep falloff.
  67121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67122. */
  67123. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67124. /**
  67125. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67126. * edge artifacts on steep falloff.
  67127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67128. */
  67129. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67130. /**
  67131. * Shadow generator mode PCF: Percentage Closer Filtering
  67132. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67133. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67134. */
  67135. static readonly FILTER_PCF: number;
  67136. /**
  67137. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67138. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67139. * Contact Hardening
  67140. */
  67141. static readonly FILTER_PCSS: number;
  67142. /**
  67143. * Reserved for PCF and PCSS
  67144. * Highest Quality.
  67145. *
  67146. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67147. *
  67148. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67149. */
  67150. static readonly QUALITY_HIGH: number;
  67151. /**
  67152. * Reserved for PCF and PCSS
  67153. * Good tradeoff for quality/perf cross devices
  67154. *
  67155. * Execute PCF on a 3*3 kernel.
  67156. *
  67157. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67158. */
  67159. static readonly QUALITY_MEDIUM: number;
  67160. /**
  67161. * Reserved for PCF and PCSS
  67162. * The lowest quality but the fastest.
  67163. *
  67164. * Execute PCF on a 1*1 kernel.
  67165. *
  67166. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67167. */
  67168. static readonly QUALITY_LOW: number;
  67169. /** Gets or sets the custom shader name to use */
  67170. customShaderOptions: ICustomShaderOptions;
  67171. /**
  67172. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67173. */
  67174. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67175. private _bias;
  67176. /**
  67177. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67178. */
  67179. /**
  67180. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67181. */
  67182. bias: number;
  67183. private _normalBias;
  67184. /**
  67185. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67186. */
  67187. /**
  67188. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67189. */
  67190. normalBias: number;
  67191. private _blurBoxOffset;
  67192. /**
  67193. * Gets the blur box offset: offset applied during the blur pass.
  67194. * Only useful if useKernelBlur = false
  67195. */
  67196. /**
  67197. * Sets the blur box offset: offset applied during the blur pass.
  67198. * Only useful if useKernelBlur = false
  67199. */
  67200. blurBoxOffset: number;
  67201. private _blurScale;
  67202. /**
  67203. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67204. * 2 means half of the size.
  67205. */
  67206. /**
  67207. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67208. * 2 means half of the size.
  67209. */
  67210. blurScale: number;
  67211. private _blurKernel;
  67212. /**
  67213. * Gets the blur kernel: kernel size of the blur pass.
  67214. * Only useful if useKernelBlur = true
  67215. */
  67216. /**
  67217. * Sets the blur kernel: kernel size of the blur pass.
  67218. * Only useful if useKernelBlur = true
  67219. */
  67220. blurKernel: number;
  67221. private _useKernelBlur;
  67222. /**
  67223. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67224. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67225. */
  67226. /**
  67227. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67228. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67229. */
  67230. useKernelBlur: boolean;
  67231. private _depthScale;
  67232. /**
  67233. * Gets the depth scale used in ESM mode.
  67234. */
  67235. /**
  67236. * Sets the depth scale used in ESM mode.
  67237. * This can override the scale stored on the light.
  67238. */
  67239. depthScale: number;
  67240. private _filter;
  67241. /**
  67242. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67243. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67244. */
  67245. /**
  67246. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67247. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67248. */
  67249. filter: number;
  67250. /**
  67251. * Gets if the current filter is set to Poisson Sampling.
  67252. */
  67253. /**
  67254. * Sets the current filter to Poisson Sampling.
  67255. */
  67256. usePoissonSampling: boolean;
  67257. /**
  67258. * Gets if the current filter is set to ESM.
  67259. */
  67260. /**
  67261. * Sets the current filter is to ESM.
  67262. */
  67263. useExponentialShadowMap: boolean;
  67264. /**
  67265. * Gets if the current filter is set to filtered ESM.
  67266. */
  67267. /**
  67268. * Gets if the current filter is set to filtered ESM.
  67269. */
  67270. useBlurExponentialShadowMap: boolean;
  67271. /**
  67272. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67273. * exponential to prevent steep falloff artifacts).
  67274. */
  67275. /**
  67276. * Sets the current filter to "close ESM" (using the inverse of the
  67277. * exponential to prevent steep falloff artifacts).
  67278. */
  67279. useCloseExponentialShadowMap: boolean;
  67280. /**
  67281. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67282. * exponential to prevent steep falloff artifacts).
  67283. */
  67284. /**
  67285. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67286. * exponential to prevent steep falloff artifacts).
  67287. */
  67288. useBlurCloseExponentialShadowMap: boolean;
  67289. /**
  67290. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67291. */
  67292. /**
  67293. * Sets the current filter to "PCF" (percentage closer filtering).
  67294. */
  67295. usePercentageCloserFiltering: boolean;
  67296. private _filteringQuality;
  67297. /**
  67298. * Gets the PCF or PCSS Quality.
  67299. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67300. */
  67301. /**
  67302. * Sets the PCF or PCSS Quality.
  67303. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67304. */
  67305. filteringQuality: number;
  67306. /**
  67307. * Gets if the current filter is set to "PCSS" (contact hardening).
  67308. */
  67309. /**
  67310. * Sets the current filter to "PCSS" (contact hardening).
  67311. */
  67312. useContactHardeningShadow: boolean;
  67313. private _contactHardeningLightSizeUVRatio;
  67314. /**
  67315. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67316. * Using a ratio helps keeping shape stability independently of the map size.
  67317. *
  67318. * It does not account for the light projection as it was having too much
  67319. * instability during the light setup or during light position changes.
  67320. *
  67321. * Only valid if useContactHardeningShadow is true.
  67322. */
  67323. /**
  67324. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67325. * Using a ratio helps keeping shape stability independently of the map size.
  67326. *
  67327. * It does not account for the light projection as it was having too much
  67328. * instability during the light setup or during light position changes.
  67329. *
  67330. * Only valid if useContactHardeningShadow is true.
  67331. */
  67332. contactHardeningLightSizeUVRatio: number;
  67333. private _darkness;
  67334. /**
  67335. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67336. * 0 means strongest and 1 would means no shadow.
  67337. * @returns the darkness.
  67338. */
  67339. getDarkness(): number;
  67340. /**
  67341. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67342. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67343. * @returns the shadow generator allowing fluent coding.
  67344. */
  67345. setDarkness(darkness: number): ShadowGenerator;
  67346. private _transparencyShadow;
  67347. /**
  67348. * Sets the ability to have transparent shadow (boolean).
  67349. * @param transparent True if transparent else False
  67350. * @returns the shadow generator allowing fluent coding
  67351. */
  67352. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67353. private _shadowMap;
  67354. private _shadowMap2;
  67355. /**
  67356. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67357. * @returns The render target texture if present otherwise, null
  67358. */
  67359. getShadowMap(): Nullable<RenderTargetTexture>;
  67360. /**
  67361. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67362. * @returns The render target texture if the shadow map is present otherwise, null
  67363. */
  67364. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67365. /**
  67366. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67367. * @param mesh Mesh to add
  67368. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67369. * @returns the Shadow Generator itself
  67370. */
  67371. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67372. /**
  67373. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67374. * @param mesh Mesh to remove
  67375. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67376. * @returns the Shadow Generator itself
  67377. */
  67378. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67379. /**
  67380. * Controls the extent to which the shadows fade out at the edge of the frustum
  67381. * Used only by directionals and spots
  67382. */
  67383. frustumEdgeFalloff: number;
  67384. private _light;
  67385. /**
  67386. * Returns the associated light object.
  67387. * @returns the light generating the shadow
  67388. */
  67389. getLight(): IShadowLight;
  67390. /**
  67391. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67392. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67393. * It might on the other hand introduce peter panning.
  67394. */
  67395. forceBackFacesOnly: boolean;
  67396. private _scene;
  67397. private _lightDirection;
  67398. private _effect;
  67399. private _viewMatrix;
  67400. private _projectionMatrix;
  67401. private _transformMatrix;
  67402. private _cachedPosition;
  67403. private _cachedDirection;
  67404. private _cachedDefines;
  67405. private _currentRenderID;
  67406. private _boxBlurPostprocess;
  67407. private _kernelBlurXPostprocess;
  67408. private _kernelBlurYPostprocess;
  67409. private _blurPostProcesses;
  67410. private _mapSize;
  67411. private _currentFaceIndex;
  67412. private _currentFaceIndexCache;
  67413. private _textureType;
  67414. private _defaultTextureMatrix;
  67415. /** @hidden */
  67416. static _SceneComponentInitialization: (scene: Scene) => void;
  67417. /**
  67418. * Creates a ShadowGenerator object.
  67419. * A ShadowGenerator is the required tool to use the shadows.
  67420. * Each light casting shadows needs to use its own ShadowGenerator.
  67421. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67422. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67423. * @param light The light object generating the shadows.
  67424. * @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.
  67425. */
  67426. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67427. private _initializeGenerator;
  67428. private _initializeShadowMap;
  67429. private _initializeBlurRTTAndPostProcesses;
  67430. private _renderForShadowMap;
  67431. private _renderSubMeshForShadowMap;
  67432. private _applyFilterValues;
  67433. /**
  67434. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67435. * @param onCompiled Callback triggered at the and of the effects compilation
  67436. * @param options Sets of optional options forcing the compilation with different modes
  67437. */
  67438. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67439. useInstances: boolean;
  67440. }>): void;
  67441. /**
  67442. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67443. * @param options Sets of optional options forcing the compilation with different modes
  67444. * @returns A promise that resolves when the compilation completes
  67445. */
  67446. forceCompilationAsync(options?: Partial<{
  67447. useInstances: boolean;
  67448. }>): Promise<void>;
  67449. /**
  67450. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67451. * @param subMesh The submesh we want to render in the shadow map
  67452. * @param useInstances Defines wether will draw in the map using instances
  67453. * @returns true if ready otherwise, false
  67454. */
  67455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67456. /**
  67457. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67458. * @param defines Defines of the material we want to update
  67459. * @param lightIndex Index of the light in the enabled light list of the material
  67460. */
  67461. prepareDefines(defines: any, lightIndex: number): void;
  67462. /**
  67463. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67464. * defined in the generator but impacting the effect).
  67465. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67466. * @param effect The effect we are binfing the information for
  67467. */
  67468. bindShadowLight(lightIndex: string, effect: Effect): void;
  67469. /**
  67470. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67471. * (eq to shadow prjection matrix * light transform matrix)
  67472. * @returns The transform matrix used to create the shadow map
  67473. */
  67474. getTransformMatrix(): Matrix;
  67475. /**
  67476. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67477. * Cube and 2D textures for instance.
  67478. */
  67479. recreateShadowMap(): void;
  67480. private _disposeBlurPostProcesses;
  67481. private _disposeRTTandPostProcesses;
  67482. /**
  67483. * Disposes the ShadowGenerator.
  67484. * Returns nothing.
  67485. */
  67486. dispose(): void;
  67487. /**
  67488. * Serializes the shadow generator setup to a json object.
  67489. * @returns The serialized JSON object
  67490. */
  67491. serialize(): any;
  67492. /**
  67493. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67494. * @param parsedShadowGenerator The JSON object to parse
  67495. * @param scene The scene to create the shadow map for
  67496. * @returns The parsed shadow generator
  67497. */
  67498. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67499. }
  67500. }
  67501. declare module BABYLON {
  67502. /**
  67503. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67504. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67505. * 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.
  67506. */
  67507. export abstract class Light extends Node {
  67508. /**
  67509. * Falloff Default: light is falling off following the material specification:
  67510. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67511. */
  67512. static readonly FALLOFF_DEFAULT: number;
  67513. /**
  67514. * Falloff Physical: light is falling off following the inverse squared distance law.
  67515. */
  67516. static readonly FALLOFF_PHYSICAL: number;
  67517. /**
  67518. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67519. * to enhance interoperability with other engines.
  67520. */
  67521. static readonly FALLOFF_GLTF: number;
  67522. /**
  67523. * Falloff Standard: light is falling off like in the standard material
  67524. * to enhance interoperability with other materials.
  67525. */
  67526. static readonly FALLOFF_STANDARD: number;
  67527. /**
  67528. * If every light affecting the material is in this lightmapMode,
  67529. * material.lightmapTexture adds or multiplies
  67530. * (depends on material.useLightmapAsShadowmap)
  67531. * after every other light calculations.
  67532. */
  67533. static readonly LIGHTMAP_DEFAULT: number;
  67534. /**
  67535. * material.lightmapTexture as only diffuse lighting from this light
  67536. * adds only specular lighting from this light
  67537. * adds dynamic shadows
  67538. */
  67539. static readonly LIGHTMAP_SPECULAR: number;
  67540. /**
  67541. * material.lightmapTexture as only lighting
  67542. * no light calculation from this light
  67543. * only adds dynamic shadows from this light
  67544. */
  67545. static readonly LIGHTMAP_SHADOWSONLY: number;
  67546. /**
  67547. * Each light type uses the default quantity according to its type:
  67548. * point/spot lights use luminous intensity
  67549. * directional lights use illuminance
  67550. */
  67551. static readonly INTENSITYMODE_AUTOMATIC: number;
  67552. /**
  67553. * lumen (lm)
  67554. */
  67555. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67556. /**
  67557. * candela (lm/sr)
  67558. */
  67559. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67560. /**
  67561. * lux (lm/m^2)
  67562. */
  67563. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67564. /**
  67565. * nit (cd/m^2)
  67566. */
  67567. static readonly INTENSITYMODE_LUMINANCE: number;
  67568. /**
  67569. * Light type const id of the point light.
  67570. */
  67571. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67572. /**
  67573. * Light type const id of the directional light.
  67574. */
  67575. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67576. /**
  67577. * Light type const id of the spot light.
  67578. */
  67579. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67580. /**
  67581. * Light type const id of the hemispheric light.
  67582. */
  67583. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67584. /**
  67585. * Diffuse gives the basic color to an object.
  67586. */
  67587. diffuse: Color3;
  67588. /**
  67589. * Specular produces a highlight color on an object.
  67590. * Note: This is note affecting PBR materials.
  67591. */
  67592. specular: Color3;
  67593. /**
  67594. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67595. * falling off base on range or angle.
  67596. * This can be set to any values in Light.FALLOFF_x.
  67597. *
  67598. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67599. * other types of materials.
  67600. */
  67601. falloffType: number;
  67602. /**
  67603. * Strength of the light.
  67604. * Note: By default it is define in the framework own unit.
  67605. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67606. */
  67607. intensity: number;
  67608. private _range;
  67609. protected _inverseSquaredRange: number;
  67610. /**
  67611. * Defines how far from the source the light is impacting in scene units.
  67612. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67613. */
  67614. /**
  67615. * Defines how far from the source the light is impacting in scene units.
  67616. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67617. */
  67618. range: number;
  67619. /**
  67620. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67621. * of light.
  67622. */
  67623. private _photometricScale;
  67624. private _intensityMode;
  67625. /**
  67626. * Gets the photometric scale used to interpret the intensity.
  67627. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67628. */
  67629. /**
  67630. * Sets the photometric scale used to interpret the intensity.
  67631. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67632. */
  67633. intensityMode: number;
  67634. private _radius;
  67635. /**
  67636. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67637. */
  67638. /**
  67639. * sets the light radius used by PBR Materials to simulate soft area lights.
  67640. */
  67641. radius: number;
  67642. private _renderPriority;
  67643. /**
  67644. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67645. * exceeding the number allowed of the materials.
  67646. */
  67647. renderPriority: number;
  67648. private _shadowEnabled;
  67649. /**
  67650. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67651. * the current shadow generator.
  67652. */
  67653. /**
  67654. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67655. * the current shadow generator.
  67656. */
  67657. shadowEnabled: boolean;
  67658. private _includedOnlyMeshes;
  67659. /**
  67660. * Gets the only meshes impacted by this light.
  67661. */
  67662. /**
  67663. * Sets the only meshes impacted by this light.
  67664. */
  67665. includedOnlyMeshes: AbstractMesh[];
  67666. private _excludedMeshes;
  67667. /**
  67668. * Gets the meshes not impacted by this light.
  67669. */
  67670. /**
  67671. * Sets the meshes not impacted by this light.
  67672. */
  67673. excludedMeshes: AbstractMesh[];
  67674. private _excludeWithLayerMask;
  67675. /**
  67676. * Gets the layer id use to find what meshes are not impacted by the light.
  67677. * Inactive if 0
  67678. */
  67679. /**
  67680. * Sets the layer id use to find what meshes are not impacted by the light.
  67681. * Inactive if 0
  67682. */
  67683. excludeWithLayerMask: number;
  67684. private _includeOnlyWithLayerMask;
  67685. /**
  67686. * Gets the layer id use to find what meshes are impacted by the light.
  67687. * Inactive if 0
  67688. */
  67689. /**
  67690. * Sets the layer id use to find what meshes are impacted by the light.
  67691. * Inactive if 0
  67692. */
  67693. includeOnlyWithLayerMask: number;
  67694. private _lightmapMode;
  67695. /**
  67696. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67697. */
  67698. /**
  67699. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67700. */
  67701. lightmapMode: number;
  67702. /**
  67703. * Shadow generator associted to the light.
  67704. * @hidden Internal use only.
  67705. */
  67706. _shadowGenerator: Nullable<IShadowGenerator>;
  67707. /**
  67708. * @hidden Internal use only.
  67709. */
  67710. _excludedMeshesIds: string[];
  67711. /**
  67712. * @hidden Internal use only.
  67713. */
  67714. _includedOnlyMeshesIds: string[];
  67715. /**
  67716. * The current light unifom buffer.
  67717. * @hidden Internal use only.
  67718. */
  67719. _uniformBuffer: UniformBuffer;
  67720. /**
  67721. * Creates a Light object in the scene.
  67722. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67723. * @param name The firendly name of the light
  67724. * @param scene The scene the light belongs too
  67725. */
  67726. constructor(name: string, scene: Scene);
  67727. protected abstract _buildUniformLayout(): void;
  67728. /**
  67729. * Sets the passed Effect "effect" with the Light information.
  67730. * @param effect The effect to update
  67731. * @param lightIndex The index of the light in the effect to update
  67732. * @returns The light
  67733. */
  67734. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67735. /**
  67736. * Returns the string "Light".
  67737. * @returns the class name
  67738. */
  67739. getClassName(): string;
  67740. /** @hidden */
  67741. readonly _isLight: boolean;
  67742. /**
  67743. * Converts the light information to a readable string for debug purpose.
  67744. * @param fullDetails Supports for multiple levels of logging within scene loading
  67745. * @returns the human readable light info
  67746. */
  67747. toString(fullDetails?: boolean): string;
  67748. /** @hidden */
  67749. protected _syncParentEnabledState(): void;
  67750. /**
  67751. * Set the enabled state of this node.
  67752. * @param value - the new enabled state
  67753. */
  67754. setEnabled(value: boolean): void;
  67755. /**
  67756. * Returns the Light associated shadow generator if any.
  67757. * @return the associated shadow generator.
  67758. */
  67759. getShadowGenerator(): Nullable<IShadowGenerator>;
  67760. /**
  67761. * Returns a Vector3, the absolute light position in the World.
  67762. * @returns the world space position of the light
  67763. */
  67764. getAbsolutePosition(): Vector3;
  67765. /**
  67766. * Specifies if the light will affect the passed mesh.
  67767. * @param mesh The mesh to test against the light
  67768. * @return true the mesh is affected otherwise, false.
  67769. */
  67770. canAffectMesh(mesh: AbstractMesh): boolean;
  67771. /**
  67772. * Sort function to order lights for rendering.
  67773. * @param a First Light object to compare to second.
  67774. * @param b Second Light object to compare first.
  67775. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67776. */
  67777. static CompareLightsPriority(a: Light, b: Light): number;
  67778. /**
  67779. * Releases resources associated with this node.
  67780. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67781. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67782. */
  67783. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67784. /**
  67785. * Returns the light type ID (integer).
  67786. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67787. */
  67788. getTypeID(): number;
  67789. /**
  67790. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67791. * @returns the scaled intensity in intensity mode unit
  67792. */
  67793. getScaledIntensity(): number;
  67794. /**
  67795. * Returns a new Light object, named "name", from the current one.
  67796. * @param name The name of the cloned light
  67797. * @returns the new created light
  67798. */
  67799. clone(name: string): Nullable<Light>;
  67800. /**
  67801. * Serializes the current light into a Serialization object.
  67802. * @returns the serialized object.
  67803. */
  67804. serialize(): any;
  67805. /**
  67806. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67807. * This new light is named "name" and added to the passed scene.
  67808. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67809. * @param name The friendly name of the light
  67810. * @param scene The scene the new light will belong to
  67811. * @returns the constructor function
  67812. */
  67813. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67814. /**
  67815. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67816. * @param parsedLight The JSON representation of the light
  67817. * @param scene The scene to create the parsed light in
  67818. * @returns the created light after parsing
  67819. */
  67820. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67821. private _hookArrayForExcluded;
  67822. private _hookArrayForIncludedOnly;
  67823. private _resyncMeshes;
  67824. /**
  67825. * Forces the meshes to update their light related information in their rendering used effects
  67826. * @hidden Internal Use Only
  67827. */
  67828. _markMeshesAsLightDirty(): void;
  67829. /**
  67830. * Recomputes the cached photometric scale if needed.
  67831. */
  67832. private _computePhotometricScale;
  67833. /**
  67834. * Returns the Photometric Scale according to the light type and intensity mode.
  67835. */
  67836. private _getPhotometricScale;
  67837. /**
  67838. * Reorder the light in the scene according to their defined priority.
  67839. * @hidden Internal Use Only
  67840. */
  67841. _reorderLightsInScene(): void;
  67842. /**
  67843. * Prepares the list of defines specific to the light type.
  67844. * @param defines the list of defines
  67845. * @param lightIndex defines the index of the light for the effect
  67846. */
  67847. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67848. }
  67849. }
  67850. declare module BABYLON {
  67851. /**
  67852. * The HemisphericLight simulates the ambient environment light,
  67853. * so the passed direction is the light reflection direction, not the incoming direction.
  67854. */
  67855. export class HemisphericLight extends Light {
  67856. /**
  67857. * The groundColor is the light in the opposite direction to the one specified during creation.
  67858. * 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.
  67859. */
  67860. groundColor: Color3;
  67861. /**
  67862. * The light reflection direction, not the incoming direction.
  67863. */
  67864. direction: Vector3;
  67865. /**
  67866. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  67867. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  67868. * The HemisphericLight can't cast shadows.
  67869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67870. * @param name The friendly name of the light
  67871. * @param direction The direction of the light reflection
  67872. * @param scene The scene the light belongs to
  67873. */
  67874. constructor(name: string, direction: Vector3, scene: Scene);
  67875. protected _buildUniformLayout(): void;
  67876. /**
  67877. * Returns the string "HemisphericLight".
  67878. * @return The class name
  67879. */
  67880. getClassName(): string;
  67881. /**
  67882. * Sets the HemisphericLight direction towards the passed target (Vector3).
  67883. * Returns the updated direction.
  67884. * @param target The target the direction should point to
  67885. * @return The computed direction
  67886. */
  67887. setDirectionToTarget(target: Vector3): Vector3;
  67888. /**
  67889. * Returns the shadow generator associated to the light.
  67890. * @returns Always null for hemispheric lights because it does not support shadows.
  67891. */
  67892. getShadowGenerator(): Nullable<IShadowGenerator>;
  67893. /**
  67894. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  67895. * @param effect The effect to update
  67896. * @param lightIndex The index of the light in the effect to update
  67897. * @returns The hemispheric light
  67898. */
  67899. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  67900. /**
  67901. * Computes the world matrix of the node
  67902. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67903. * @param useWasUpdatedFlag defines a reserved property
  67904. * @returns the world matrix
  67905. */
  67906. computeWorldMatrix(): Matrix;
  67907. /**
  67908. * Returns the integer 3.
  67909. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67910. */
  67911. getTypeID(): number;
  67912. /**
  67913. * Prepares the list of defines specific to the light type.
  67914. * @param defines the list of defines
  67915. * @param lightIndex defines the index of the light for the effect
  67916. */
  67917. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /**
  67922. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  67923. * IMPORTANT!! The data is right-hand data.
  67924. * @export
  67925. * @interface DevicePose
  67926. */
  67927. export interface DevicePose {
  67928. /**
  67929. * The position of the device, values in array are [x,y,z].
  67930. */
  67931. readonly position: Nullable<Float32Array>;
  67932. /**
  67933. * The linearVelocity of the device, values in array are [x,y,z].
  67934. */
  67935. readonly linearVelocity: Nullable<Float32Array>;
  67936. /**
  67937. * The linearAcceleration of the device, values in array are [x,y,z].
  67938. */
  67939. readonly linearAcceleration: Nullable<Float32Array>;
  67940. /**
  67941. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  67942. */
  67943. readonly orientation: Nullable<Float32Array>;
  67944. /**
  67945. * The angularVelocity of the device, values in array are [x,y,z].
  67946. */
  67947. readonly angularVelocity: Nullable<Float32Array>;
  67948. /**
  67949. * The angularAcceleration of the device, values in array are [x,y,z].
  67950. */
  67951. readonly angularAcceleration: Nullable<Float32Array>;
  67952. }
  67953. /**
  67954. * Interface representing a pose controlled object in Babylon.
  67955. * A pose controlled object has both regular pose values as well as pose values
  67956. * from an external device such as a VR head mounted display
  67957. */
  67958. export interface PoseControlled {
  67959. /**
  67960. * The position of the object in babylon space.
  67961. */
  67962. position: Vector3;
  67963. /**
  67964. * The rotation quaternion of the object in babylon space.
  67965. */
  67966. rotationQuaternion: Quaternion;
  67967. /**
  67968. * The position of the device in babylon space.
  67969. */
  67970. devicePosition?: Vector3;
  67971. /**
  67972. * The rotation quaternion of the device in babylon space.
  67973. */
  67974. deviceRotationQuaternion: Quaternion;
  67975. /**
  67976. * The raw pose coming from the device.
  67977. */
  67978. rawPose: Nullable<DevicePose>;
  67979. /**
  67980. * The scale of the device to be used when translating from device space to babylon space.
  67981. */
  67982. deviceScaleFactor: number;
  67983. /**
  67984. * Updates the poseControlled values based on the input device pose.
  67985. * @param poseData the pose data to update the object with
  67986. */
  67987. updateFromDevice(poseData: DevicePose): void;
  67988. }
  67989. /**
  67990. * Set of options to customize the webVRCamera
  67991. */
  67992. export interface WebVROptions {
  67993. /**
  67994. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  67995. */
  67996. trackPosition?: boolean;
  67997. /**
  67998. * Sets the scale of the vrDevice in babylon space. (default: 1)
  67999. */
  68000. positionScale?: number;
  68001. /**
  68002. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  68003. */
  68004. displayName?: string;
  68005. /**
  68006. * Should the native controller meshes be initialized. (default: true)
  68007. */
  68008. controllerMeshes?: boolean;
  68009. /**
  68010. * Creating a default HemiLight only on controllers. (default: true)
  68011. */
  68012. defaultLightingOnControllers?: boolean;
  68013. /**
  68014. * If you don't want to use the default VR button of the helper. (default: false)
  68015. */
  68016. useCustomVRButton?: boolean;
  68017. /**
  68018. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  68019. */
  68020. customVRButton?: HTMLButtonElement;
  68021. /**
  68022. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  68023. */
  68024. rayLength?: number;
  68025. /**
  68026. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  68027. */
  68028. defaultHeight?: number;
  68029. }
  68030. /**
  68031. * This represents a WebVR camera.
  68032. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  68033. * @example http://doc.babylonjs.com/how_to/webvr_camera
  68034. */
  68035. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  68036. private webVROptions;
  68037. /**
  68038. * @hidden
  68039. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  68040. */
  68041. _vrDevice: any;
  68042. /**
  68043. * The rawPose of the vrDevice.
  68044. */
  68045. rawPose: Nullable<DevicePose>;
  68046. private _onVREnabled;
  68047. private _specsVersion;
  68048. private _attached;
  68049. private _frameData;
  68050. protected _descendants: Array<Node>;
  68051. private _deviceRoomPosition;
  68052. /** @hidden */
  68053. _deviceRoomRotationQuaternion: Quaternion;
  68054. private _standingMatrix;
  68055. /**
  68056. * Represents device position in babylon space.
  68057. */
  68058. devicePosition: Vector3;
  68059. /**
  68060. * Represents device rotation in babylon space.
  68061. */
  68062. deviceRotationQuaternion: Quaternion;
  68063. /**
  68064. * The scale of the device to be used when translating from device space to babylon space.
  68065. */
  68066. deviceScaleFactor: number;
  68067. private _deviceToWorld;
  68068. private _worldToDevice;
  68069. /**
  68070. * References to the webVR controllers for the vrDevice.
  68071. */
  68072. controllers: Array<WebVRController>;
  68073. /**
  68074. * Emits an event when a controller is attached.
  68075. */
  68076. onControllersAttachedObservable: Observable<WebVRController[]>;
  68077. /**
  68078. * Emits an event when a controller's mesh has been loaded;
  68079. */
  68080. onControllerMeshLoadedObservable: Observable<WebVRController>;
  68081. /**
  68082. * Emits an event when the HMD's pose has been updated.
  68083. */
  68084. onPoseUpdatedFromDeviceObservable: Observable<any>;
  68085. private _poseSet;
  68086. /**
  68087. * If the rig cameras be used as parent instead of this camera.
  68088. */
  68089. rigParenting: boolean;
  68090. private _lightOnControllers;
  68091. private _defaultHeight?;
  68092. /**
  68093. * Instantiates a WebVRFreeCamera.
  68094. * @param name The name of the WebVRFreeCamera
  68095. * @param position The starting anchor position for the camera
  68096. * @param scene The scene the camera belongs to
  68097. * @param webVROptions a set of customizable options for the webVRCamera
  68098. */
  68099. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  68100. /**
  68101. * Gets the device distance from the ground in meters.
  68102. * @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.
  68103. */
  68104. deviceDistanceToRoomGround(): number;
  68105. /**
  68106. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  68107. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  68108. */
  68109. useStandingMatrix(callback?: (bool: boolean) => void): void;
  68110. /**
  68111. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  68112. * @returns A promise with a boolean set to if the standing matrix is supported.
  68113. */
  68114. useStandingMatrixAsync(): Promise<boolean>;
  68115. /**
  68116. * Disposes the camera
  68117. */
  68118. dispose(): void;
  68119. /**
  68120. * Gets a vrController by name.
  68121. * @param name The name of the controller to retreive
  68122. * @returns the controller matching the name specified or null if not found
  68123. */
  68124. getControllerByName(name: string): Nullable<WebVRController>;
  68125. private _leftController;
  68126. /**
  68127. * The controller corrisponding to the users left hand.
  68128. */
  68129. readonly leftController: Nullable<WebVRController>;
  68130. private _rightController;
  68131. /**
  68132. * The controller corrisponding to the users right hand.
  68133. */
  68134. readonly rightController: Nullable<WebVRController>;
  68135. /**
  68136. * Casts a ray forward from the vrCamera's gaze.
  68137. * @param length Length of the ray (default: 100)
  68138. * @returns the ray corrisponding to the gaze
  68139. */
  68140. getForwardRay(length?: number): Ray;
  68141. /**
  68142. * @hidden
  68143. * Updates the camera based on device's frame data
  68144. */
  68145. _checkInputs(): void;
  68146. /**
  68147. * Updates the poseControlled values based on the input device pose.
  68148. * @param poseData Pose coming from the device
  68149. */
  68150. updateFromDevice(poseData: DevicePose): void;
  68151. private _htmlElementAttached;
  68152. private _detachIfAttached;
  68153. /**
  68154. * WebVR's attach control will start broadcasting frames to the device.
  68155. * Note that in certain browsers (chrome for example) this function must be called
  68156. * within a user-interaction callback. Example:
  68157. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  68158. *
  68159. * @param element html element to attach the vrDevice to
  68160. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  68161. */
  68162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68163. /**
  68164. * Detaches the camera from the html element and disables VR
  68165. *
  68166. * @param element html element to detach from
  68167. */
  68168. detachControl(element: HTMLElement): void;
  68169. /**
  68170. * @returns the name of this class
  68171. */
  68172. getClassName(): string;
  68173. /**
  68174. * Calls resetPose on the vrDisplay
  68175. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  68176. */
  68177. resetToCurrentRotation(): void;
  68178. /**
  68179. * @hidden
  68180. * Updates the rig cameras (left and right eye)
  68181. */
  68182. _updateRigCameras(): void;
  68183. private _workingVector;
  68184. private _oneVector;
  68185. private _workingMatrix;
  68186. private updateCacheCalled;
  68187. private _correctPositionIfNotTrackPosition;
  68188. /**
  68189. * @hidden
  68190. * Updates the cached values of the camera
  68191. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  68192. */
  68193. _updateCache(ignoreParentClass?: boolean): void;
  68194. /**
  68195. * @hidden
  68196. * Get current device position in babylon world
  68197. */
  68198. _computeDevicePosition(): void;
  68199. /**
  68200. * Updates the current device position and rotation in the babylon world
  68201. */
  68202. update(): void;
  68203. /**
  68204. * @hidden
  68205. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  68206. * @returns an identity matrix
  68207. */
  68208. _getViewMatrix(): Matrix;
  68209. private _tmpMatrix;
  68210. /**
  68211. * This function is called by the two RIG cameras.
  68212. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  68213. * @hidden
  68214. */
  68215. _getWebVRViewMatrix(): Matrix;
  68216. /** @hidden */
  68217. _getWebVRProjectionMatrix(): Matrix;
  68218. private _onGamepadConnectedObserver;
  68219. private _onGamepadDisconnectedObserver;
  68220. private _updateCacheWhenTrackingDisabledObserver;
  68221. /**
  68222. * Initializes the controllers and their meshes
  68223. */
  68224. initControllers(): void;
  68225. }
  68226. }
  68227. declare module BABYLON {
  68228. /**
  68229. * Size options for a post process
  68230. */
  68231. export type PostProcessOptions = {
  68232. width: number;
  68233. height: number;
  68234. };
  68235. /**
  68236. * PostProcess can be used to apply a shader to a texture after it has been rendered
  68237. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68238. */
  68239. export class PostProcess {
  68240. /** Name of the PostProcess. */
  68241. name: string;
  68242. /**
  68243. * Width of the texture to apply the post process on
  68244. */
  68245. width: number;
  68246. /**
  68247. * Height of the texture to apply the post process on
  68248. */
  68249. height: number;
  68250. /**
  68251. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  68252. * @hidden
  68253. */
  68254. _outputTexture: Nullable<InternalTexture>;
  68255. /**
  68256. * Sampling mode used by the shader
  68257. * See https://doc.babylonjs.com/classes/3.1/texture
  68258. */
  68259. renderTargetSamplingMode: number;
  68260. /**
  68261. * Clear color to use when screen clearing
  68262. */
  68263. clearColor: Color4;
  68264. /**
  68265. * If the buffer needs to be cleared before applying the post process. (default: true)
  68266. * Should be set to false if shader will overwrite all previous pixels.
  68267. */
  68268. autoClear: boolean;
  68269. /**
  68270. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  68271. */
  68272. alphaMode: number;
  68273. /**
  68274. * Sets the setAlphaBlendConstants of the babylon engine
  68275. */
  68276. alphaConstants: Color4;
  68277. /**
  68278. * Animations to be used for the post processing
  68279. */
  68280. animations: Animation[];
  68281. /**
  68282. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  68283. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  68284. */
  68285. enablePixelPerfectMode: boolean;
  68286. /**
  68287. * Force the postprocess to be applied without taking in account viewport
  68288. */
  68289. forceFullscreenViewport: boolean;
  68290. /**
  68291. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  68292. *
  68293. * | Value | Type | Description |
  68294. * | ----- | ----------------------------------- | ----------- |
  68295. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  68296. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  68297. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  68298. *
  68299. */
  68300. scaleMode: number;
  68301. /**
  68302. * Force textures to be a power of two (default: false)
  68303. */
  68304. alwaysForcePOT: boolean;
  68305. private _samples;
  68306. /**
  68307. * Number of sample textures (default: 1)
  68308. */
  68309. samples: number;
  68310. /**
  68311. * Modify the scale of the post process to be the same as the viewport (default: false)
  68312. */
  68313. adaptScaleToCurrentViewport: boolean;
  68314. private _camera;
  68315. private _scene;
  68316. private _engine;
  68317. private _options;
  68318. private _reusable;
  68319. private _textureType;
  68320. /**
  68321. * Smart array of input and output textures for the post process.
  68322. * @hidden
  68323. */
  68324. _textures: SmartArray<InternalTexture>;
  68325. /**
  68326. * The index in _textures that corresponds to the output texture.
  68327. * @hidden
  68328. */
  68329. _currentRenderTextureInd: number;
  68330. private _effect;
  68331. private _samplers;
  68332. private _fragmentUrl;
  68333. private _vertexUrl;
  68334. private _parameters;
  68335. private _scaleRatio;
  68336. protected _indexParameters: any;
  68337. private _shareOutputWithPostProcess;
  68338. private _texelSize;
  68339. private _forcedOutputTexture;
  68340. /**
  68341. * Returns the fragment url or shader name used in the post process.
  68342. * @returns the fragment url or name in the shader store.
  68343. */
  68344. getEffectName(): string;
  68345. /**
  68346. * An event triggered when the postprocess is activated.
  68347. */
  68348. onActivateObservable: Observable<Camera>;
  68349. private _onActivateObserver;
  68350. /**
  68351. * A function that is added to the onActivateObservable
  68352. */
  68353. onActivate: Nullable<(camera: Camera) => void>;
  68354. /**
  68355. * An event triggered when the postprocess changes its size.
  68356. */
  68357. onSizeChangedObservable: Observable<PostProcess>;
  68358. private _onSizeChangedObserver;
  68359. /**
  68360. * A function that is added to the onSizeChangedObservable
  68361. */
  68362. onSizeChanged: (postProcess: PostProcess) => void;
  68363. /**
  68364. * An event triggered when the postprocess applies its effect.
  68365. */
  68366. onApplyObservable: Observable<Effect>;
  68367. private _onApplyObserver;
  68368. /**
  68369. * A function that is added to the onApplyObservable
  68370. */
  68371. onApply: (effect: Effect) => void;
  68372. /**
  68373. * An event triggered before rendering the postprocess
  68374. */
  68375. onBeforeRenderObservable: Observable<Effect>;
  68376. private _onBeforeRenderObserver;
  68377. /**
  68378. * A function that is added to the onBeforeRenderObservable
  68379. */
  68380. onBeforeRender: (effect: Effect) => void;
  68381. /**
  68382. * An event triggered after rendering the postprocess
  68383. */
  68384. onAfterRenderObservable: Observable<Effect>;
  68385. private _onAfterRenderObserver;
  68386. /**
  68387. * A function that is added to the onAfterRenderObservable
  68388. */
  68389. onAfterRender: (efect: Effect) => void;
  68390. /**
  68391. * 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
  68392. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  68393. */
  68394. inputTexture: InternalTexture;
  68395. /**
  68396. * Gets the camera which post process is applied to.
  68397. * @returns The camera the post process is applied to.
  68398. */
  68399. getCamera(): Camera;
  68400. /**
  68401. * Gets the texel size of the postprocess.
  68402. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  68403. */
  68404. readonly texelSize: Vector2;
  68405. /**
  68406. * Creates a new instance PostProcess
  68407. * @param name The name of the PostProcess.
  68408. * @param fragmentUrl The url of the fragment shader to be used.
  68409. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  68410. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  68411. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68412. * @param camera The camera to apply the render pass to.
  68413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68414. * @param engine The engine which the post process will be applied. (default: current engine)
  68415. * @param reusable If the post process can be reused on the same frame. (default: false)
  68416. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  68417. * @param textureType Type of textures used when performing the post process. (default: 0)
  68418. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  68419. * @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
  68420. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  68421. */
  68422. constructor(
  68423. /** Name of the PostProcess. */
  68424. 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);
  68425. /**
  68426. * Gets the engine which this post process belongs to.
  68427. * @returns The engine the post process was enabled with.
  68428. */
  68429. getEngine(): Engine;
  68430. /**
  68431. * The effect that is created when initializing the post process.
  68432. * @returns The created effect corrisponding the the postprocess.
  68433. */
  68434. getEffect(): Effect;
  68435. /**
  68436. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  68437. * @param postProcess The post process to share the output with.
  68438. * @returns This post process.
  68439. */
  68440. shareOutputWith(postProcess: PostProcess): PostProcess;
  68441. /**
  68442. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  68443. * This should be called if the post process that shares output with this post process is disabled/disposed.
  68444. */
  68445. useOwnOutput(): void;
  68446. /**
  68447. * Updates the effect with the current post process compile time values and recompiles the shader.
  68448. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68449. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68450. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68451. * @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
  68452. * @param onCompiled Called when the shader has been compiled.
  68453. * @param onError Called if there is an error when compiling a shader.
  68454. */
  68455. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68456. /**
  68457. * The post process is reusable if it can be used multiple times within one frame.
  68458. * @returns If the post process is reusable
  68459. */
  68460. isReusable(): boolean;
  68461. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  68462. markTextureDirty(): void;
  68463. /**
  68464. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  68465. * 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.
  68466. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  68467. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  68468. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  68469. * @returns The target texture that was bound to be written to.
  68470. */
  68471. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  68472. /**
  68473. * If the post process is supported.
  68474. */
  68475. readonly isSupported: boolean;
  68476. /**
  68477. * The aspect ratio of the output texture.
  68478. */
  68479. readonly aspectRatio: number;
  68480. /**
  68481. * Get a value indicating if the post-process is ready to be used
  68482. * @returns true if the post-process is ready (shader is compiled)
  68483. */
  68484. isReady(): boolean;
  68485. /**
  68486. * Binds all textures and uniforms to the shader, this will be run on every pass.
  68487. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  68488. */
  68489. apply(): Nullable<Effect>;
  68490. private _disposeTextures;
  68491. /**
  68492. * Disposes the post process.
  68493. * @param camera The camera to dispose the post process on.
  68494. */
  68495. dispose(camera?: Camera): void;
  68496. }
  68497. }
  68498. declare module BABYLON {
  68499. /** @hidden */
  68500. export var kernelBlurVaryingDeclaration: {
  68501. name: string;
  68502. shader: string;
  68503. };
  68504. }
  68505. declare module BABYLON {
  68506. /** @hidden */
  68507. export var kernelBlurFragment: {
  68508. name: string;
  68509. shader: string;
  68510. };
  68511. }
  68512. declare module BABYLON {
  68513. /** @hidden */
  68514. export var kernelBlurFragment2: {
  68515. name: string;
  68516. shader: string;
  68517. };
  68518. }
  68519. declare module BABYLON {
  68520. /** @hidden */
  68521. export var kernelBlurPixelShader: {
  68522. name: string;
  68523. shader: string;
  68524. };
  68525. }
  68526. declare module BABYLON {
  68527. /** @hidden */
  68528. export var kernelBlurVertex: {
  68529. name: string;
  68530. shader: string;
  68531. };
  68532. }
  68533. declare module BABYLON {
  68534. /** @hidden */
  68535. export var kernelBlurVertexShader: {
  68536. name: string;
  68537. shader: string;
  68538. };
  68539. }
  68540. declare module BABYLON {
  68541. /**
  68542. * The Blur Post Process which blurs an image based on a kernel and direction.
  68543. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68544. */
  68545. export class BlurPostProcess extends PostProcess {
  68546. /** The direction in which to blur the image. */
  68547. direction: Vector2;
  68548. private blockCompilation;
  68549. protected _kernel: number;
  68550. protected _idealKernel: number;
  68551. protected _packedFloat: boolean;
  68552. private _staticDefines;
  68553. /**
  68554. * Sets the length in pixels of the blur sample region
  68555. */
  68556. /**
  68557. * Gets the length in pixels of the blur sample region
  68558. */
  68559. kernel: number;
  68560. /**
  68561. * Sets wether or not the blur needs to unpack/repack floats
  68562. */
  68563. /**
  68564. * Gets wether or not the blur is unpacking/repacking floats
  68565. */
  68566. packedFloat: boolean;
  68567. /**
  68568. * Creates a new instance BlurPostProcess
  68569. * @param name The name of the effect.
  68570. * @param direction The direction in which to blur the image.
  68571. * @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.
  68572. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68573. * @param camera The camera to apply the render pass to.
  68574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68575. * @param engine The engine which the post process will be applied. (default: current engine)
  68576. * @param reusable If the post process can be reused on the same frame. (default: false)
  68577. * @param textureType Type of textures used when performing the post process. (default: 0)
  68578. * @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)
  68579. */
  68580. constructor(name: string,
  68581. /** The direction in which to blur the image. */
  68582. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68583. /**
  68584. * Updates the effect with the current post process compile time values and recompiles the shader.
  68585. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68586. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68587. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68588. * @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
  68589. * @param onCompiled Called when the shader has been compiled.
  68590. * @param onError Called if there is an error when compiling a shader.
  68591. */
  68592. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68593. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68594. /**
  68595. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68596. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68597. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68598. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68599. * The gaps between physical kernels are compensated for in the weighting of the samples
  68600. * @param idealKernel Ideal blur kernel.
  68601. * @return Nearest best kernel.
  68602. */
  68603. protected _nearestBestKernel(idealKernel: number): number;
  68604. /**
  68605. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68606. * @param x The point on the Gaussian distribution to sample.
  68607. * @return the value of the Gaussian function at x.
  68608. */
  68609. protected _gaussianWeight(x: number): number;
  68610. /**
  68611. * Generates a string that can be used as a floating point number in GLSL.
  68612. * @param x Value to print.
  68613. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68614. * @return GLSL float string.
  68615. */
  68616. protected _glslFloat(x: number, decimalFigures?: number): string;
  68617. }
  68618. }
  68619. declare module BABYLON {
  68620. /**
  68621. * Mirror texture can be used to simulate the view from a mirror in a scene.
  68622. * It will dynamically be rendered every frame to adapt to the camera point of view.
  68623. * You can then easily use it as a reflectionTexture on a flat surface.
  68624. * In case the surface is not a plane, please consider relying on reflection probes.
  68625. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68626. */
  68627. export class MirrorTexture extends RenderTargetTexture {
  68628. private scene;
  68629. /**
  68630. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  68631. * 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.
  68632. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68633. */
  68634. mirrorPlane: Plane;
  68635. /**
  68636. * Define the blur ratio used to blur the reflection if needed.
  68637. */
  68638. blurRatio: number;
  68639. /**
  68640. * Define the adaptive blur kernel used to blur the reflection if needed.
  68641. * This will autocompute the closest best match for the `blurKernel`
  68642. */
  68643. adaptiveBlurKernel: number;
  68644. /**
  68645. * Define the blur kernel used to blur the reflection if needed.
  68646. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68647. */
  68648. blurKernel: number;
  68649. /**
  68650. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  68651. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68652. */
  68653. blurKernelX: number;
  68654. /**
  68655. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  68656. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  68657. */
  68658. blurKernelY: number;
  68659. private _autoComputeBlurKernel;
  68660. protected _onRatioRescale(): void;
  68661. private _updateGammaSpace;
  68662. private _imageProcessingConfigChangeObserver;
  68663. private _transformMatrix;
  68664. private _mirrorMatrix;
  68665. private _savedViewMatrix;
  68666. private _blurX;
  68667. private _blurY;
  68668. private _adaptiveBlurKernel;
  68669. private _blurKernelX;
  68670. private _blurKernelY;
  68671. private _blurRatio;
  68672. /**
  68673. * Instantiates a Mirror Texture.
  68674. * Mirror texture can be used to simulate the view from a mirror in a scene.
  68675. * It will dynamically be rendered every frame to adapt to the camera point of view.
  68676. * You can then easily use it as a reflectionTexture on a flat surface.
  68677. * In case the surface is not a plane, please consider relying on reflection probes.
  68678. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  68679. * @param name
  68680. * @param size
  68681. * @param scene
  68682. * @param generateMipMaps
  68683. * @param type
  68684. * @param samplingMode
  68685. * @param generateDepthBuffer
  68686. */
  68687. constructor(name: string, size: number | {
  68688. width: number;
  68689. height: number;
  68690. } | {
  68691. ratio: number;
  68692. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  68693. private _preparePostProcesses;
  68694. /**
  68695. * Clone the mirror texture.
  68696. * @returns the cloned texture
  68697. */
  68698. clone(): MirrorTexture;
  68699. /**
  68700. * Serialize the texture to a JSON representation you could use in Parse later on
  68701. * @returns the serialized JSON representation
  68702. */
  68703. serialize(): any;
  68704. /**
  68705. * Dispose the texture and release its associated resources.
  68706. */
  68707. dispose(): void;
  68708. }
  68709. }
  68710. declare module BABYLON {
  68711. /**
  68712. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  68713. * @see http://doc.babylonjs.com/babylon101/materials#texture
  68714. */
  68715. export class Texture extends BaseTexture {
  68716. /** @hidden */
  68717. static _AnimationParser: (jsonAnimation: any) => Animation;
  68718. /** @hidden */
  68719. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  68720. /** @hidden */
  68721. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  68722. /** @hidden */
  68723. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  68724. /** nearest is mag = nearest and min = nearest and mip = linear */
  68725. static readonly NEAREST_SAMPLINGMODE: number;
  68726. /** nearest is mag = nearest and min = nearest and mip = linear */
  68727. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  68728. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68729. static readonly BILINEAR_SAMPLINGMODE: number;
  68730. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68731. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  68732. /** Trilinear is mag = linear and min = linear and mip = linear */
  68733. static readonly TRILINEAR_SAMPLINGMODE: number;
  68734. /** Trilinear is mag = linear and min = linear and mip = linear */
  68735. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  68736. /** mag = nearest and min = nearest and mip = nearest */
  68737. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  68738. /** mag = nearest and min = linear and mip = nearest */
  68739. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  68740. /** mag = nearest and min = linear and mip = linear */
  68741. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  68742. /** mag = nearest and min = linear and mip = none */
  68743. static readonly NEAREST_LINEAR: number;
  68744. /** mag = nearest and min = nearest and mip = none */
  68745. static readonly NEAREST_NEAREST: number;
  68746. /** mag = linear and min = nearest and mip = nearest */
  68747. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  68748. /** mag = linear and min = nearest and mip = linear */
  68749. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  68750. /** mag = linear and min = linear and mip = none */
  68751. static readonly LINEAR_LINEAR: number;
  68752. /** mag = linear and min = nearest and mip = none */
  68753. static readonly LINEAR_NEAREST: number;
  68754. /** Explicit coordinates mode */
  68755. static readonly EXPLICIT_MODE: number;
  68756. /** Spherical coordinates mode */
  68757. static readonly SPHERICAL_MODE: number;
  68758. /** Planar coordinates mode */
  68759. static readonly PLANAR_MODE: number;
  68760. /** Cubic coordinates mode */
  68761. static readonly CUBIC_MODE: number;
  68762. /** Projection coordinates mode */
  68763. static readonly PROJECTION_MODE: number;
  68764. /** Inverse Cubic coordinates mode */
  68765. static readonly SKYBOX_MODE: number;
  68766. /** Inverse Cubic coordinates mode */
  68767. static readonly INVCUBIC_MODE: number;
  68768. /** Equirectangular coordinates mode */
  68769. static readonly EQUIRECTANGULAR_MODE: number;
  68770. /** Equirectangular Fixed coordinates mode */
  68771. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  68772. /** Equirectangular Fixed Mirrored coordinates mode */
  68773. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68774. /** Texture is not repeating outside of 0..1 UVs */
  68775. static readonly CLAMP_ADDRESSMODE: number;
  68776. /** Texture is repeating outside of 0..1 UVs */
  68777. static readonly WRAP_ADDRESSMODE: number;
  68778. /** Texture is repeating and mirrored */
  68779. static readonly MIRROR_ADDRESSMODE: number;
  68780. /**
  68781. * 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
  68782. */
  68783. static UseSerializedUrlIfAny: boolean;
  68784. /**
  68785. * Define the url of the texture.
  68786. */
  68787. url: Nullable<string>;
  68788. /**
  68789. * Define an offset on the texture to offset the u coordinates of the UVs
  68790. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  68791. */
  68792. uOffset: number;
  68793. /**
  68794. * Define an offset on the texture to offset the v coordinates of the UVs
  68795. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  68796. */
  68797. vOffset: number;
  68798. /**
  68799. * Define an offset on the texture to scale the u coordinates of the UVs
  68800. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  68801. */
  68802. uScale: number;
  68803. /**
  68804. * Define an offset on the texture to scale the v coordinates of the UVs
  68805. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  68806. */
  68807. vScale: number;
  68808. /**
  68809. * Define an offset on the texture to rotate around the u coordinates of the UVs
  68810. * @see http://doc.babylonjs.com/how_to/more_materials
  68811. */
  68812. uAng: number;
  68813. /**
  68814. * Define an offset on the texture to rotate around the v coordinates of the UVs
  68815. * @see http://doc.babylonjs.com/how_to/more_materials
  68816. */
  68817. vAng: number;
  68818. /**
  68819. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  68820. * @see http://doc.babylonjs.com/how_to/more_materials
  68821. */
  68822. wAng: number;
  68823. /**
  68824. * Defines the center of rotation (U)
  68825. */
  68826. uRotationCenter: number;
  68827. /**
  68828. * Defines the center of rotation (V)
  68829. */
  68830. vRotationCenter: number;
  68831. /**
  68832. * Defines the center of rotation (W)
  68833. */
  68834. wRotationCenter: number;
  68835. /**
  68836. * Are mip maps generated for this texture or not.
  68837. */
  68838. readonly noMipmap: boolean;
  68839. private _noMipmap;
  68840. /** @hidden */
  68841. _invertY: boolean;
  68842. private _rowGenerationMatrix;
  68843. private _cachedTextureMatrix;
  68844. private _projectionModeMatrix;
  68845. private _t0;
  68846. private _t1;
  68847. private _t2;
  68848. private _cachedUOffset;
  68849. private _cachedVOffset;
  68850. private _cachedUScale;
  68851. private _cachedVScale;
  68852. private _cachedUAng;
  68853. private _cachedVAng;
  68854. private _cachedWAng;
  68855. private _cachedProjectionMatrixId;
  68856. private _cachedCoordinatesMode;
  68857. /** @hidden */
  68858. protected _initialSamplingMode: number;
  68859. /** @hidden */
  68860. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68861. private _deleteBuffer;
  68862. protected _format: Nullable<number>;
  68863. private _delayedOnLoad;
  68864. private _delayedOnError;
  68865. /**
  68866. * Observable triggered once the texture has been loaded.
  68867. */
  68868. onLoadObservable: Observable<Texture>;
  68869. protected _isBlocking: boolean;
  68870. /**
  68871. * Is the texture preventing material to render while loading.
  68872. * If false, a default texture will be used instead of the loading one during the preparation step.
  68873. */
  68874. isBlocking: boolean;
  68875. /**
  68876. * Get the current sampling mode associated with the texture.
  68877. */
  68878. readonly samplingMode: number;
  68879. /**
  68880. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  68881. */
  68882. readonly invertY: boolean;
  68883. /**
  68884. * Instantiates a new texture.
  68885. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  68886. * @see http://doc.babylonjs.com/babylon101/materials#texture
  68887. * @param url define the url of the picture to load as a texture
  68888. * @param scene define the scene the texture will belong to
  68889. * @param noMipmap define if the texture will require mip maps or not
  68890. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68891. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68892. * @param onLoad define a callback triggered when the texture has been loaded
  68893. * @param onError define a callback triggered when an error occurred during the loading session
  68894. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  68895. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  68896. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68897. */
  68898. 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);
  68899. /**
  68900. * Update the url (and optional buffer) of this texture if url was null during construction.
  68901. * @param url the url of the texture
  68902. * @param buffer the buffer of the texture (defaults to null)
  68903. * @param onLoad callback called when the texture is loaded (defaults to null)
  68904. */
  68905. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  68906. /**
  68907. * Finish the loading sequence of a texture flagged as delayed load.
  68908. * @hidden
  68909. */
  68910. delayLoad(): void;
  68911. private _prepareRowForTextureGeneration;
  68912. /**
  68913. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  68914. * @returns the transform matrix of the texture.
  68915. */
  68916. getTextureMatrix(): Matrix;
  68917. /**
  68918. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  68919. * @returns The reflection texture transform
  68920. */
  68921. getReflectionTextureMatrix(): Matrix;
  68922. /**
  68923. * Clones the texture.
  68924. * @returns the cloned texture
  68925. */
  68926. clone(): Texture;
  68927. /**
  68928. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  68929. * @returns The JSON representation of the texture
  68930. */
  68931. serialize(): any;
  68932. /**
  68933. * Get the current class name of the texture useful for serialization or dynamic coding.
  68934. * @returns "Texture"
  68935. */
  68936. getClassName(): string;
  68937. /**
  68938. * Dispose the texture and release its associated resources.
  68939. */
  68940. dispose(): void;
  68941. /**
  68942. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  68943. * @param parsedTexture Define the JSON representation of the texture
  68944. * @param scene Define the scene the parsed texture should be instantiated in
  68945. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68946. * @returns The parsed texture if successful
  68947. */
  68948. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  68949. /**
  68950. * Creates a texture from its base 64 representation.
  68951. * @param data Define the base64 payload without the data: prefix
  68952. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  68953. * @param scene Define the scene the texture should belong to
  68954. * @param noMipmap Forces the texture to not create mip map information if true
  68955. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68956. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68957. * @param onLoad define a callback triggered when the texture has been loaded
  68958. * @param onError define a callback triggered when an error occurred during the loading session
  68959. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68960. * @returns the created texture
  68961. */
  68962. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  68963. /**
  68964. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  68965. * @param data Define the base64 payload without the data: prefix
  68966. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  68967. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  68968. * @param scene Define the scene the texture should belong to
  68969. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  68970. * @param noMipmap Forces the texture to not create mip map information if true
  68971. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68972. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68973. * @param onLoad define a callback triggered when the texture has been loaded
  68974. * @param onError define a callback triggered when an error occurred during the loading session
  68975. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68976. * @returns the created texture
  68977. */
  68978. 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;
  68979. }
  68980. }
  68981. declare module BABYLON {
  68982. /**
  68983. * PostProcessManager is used to manage one or more post processes or post process pipelines
  68984. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68985. */
  68986. export class PostProcessManager {
  68987. private _scene;
  68988. private _indexBuffer;
  68989. private _vertexBuffers;
  68990. /**
  68991. * Creates a new instance PostProcess
  68992. * @param scene The scene that the post process is associated with.
  68993. */
  68994. constructor(scene: Scene);
  68995. private _prepareBuffers;
  68996. private _buildIndexBuffer;
  68997. /**
  68998. * Rebuilds the vertex buffers of the manager.
  68999. * @hidden
  69000. */
  69001. _rebuild(): void;
  69002. /**
  69003. * Prepares a frame to be run through a post process.
  69004. * @param sourceTexture The input texture to the post procesess. (default: null)
  69005. * @param postProcesses An array of post processes to be run. (default: null)
  69006. * @returns True if the post processes were able to be run.
  69007. * @hidden
  69008. */
  69009. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  69010. /**
  69011. * Manually render a set of post processes to a texture.
  69012. * @param postProcesses An array of post processes to be run.
  69013. * @param targetTexture The target texture to render to.
  69014. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  69015. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  69016. * @param lodLevel defines which lod of the texture to render to
  69017. */
  69018. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  69019. /**
  69020. * Finalize the result of the output of the postprocesses.
  69021. * @param doNotPresent If true the result will not be displayed to the screen.
  69022. * @param targetTexture The target texture to render to.
  69023. * @param faceIndex The index of the face to bind the target texture to.
  69024. * @param postProcesses The array of post processes to render.
  69025. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  69026. * @hidden
  69027. */
  69028. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  69029. /**
  69030. * Disposes of the post process manager.
  69031. */
  69032. dispose(): void;
  69033. }
  69034. }
  69035. declare module BABYLON {
  69036. /**
  69037. * Groups all the scene component constants in one place to ease maintenance.
  69038. * @hidden
  69039. */
  69040. export class SceneComponentConstants {
  69041. static readonly NAME_EFFECTLAYER: string;
  69042. static readonly NAME_LAYER: string;
  69043. static readonly NAME_LENSFLARESYSTEM: string;
  69044. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69045. static readonly NAME_PARTICLESYSTEM: string;
  69046. static readonly NAME_GAMEPAD: string;
  69047. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69048. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69049. static readonly NAME_DEPTHRENDERER: string;
  69050. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69051. static readonly NAME_SPRITE: string;
  69052. static readonly NAME_OUTLINERENDERER: string;
  69053. static readonly NAME_PROCEDURALTEXTURE: string;
  69054. static readonly NAME_SHADOWGENERATOR: string;
  69055. static readonly NAME_OCTREE: string;
  69056. static readonly NAME_PHYSICSENGINE: string;
  69057. static readonly NAME_AUDIO: string;
  69058. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69059. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69060. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69061. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69062. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69063. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69064. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69065. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69066. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69067. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69068. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69069. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69070. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69071. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69072. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69073. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69074. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69075. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69076. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69077. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69078. static readonly STEP_AFTERRENDER_AUDIO: number;
  69079. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69080. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69081. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69082. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69083. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69084. static readonly STEP_POINTERMOVE_SPRITE: number;
  69085. static readonly STEP_POINTERDOWN_SPRITE: number;
  69086. static readonly STEP_POINTERUP_SPRITE: number;
  69087. }
  69088. /**
  69089. * This represents a scene component.
  69090. *
  69091. * This is used to decouple the dependency the scene is having on the different workloads like
  69092. * layers, post processes...
  69093. */
  69094. export interface ISceneComponent {
  69095. /**
  69096. * The name of the component. Each component must have a unique name.
  69097. */
  69098. name: string;
  69099. /**
  69100. * The scene the component belongs to.
  69101. */
  69102. scene: Scene;
  69103. /**
  69104. * Register the component to one instance of a scene.
  69105. */
  69106. register(): void;
  69107. /**
  69108. * Rebuilds the elements related to this component in case of
  69109. * context lost for instance.
  69110. */
  69111. rebuild(): void;
  69112. /**
  69113. * Disposes the component and the associated ressources.
  69114. */
  69115. dispose(): void;
  69116. }
  69117. /**
  69118. * This represents a SERIALIZABLE scene component.
  69119. *
  69120. * This extends Scene Component to add Serialization methods on top.
  69121. */
  69122. export interface ISceneSerializableComponent extends ISceneComponent {
  69123. /**
  69124. * Adds all the element from the container to the scene
  69125. * @param container the container holding the elements
  69126. */
  69127. addFromContainer(container: AbstractScene): void;
  69128. /**
  69129. * Removes all the elements in the container from the scene
  69130. * @param container contains the elements to remove
  69131. */
  69132. removeFromContainer(container: AbstractScene): void;
  69133. /**
  69134. * Serializes the component data to the specified json object
  69135. * @param serializationObject The object to serialize to
  69136. */
  69137. serialize(serializationObject: any): void;
  69138. }
  69139. /**
  69140. * Strong typing of a Mesh related stage step action
  69141. */
  69142. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69143. /**
  69144. * Strong typing of a Evaluate Sub Mesh related stage step action
  69145. */
  69146. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69147. /**
  69148. * Strong typing of a Active Mesh related stage step action
  69149. */
  69150. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69151. /**
  69152. * Strong typing of a Camera related stage step action
  69153. */
  69154. export type CameraStageAction = (camera: Camera) => void;
  69155. /**
  69156. * Strong typing of a Render Target related stage step action
  69157. */
  69158. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69159. /**
  69160. * Strong typing of a RenderingGroup related stage step action
  69161. */
  69162. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69163. /**
  69164. * Strong typing of a Mesh Render related stage step action
  69165. */
  69166. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69167. /**
  69168. * Strong typing of a simple stage step action
  69169. */
  69170. export type SimpleStageAction = () => void;
  69171. /**
  69172. * Strong typing of a render target action.
  69173. */
  69174. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69175. /**
  69176. * Strong typing of a pointer move action.
  69177. */
  69178. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69179. /**
  69180. * Strong typing of a pointer up/down action.
  69181. */
  69182. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69183. /**
  69184. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69185. * @hidden
  69186. */
  69187. export class Stage<T extends Function> extends Array<{
  69188. index: number;
  69189. component: ISceneComponent;
  69190. action: T;
  69191. }> {
  69192. /**
  69193. * Hide ctor from the rest of the world.
  69194. * @param items The items to add.
  69195. */
  69196. private constructor();
  69197. /**
  69198. * Creates a new Stage.
  69199. * @returns A new instance of a Stage
  69200. */
  69201. static Create<T extends Function>(): Stage<T>;
  69202. /**
  69203. * Registers a step in an ordered way in the targeted stage.
  69204. * @param index Defines the position to register the step in
  69205. * @param component Defines the component attached to the step
  69206. * @param action Defines the action to launch during the step
  69207. */
  69208. registerStep(index: number, component: ISceneComponent, action: T): void;
  69209. /**
  69210. * Clears all the steps from the stage.
  69211. */
  69212. clear(): void;
  69213. }
  69214. }
  69215. declare module BABYLON {
  69216. interface Scene {
  69217. /** @hidden */
  69218. _pointerOverSprite: Nullable<Sprite>;
  69219. /** @hidden */
  69220. _pickedDownSprite: Nullable<Sprite>;
  69221. /** @hidden */
  69222. _tempSpritePickingRay: Nullable<Ray>;
  69223. /**
  69224. * All of the sprite managers added to this scene
  69225. * @see http://doc.babylonjs.com/babylon101/sprites
  69226. */
  69227. spriteManagers: Array<ISpriteManager>;
  69228. /**
  69229. * An event triggered when sprites rendering is about to start
  69230. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69231. */
  69232. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69233. /**
  69234. * An event triggered when sprites rendering is done
  69235. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69236. */
  69237. onAfterSpritesRenderingObservable: Observable<Scene>;
  69238. /** @hidden */
  69239. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69240. /** Launch a ray to try to pick a sprite in the scene
  69241. * @param x position on screen
  69242. * @param y position on screen
  69243. * @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
  69244. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69245. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69246. * @returns a PickingInfo
  69247. */
  69248. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69249. /** Use the given ray to pick a sprite in the scene
  69250. * @param ray The ray (in world space) to use to pick meshes
  69251. * @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
  69252. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69253. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69254. * @returns a PickingInfo
  69255. */
  69256. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69257. /**
  69258. * Force the sprite under the pointer
  69259. * @param sprite defines the sprite to use
  69260. */
  69261. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69262. /**
  69263. * Gets the sprite under the pointer
  69264. * @returns a Sprite or null if no sprite is under the pointer
  69265. */
  69266. getPointerOverSprite(): Nullable<Sprite>;
  69267. }
  69268. /**
  69269. * Defines the sprite scene component responsible to manage sprites
  69270. * in a given scene.
  69271. */
  69272. export class SpriteSceneComponent implements ISceneComponent {
  69273. /**
  69274. * The component name helpfull to identify the component in the list of scene components.
  69275. */
  69276. readonly name: string;
  69277. /**
  69278. * The scene the component belongs to.
  69279. */
  69280. scene: Scene;
  69281. /** @hidden */
  69282. private _spritePredicate;
  69283. /**
  69284. * Creates a new instance of the component for the given scene
  69285. * @param scene Defines the scene to register the component in
  69286. */
  69287. constructor(scene: Scene);
  69288. /**
  69289. * Registers the component in a given scene
  69290. */
  69291. register(): void;
  69292. /**
  69293. * Rebuilds the elements related to this component in case of
  69294. * context lost for instance.
  69295. */
  69296. rebuild(): void;
  69297. /**
  69298. * Disposes the component and the associated ressources.
  69299. */
  69300. dispose(): void;
  69301. private _pickSpriteButKeepRay;
  69302. private _pointerMove;
  69303. private _pointerDown;
  69304. private _pointerUp;
  69305. }
  69306. }
  69307. declare module BABYLON {
  69308. /** @hidden */
  69309. export var fogFragmentDeclaration: {
  69310. name: string;
  69311. shader: string;
  69312. };
  69313. }
  69314. declare module BABYLON {
  69315. /** @hidden */
  69316. export var fogFragment: {
  69317. name: string;
  69318. shader: string;
  69319. };
  69320. }
  69321. declare module BABYLON {
  69322. /** @hidden */
  69323. export var spritesPixelShader: {
  69324. name: string;
  69325. shader: string;
  69326. };
  69327. }
  69328. declare module BABYLON {
  69329. /** @hidden */
  69330. export var fogVertexDeclaration: {
  69331. name: string;
  69332. shader: string;
  69333. };
  69334. }
  69335. declare module BABYLON {
  69336. /** @hidden */
  69337. export var spritesVertexShader: {
  69338. name: string;
  69339. shader: string;
  69340. };
  69341. }
  69342. declare module BABYLON {
  69343. /**
  69344. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69345. */
  69346. export interface ISpriteManager extends IDisposable {
  69347. /**
  69348. * Restricts the camera to viewing objects with the same layerMask.
  69349. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69350. */
  69351. layerMask: number;
  69352. /**
  69353. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69354. */
  69355. isPickable: boolean;
  69356. /**
  69357. * Specifies the rendering group id for this mesh (0 by default)
  69358. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69359. */
  69360. renderingGroupId: number;
  69361. /**
  69362. * Defines the list of sprites managed by the manager.
  69363. */
  69364. sprites: Array<Sprite>;
  69365. /**
  69366. * Tests the intersection of a sprite with a specific ray.
  69367. * @param ray The ray we are sending to test the collision
  69368. * @param camera The camera space we are sending rays in
  69369. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69370. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69371. * @returns picking info or null.
  69372. */
  69373. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69374. /**
  69375. * Renders the list of sprites on screen.
  69376. */
  69377. render(): void;
  69378. }
  69379. /**
  69380. * Class used to manage multiple sprites on the same spritesheet
  69381. * @see http://doc.babylonjs.com/babylon101/sprites
  69382. */
  69383. export class SpriteManager implements ISpriteManager {
  69384. /** defines the manager's name */
  69385. name: string;
  69386. /** Gets the list of sprites */
  69387. sprites: Sprite[];
  69388. /** Gets or sets the rendering group id (0 by default) */
  69389. renderingGroupId: number;
  69390. /** Gets or sets camera layer mask */
  69391. layerMask: number;
  69392. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69393. fogEnabled: boolean;
  69394. /** Gets or sets a boolean indicating if the sprites are pickable */
  69395. isPickable: boolean;
  69396. /** Defines the default width of a cell in the spritesheet */
  69397. cellWidth: number;
  69398. /** Defines the default height of a cell in the spritesheet */
  69399. cellHeight: number;
  69400. /**
  69401. * An event triggered when the manager is disposed.
  69402. */
  69403. onDisposeObservable: Observable<SpriteManager>;
  69404. private _onDisposeObserver;
  69405. /**
  69406. * Callback called when the manager is disposed
  69407. */
  69408. onDispose: () => void;
  69409. private _capacity;
  69410. private _spriteTexture;
  69411. private _epsilon;
  69412. private _scene;
  69413. private _vertexData;
  69414. private _buffer;
  69415. private _vertexBuffers;
  69416. private _indexBuffer;
  69417. private _effectBase;
  69418. private _effectFog;
  69419. /**
  69420. * Gets or sets the spritesheet texture
  69421. */
  69422. texture: Texture;
  69423. /**
  69424. * Creates a new sprite manager
  69425. * @param name defines the manager's name
  69426. * @param imgUrl defines the sprite sheet url
  69427. * @param capacity defines the maximum allowed number of sprites
  69428. * @param cellSize defines the size of a sprite cell
  69429. * @param scene defines the hosting scene
  69430. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69431. * @param samplingMode defines the smapling mode to use with spritesheet
  69432. */
  69433. constructor(
  69434. /** defines the manager's name */
  69435. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69436. private _appendSpriteVertex;
  69437. /**
  69438. * Intersects the sprites with a ray
  69439. * @param ray defines the ray to intersect with
  69440. * @param camera defines the current active camera
  69441. * @param predicate defines a predicate used to select candidate sprites
  69442. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69443. * @returns null if no hit or a PickingInfo
  69444. */
  69445. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69446. /**
  69447. * Render all child sprites
  69448. */
  69449. render(): void;
  69450. /**
  69451. * Release associated resources
  69452. */
  69453. dispose(): void;
  69454. }
  69455. }
  69456. declare module BABYLON {
  69457. interface AbstractScene {
  69458. /**
  69459. * The list of layers (background and foreground) of the scene
  69460. */
  69461. layers: Array<Layer>;
  69462. }
  69463. /**
  69464. * Defines the layer scene component responsible to manage any layers
  69465. * in a given scene.
  69466. */
  69467. export class LayerSceneComponent implements ISceneComponent {
  69468. /**
  69469. * The component name helpfull to identify the component in the list of scene components.
  69470. */
  69471. readonly name: string;
  69472. /**
  69473. * The scene the component belongs to.
  69474. */
  69475. scene: Scene;
  69476. private _engine;
  69477. /**
  69478. * Creates a new instance of the component for the given scene
  69479. * @param scene Defines the scene to register the component in
  69480. */
  69481. constructor(scene: Scene);
  69482. /**
  69483. * Registers the component in a given scene
  69484. */
  69485. register(): void;
  69486. /**
  69487. * Rebuilds the elements related to this component in case of
  69488. * context lost for instance.
  69489. */
  69490. rebuild(): void;
  69491. /**
  69492. * Disposes the component and the associated ressources.
  69493. */
  69494. dispose(): void;
  69495. private _draw;
  69496. private _drawCameraPredicate;
  69497. private _drawCameraBackground;
  69498. private _drawCameraForeground;
  69499. private _drawRenderTargetPredicate;
  69500. private _drawRenderTargetBackground;
  69501. private _drawRenderTargetForeground;
  69502. }
  69503. }
  69504. declare module BABYLON {
  69505. /** @hidden */
  69506. export var layerPixelShader: {
  69507. name: string;
  69508. shader: string;
  69509. };
  69510. }
  69511. declare module BABYLON {
  69512. /** @hidden */
  69513. export var layerVertexShader: {
  69514. name: string;
  69515. shader: string;
  69516. };
  69517. }
  69518. declare module BABYLON {
  69519. /**
  69520. * This represents a full screen 2d layer.
  69521. * This can be useful to display a picture in the background of your scene for instance.
  69522. * @see https://www.babylonjs-playground.com/#08A2BS#1
  69523. */
  69524. export class Layer {
  69525. /**
  69526. * Define the name of the layer.
  69527. */
  69528. name: string;
  69529. /**
  69530. * Define the texture the layer should display.
  69531. */
  69532. texture: Nullable<Texture>;
  69533. /**
  69534. * Is the layer in background or foreground.
  69535. */
  69536. isBackground: boolean;
  69537. /**
  69538. * Define the color of the layer (instead of texture).
  69539. */
  69540. color: Color4;
  69541. /**
  69542. * Define the scale of the layer in order to zoom in out of the texture.
  69543. */
  69544. scale: Vector2;
  69545. /**
  69546. * Define an offset for the layer in order to shift the texture.
  69547. */
  69548. offset: Vector2;
  69549. /**
  69550. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  69551. */
  69552. alphaBlendingMode: number;
  69553. /**
  69554. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  69555. * Alpha test will not mix with the background color in case of transparency.
  69556. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  69557. */
  69558. alphaTest: boolean;
  69559. /**
  69560. * Define a mask to restrict the layer to only some of the scene cameras.
  69561. */
  69562. layerMask: number;
  69563. /**
  69564. * Define the list of render target the layer is visible into.
  69565. */
  69566. renderTargetTextures: RenderTargetTexture[];
  69567. /**
  69568. * Define if the layer is only used in renderTarget or if it also
  69569. * renders in the main frame buffer of the canvas.
  69570. */
  69571. renderOnlyInRenderTargetTextures: boolean;
  69572. private _scene;
  69573. private _vertexBuffers;
  69574. private _indexBuffer;
  69575. private _effect;
  69576. private _alphaTestEffect;
  69577. /**
  69578. * An event triggered when the layer is disposed.
  69579. */
  69580. onDisposeObservable: Observable<Layer>;
  69581. private _onDisposeObserver;
  69582. /**
  69583. * Back compatibility with callback before the onDisposeObservable existed.
  69584. * The set callback will be triggered when the layer has been disposed.
  69585. */
  69586. onDispose: () => void;
  69587. /**
  69588. * An event triggered before rendering the scene
  69589. */
  69590. onBeforeRenderObservable: Observable<Layer>;
  69591. private _onBeforeRenderObserver;
  69592. /**
  69593. * Back compatibility with callback before the onBeforeRenderObservable existed.
  69594. * The set callback will be triggered just before rendering the layer.
  69595. */
  69596. onBeforeRender: () => void;
  69597. /**
  69598. * An event triggered after rendering the scene
  69599. */
  69600. onAfterRenderObservable: Observable<Layer>;
  69601. private _onAfterRenderObserver;
  69602. /**
  69603. * Back compatibility with callback before the onAfterRenderObservable existed.
  69604. * The set callback will be triggered just after rendering the layer.
  69605. */
  69606. onAfterRender: () => void;
  69607. /**
  69608. * Instantiates a new layer.
  69609. * This represents a full screen 2d layer.
  69610. * This can be useful to display a picture in the background of your scene for instance.
  69611. * @see https://www.babylonjs-playground.com/#08A2BS#1
  69612. * @param name Define the name of the layer in the scene
  69613. * @param imgUrl Define the url of the texture to display in the layer
  69614. * @param scene Define the scene the layer belongs to
  69615. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  69616. * @param color Defines a color for the layer
  69617. */
  69618. constructor(
  69619. /**
  69620. * Define the name of the layer.
  69621. */
  69622. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  69623. private _createIndexBuffer;
  69624. /** @hidden */
  69625. _rebuild(): void;
  69626. /**
  69627. * Renders the layer in the scene.
  69628. */
  69629. render(): void;
  69630. /**
  69631. * Disposes and releases the associated ressources.
  69632. */
  69633. dispose(): void;
  69634. }
  69635. }
  69636. declare module BABYLON {
  69637. interface AbstractScene {
  69638. /**
  69639. * The list of procedural textures added to the scene
  69640. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69641. */
  69642. proceduralTextures: Array<ProceduralTexture>;
  69643. }
  69644. /**
  69645. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  69646. * in a given scene.
  69647. */
  69648. export class ProceduralTextureSceneComponent implements ISceneComponent {
  69649. /**
  69650. * The component name helpfull to identify the component in the list of scene components.
  69651. */
  69652. readonly name: string;
  69653. /**
  69654. * The scene the component belongs to.
  69655. */
  69656. scene: Scene;
  69657. /**
  69658. * Creates a new instance of the component for the given scene
  69659. * @param scene Defines the scene to register the component in
  69660. */
  69661. constructor(scene: Scene);
  69662. /**
  69663. * Registers the component in a given scene
  69664. */
  69665. register(): void;
  69666. /**
  69667. * Rebuilds the elements related to this component in case of
  69668. * context lost for instance.
  69669. */
  69670. rebuild(): void;
  69671. /**
  69672. * Disposes the component and the associated ressources.
  69673. */
  69674. dispose(): void;
  69675. private _beforeClear;
  69676. }
  69677. }
  69678. declare module BABYLON {
  69679. /** @hidden */
  69680. export var proceduralVertexShader: {
  69681. name: string;
  69682. shader: string;
  69683. };
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * 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.
  69688. * This is the base class of any Procedural texture and contains most of the shareable code.
  69689. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69690. */
  69691. export class ProceduralTexture extends Texture {
  69692. isCube: boolean;
  69693. /**
  69694. * Define if the texture is enabled or not (disabled texture will not render)
  69695. */
  69696. isEnabled: boolean;
  69697. /**
  69698. * Define if the texture must be cleared before rendering (default is true)
  69699. */
  69700. autoClear: boolean;
  69701. /**
  69702. * Callback called when the texture is generated
  69703. */
  69704. onGenerated: () => void;
  69705. /**
  69706. * Event raised when the texture is generated
  69707. */
  69708. onGeneratedObservable: Observable<ProceduralTexture>;
  69709. /** @hidden */
  69710. _generateMipMaps: boolean;
  69711. /** @hidden **/
  69712. _effect: Effect;
  69713. /** @hidden */
  69714. _textures: {
  69715. [key: string]: Texture;
  69716. };
  69717. private _size;
  69718. private _currentRefreshId;
  69719. private _refreshRate;
  69720. private _vertexBuffers;
  69721. private _indexBuffer;
  69722. private _uniforms;
  69723. private _samplers;
  69724. private _fragment;
  69725. private _floats;
  69726. private _ints;
  69727. private _floatsArrays;
  69728. private _colors3;
  69729. private _colors4;
  69730. private _vectors2;
  69731. private _vectors3;
  69732. private _matrices;
  69733. private _fallbackTexture;
  69734. private _fallbackTextureUsed;
  69735. private _engine;
  69736. private _cachedDefines;
  69737. private _contentUpdateId;
  69738. private _contentData;
  69739. /**
  69740. * Instantiates a new procedural texture.
  69741. * 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.
  69742. * This is the base class of any Procedural texture and contains most of the shareable code.
  69743. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69744. * @param name Define the name of the texture
  69745. * @param size Define the size of the texture to create
  69746. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  69747. * @param scene Define the scene the texture belongs to
  69748. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69749. * @param generateMipMaps Define if the texture should creates mip maps or not
  69750. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  69751. */
  69752. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  69753. /**
  69754. * The effect that is created when initializing the post process.
  69755. * @returns The created effect corrisponding the the postprocess.
  69756. */
  69757. getEffect(): Effect;
  69758. /**
  69759. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  69760. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  69761. */
  69762. getContent(): Nullable<ArrayBufferView>;
  69763. private _createIndexBuffer;
  69764. /** @hidden */
  69765. _rebuild(): void;
  69766. /**
  69767. * Resets the texture in order to recreate its associated resources.
  69768. * This can be called in case of context loss
  69769. */
  69770. reset(): void;
  69771. protected _getDefines(): string;
  69772. /**
  69773. * Is the texture ready to be used ? (rendered at least once)
  69774. * @returns true if ready, otherwise, false.
  69775. */
  69776. isReady(): boolean;
  69777. /**
  69778. * Resets the refresh counter of the texture and start bak from scratch.
  69779. * Could be useful to regenerate the texture if it is setup to render only once.
  69780. */
  69781. resetRefreshCounter(): void;
  69782. /**
  69783. * Set the fragment shader to use in order to render the texture.
  69784. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  69785. */
  69786. setFragment(fragment: any): void;
  69787. /**
  69788. * Define the refresh rate of the texture or the rendering frequency.
  69789. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  69790. */
  69791. refreshRate: number;
  69792. /** @hidden */
  69793. _shouldRender(): boolean;
  69794. /**
  69795. * Get the size the texture is rendering at.
  69796. * @returns the size (texture is always squared)
  69797. */
  69798. getRenderSize(): number;
  69799. /**
  69800. * Resize the texture to new value.
  69801. * @param size Define the new size the texture should have
  69802. * @param generateMipMaps Define whether the new texture should create mip maps
  69803. */
  69804. resize(size: number, generateMipMaps: boolean): void;
  69805. private _checkUniform;
  69806. /**
  69807. * Set a texture in the shader program used to render.
  69808. * @param name Define the name of the uniform samplers as defined in the shader
  69809. * @param texture Define the texture to bind to this sampler
  69810. * @return the texture itself allowing "fluent" like uniform updates
  69811. */
  69812. setTexture(name: string, texture: Texture): ProceduralTexture;
  69813. /**
  69814. * Set a float in the shader.
  69815. * @param name Define the name of the uniform as defined in the shader
  69816. * @param value Define the value to give to the uniform
  69817. * @return the texture itself allowing "fluent" like uniform updates
  69818. */
  69819. setFloat(name: string, value: number): ProceduralTexture;
  69820. /**
  69821. * Set a int in the shader.
  69822. * @param name Define the name of the uniform as defined in the shader
  69823. * @param value Define the value to give to the uniform
  69824. * @return the texture itself allowing "fluent" like uniform updates
  69825. */
  69826. setInt(name: string, value: number): ProceduralTexture;
  69827. /**
  69828. * Set an array of floats in the shader.
  69829. * @param name Define the name of the uniform as defined in the shader
  69830. * @param value Define the value to give to the uniform
  69831. * @return the texture itself allowing "fluent" like uniform updates
  69832. */
  69833. setFloats(name: string, value: number[]): ProceduralTexture;
  69834. /**
  69835. * Set a vec3 in the shader from a Color3.
  69836. * @param name Define the name of the uniform as defined in the shader
  69837. * @param value Define the value to give to the uniform
  69838. * @return the texture itself allowing "fluent" like uniform updates
  69839. */
  69840. setColor3(name: string, value: Color3): ProceduralTexture;
  69841. /**
  69842. * Set a vec4 in the shader from a Color4.
  69843. * @param name Define the name of the uniform as defined in the shader
  69844. * @param value Define the value to give to the uniform
  69845. * @return the texture itself allowing "fluent" like uniform updates
  69846. */
  69847. setColor4(name: string, value: Color4): ProceduralTexture;
  69848. /**
  69849. * Set a vec2 in the shader from a Vector2.
  69850. * @param name Define the name of the uniform as defined in the shader
  69851. * @param value Define the value to give to the uniform
  69852. * @return the texture itself allowing "fluent" like uniform updates
  69853. */
  69854. setVector2(name: string, value: Vector2): ProceduralTexture;
  69855. /**
  69856. * Set a vec3 in the shader from a Vector3.
  69857. * @param name Define the name of the uniform as defined in the shader
  69858. * @param value Define the value to give to the uniform
  69859. * @return the texture itself allowing "fluent" like uniform updates
  69860. */
  69861. setVector3(name: string, value: Vector3): ProceduralTexture;
  69862. /**
  69863. * Set a mat4 in the shader from a MAtrix.
  69864. * @param name Define the name of the uniform as defined in the shader
  69865. * @param value Define the value to give to the uniform
  69866. * @return the texture itself allowing "fluent" like uniform updates
  69867. */
  69868. setMatrix(name: string, value: Matrix): ProceduralTexture;
  69869. /**
  69870. * Render the texture to its associated render target.
  69871. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69872. */
  69873. render(useCameraPostProcess?: boolean): void;
  69874. /**
  69875. * Clone the texture.
  69876. * @returns the cloned texture
  69877. */
  69878. clone(): ProceduralTexture;
  69879. /**
  69880. * Dispose the texture and release its asoociated resources.
  69881. */
  69882. dispose(): void;
  69883. }
  69884. }
  69885. declare module BABYLON {
  69886. /**
  69887. * This represents the base class for particle system in Babylon.
  69888. * 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.
  69889. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  69890. * @example https://doc.babylonjs.com/babylon101/particles
  69891. */
  69892. export class BaseParticleSystem {
  69893. /**
  69894. * Source color is added to the destination color without alpha affecting the result
  69895. */
  69896. static BLENDMODE_ONEONE: number;
  69897. /**
  69898. * Blend current color and particle color using particle’s alpha
  69899. */
  69900. static BLENDMODE_STANDARD: number;
  69901. /**
  69902. * Add current color and particle color multiplied by particle’s alpha
  69903. */
  69904. static BLENDMODE_ADD: number;
  69905. /**
  69906. * Multiply current color with particle color
  69907. */
  69908. static BLENDMODE_MULTIPLY: number;
  69909. /**
  69910. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  69911. */
  69912. static BLENDMODE_MULTIPLYADD: number;
  69913. /**
  69914. * List of animations used by the particle system.
  69915. */
  69916. animations: Animation[];
  69917. /**
  69918. * The id of the Particle system.
  69919. */
  69920. id: string;
  69921. /**
  69922. * The friendly name of the Particle system.
  69923. */
  69924. name: string;
  69925. /**
  69926. * The rendering group used by the Particle system to chose when to render.
  69927. */
  69928. renderingGroupId: number;
  69929. /**
  69930. * The emitter represents the Mesh or position we are attaching the particle system to.
  69931. */
  69932. emitter: Nullable<AbstractMesh | Vector3>;
  69933. /**
  69934. * The maximum number of particles to emit per frame
  69935. */
  69936. emitRate: number;
  69937. /**
  69938. * If you want to launch only a few particles at once, that can be done, as well.
  69939. */
  69940. manualEmitCount: number;
  69941. /**
  69942. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  69943. */
  69944. updateSpeed: number;
  69945. /**
  69946. * The amount of time the particle system is running (depends of the overall update speed).
  69947. */
  69948. targetStopDuration: number;
  69949. /**
  69950. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  69951. */
  69952. disposeOnStop: boolean;
  69953. /**
  69954. * Minimum power of emitting particles.
  69955. */
  69956. minEmitPower: number;
  69957. /**
  69958. * Maximum power of emitting particles.
  69959. */
  69960. maxEmitPower: number;
  69961. /**
  69962. * Minimum life time of emitting particles.
  69963. */
  69964. minLifeTime: number;
  69965. /**
  69966. * Maximum life time of emitting particles.
  69967. */
  69968. maxLifeTime: number;
  69969. /**
  69970. * Minimum Size of emitting particles.
  69971. */
  69972. minSize: number;
  69973. /**
  69974. * Maximum Size of emitting particles.
  69975. */
  69976. maxSize: number;
  69977. /**
  69978. * Minimum scale of emitting particles on X axis.
  69979. */
  69980. minScaleX: number;
  69981. /**
  69982. * Maximum scale of emitting particles on X axis.
  69983. */
  69984. maxScaleX: number;
  69985. /**
  69986. * Minimum scale of emitting particles on Y axis.
  69987. */
  69988. minScaleY: number;
  69989. /**
  69990. * Maximum scale of emitting particles on Y axis.
  69991. */
  69992. maxScaleY: number;
  69993. /**
  69994. * Gets or sets the minimal initial rotation in radians.
  69995. */
  69996. minInitialRotation: number;
  69997. /**
  69998. * Gets or sets the maximal initial rotation in radians.
  69999. */
  70000. maxInitialRotation: number;
  70001. /**
  70002. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70003. */
  70004. minAngularSpeed: number;
  70005. /**
  70006. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70007. */
  70008. maxAngularSpeed: number;
  70009. /**
  70010. * The texture used to render each particle. (this can be a spritesheet)
  70011. */
  70012. particleTexture: Nullable<Texture>;
  70013. /**
  70014. * The layer mask we are rendering the particles through.
  70015. */
  70016. layerMask: number;
  70017. /**
  70018. * This can help using your own shader to render the particle system.
  70019. * The according effect will be created
  70020. */
  70021. customShader: any;
  70022. /**
  70023. * By default particle system starts as soon as they are created. This prevents the
  70024. * automatic start to happen and let you decide when to start emitting particles.
  70025. */
  70026. preventAutoStart: boolean;
  70027. private _noiseTexture;
  70028. /**
  70029. * Gets or sets a texture used to add random noise to particle positions
  70030. */
  70031. noiseTexture: Nullable<ProceduralTexture>;
  70032. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70033. noiseStrength: Vector3;
  70034. /**
  70035. * Callback triggered when the particle animation is ending.
  70036. */
  70037. onAnimationEnd: Nullable<() => void>;
  70038. /**
  70039. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70040. */
  70041. blendMode: number;
  70042. /**
  70043. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70044. * to override the particles.
  70045. */
  70046. forceDepthWrite: boolean;
  70047. /** 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 */
  70048. preWarmCycles: number;
  70049. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70050. preWarmStepOffset: number;
  70051. /**
  70052. * 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)
  70053. */
  70054. spriteCellChangeSpeed: number;
  70055. /**
  70056. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70057. */
  70058. startSpriteCellID: number;
  70059. /**
  70060. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70061. */
  70062. endSpriteCellID: number;
  70063. /**
  70064. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70065. */
  70066. spriteCellWidth: number;
  70067. /**
  70068. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70069. */
  70070. spriteCellHeight: number;
  70071. /**
  70072. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70073. */
  70074. spriteRandomStartCell: boolean;
  70075. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70076. translationPivot: Vector2;
  70077. /** @hidden */
  70078. protected _isAnimationSheetEnabled: boolean;
  70079. /**
  70080. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70081. */
  70082. beginAnimationOnStart: boolean;
  70083. /**
  70084. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70085. */
  70086. beginAnimationFrom: number;
  70087. /**
  70088. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70089. */
  70090. beginAnimationTo: number;
  70091. /**
  70092. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70093. */
  70094. beginAnimationLoop: boolean;
  70095. /**
  70096. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70097. */
  70098. isAnimationSheetEnabled: boolean;
  70099. /**
  70100. * Get hosting scene
  70101. * @returns the scene
  70102. */
  70103. getScene(): Scene;
  70104. /**
  70105. * You can use gravity if you want to give an orientation to your particles.
  70106. */
  70107. gravity: Vector3;
  70108. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70109. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70110. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70111. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70112. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70113. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70114. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70115. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70116. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70117. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70118. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70119. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70120. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70121. /**
  70122. * Defines the delay in milliseconds before starting the system (0 by default)
  70123. */
  70124. startDelay: number;
  70125. /**
  70126. * Gets the current list of drag gradients.
  70127. * You must use addDragGradient and removeDragGradient to udpate this list
  70128. * @returns the list of drag gradients
  70129. */
  70130. getDragGradients(): Nullable<Array<FactorGradient>>;
  70131. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70132. limitVelocityDamping: number;
  70133. /**
  70134. * Gets the current list of limit velocity gradients.
  70135. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70136. * @returns the list of limit velocity gradients
  70137. */
  70138. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70139. /**
  70140. * Gets the current list of color gradients.
  70141. * You must use addColorGradient and removeColorGradient to udpate this list
  70142. * @returns the list of color gradients
  70143. */
  70144. getColorGradients(): Nullable<Array<ColorGradient>>;
  70145. /**
  70146. * Gets the current list of size gradients.
  70147. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70148. * @returns the list of size gradients
  70149. */
  70150. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70151. /**
  70152. * Gets the current list of color remap gradients.
  70153. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70154. * @returns the list of color remap gradients
  70155. */
  70156. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70157. /**
  70158. * Gets the current list of alpha remap gradients.
  70159. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70160. * @returns the list of alpha remap gradients
  70161. */
  70162. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70163. /**
  70164. * Gets the current list of life time gradients.
  70165. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70166. * @returns the list of life time gradients
  70167. */
  70168. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70169. /**
  70170. * Gets the current list of angular speed gradients.
  70171. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70172. * @returns the list of angular speed gradients
  70173. */
  70174. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70175. /**
  70176. * Gets the current list of velocity gradients.
  70177. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70178. * @returns the list of velocity gradients
  70179. */
  70180. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70181. /**
  70182. * Gets the current list of start size gradients.
  70183. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  70184. * @returns the list of start size gradients
  70185. */
  70186. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  70187. /**
  70188. * Gets the current list of emit rate gradients.
  70189. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  70190. * @returns the list of emit rate gradients
  70191. */
  70192. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  70193. /**
  70194. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70195. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70196. */
  70197. direction1: Vector3;
  70198. /**
  70199. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70201. */
  70202. direction2: Vector3;
  70203. /**
  70204. * 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.
  70205. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70206. */
  70207. minEmitBox: Vector3;
  70208. /**
  70209. * 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.
  70210. * This only works when particleEmitterTyps is a BoxParticleEmitter
  70211. */
  70212. maxEmitBox: Vector3;
  70213. /**
  70214. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70215. */
  70216. color1: Color4;
  70217. /**
  70218. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  70219. */
  70220. color2: Color4;
  70221. /**
  70222. * Color the particle will have at the end of its lifetime
  70223. */
  70224. colorDead: Color4;
  70225. /**
  70226. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  70227. */
  70228. textureMask: Color4;
  70229. /**
  70230. * The particle emitter type defines the emitter used by the particle system.
  70231. * It can be for example box, sphere, or cone...
  70232. */
  70233. particleEmitterType: IParticleEmitterType;
  70234. /** @hidden */
  70235. _isSubEmitter: boolean;
  70236. /**
  70237. * Gets or sets the billboard mode to use when isBillboardBased = true.
  70238. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  70239. */
  70240. billboardMode: number;
  70241. protected _isBillboardBased: boolean;
  70242. /**
  70243. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  70244. */
  70245. isBillboardBased: boolean;
  70246. /**
  70247. * The scene the particle system belongs to.
  70248. */
  70249. protected _scene: Scene;
  70250. /**
  70251. * Local cache of defines for image processing.
  70252. */
  70253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  70254. /**
  70255. * Default configuration related to image processing available in the standard Material.
  70256. */
  70257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  70258. /**
  70259. * Gets the image processing configuration used either in this material.
  70260. */
  70261. /**
  70262. * Sets the Default image processing configuration used either in the this material.
  70263. *
  70264. * If sets to null, the scene one is in use.
  70265. */
  70266. imageProcessingConfiguration: ImageProcessingConfiguration;
  70267. /**
  70268. * Attaches a new image processing configuration to the Standard Material.
  70269. * @param configuration
  70270. */
  70271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  70272. /** @hidden */
  70273. protected _reset(): void;
  70274. /** @hidden */
  70275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  70276. /**
  70277. * Instantiates a particle system.
  70278. * 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.
  70279. * @param name The name of the particle system
  70280. */
  70281. constructor(name: string);
  70282. /**
  70283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  70284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  70285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  70286. * @returns the emitter
  70287. */
  70288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  70289. /**
  70290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  70291. * @param radius The radius of the hemisphere to emit from
  70292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  70293. * @returns the emitter
  70294. */
  70295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  70296. /**
  70297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  70298. * @param radius The radius of the sphere to emit from
  70299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  70300. * @returns the emitter
  70301. */
  70302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  70303. /**
  70304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  70305. * @param radius The radius of the sphere to emit from
  70306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  70307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  70308. * @returns the emitter
  70309. */
  70310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  70311. /**
  70312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  70313. * @param radius The radius of the emission cylinder
  70314. * @param height The height of the emission cylinder
  70315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  70316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  70317. * @returns the emitter
  70318. */
  70319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  70320. /**
  70321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  70322. * @param radius The radius of the cylinder to emit from
  70323. * @param height The height of the emission cylinder
  70324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  70326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  70327. * @returns the emitter
  70328. */
  70329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  70330. /**
  70331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  70332. * @param radius The radius of the cone to emit from
  70333. * @param angle The base angle of the cone
  70334. * @returns the emitter
  70335. */
  70336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  70337. /**
  70338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  70339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  70340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  70341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  70342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  70343. * @returns the emitter
  70344. */
  70345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  70346. }
  70347. }
  70348. declare module BABYLON {
  70349. /**
  70350. * Type of sub emitter
  70351. */
  70352. export enum SubEmitterType {
  70353. /**
  70354. * Attached to the particle over it's lifetime
  70355. */
  70356. ATTACHED = 0,
  70357. /**
  70358. * Created when the particle dies
  70359. */
  70360. END = 1
  70361. }
  70362. /**
  70363. * Sub emitter class used to emit particles from an existing particle
  70364. */
  70365. export class SubEmitter {
  70366. /**
  70367. * the particle system to be used by the sub emitter
  70368. */
  70369. particleSystem: ParticleSystem;
  70370. /**
  70371. * Type of the submitter (Default: END)
  70372. */
  70373. type: SubEmitterType;
  70374. /**
  70375. * 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)
  70376. * Note: This only is supported when using an emitter of type Mesh
  70377. */
  70378. inheritDirection: boolean;
  70379. /**
  70380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  70381. */
  70382. inheritedVelocityAmount: number;
  70383. /**
  70384. * Creates a sub emitter
  70385. * @param particleSystem the particle system to be used by the sub emitter
  70386. */
  70387. constructor(
  70388. /**
  70389. * the particle system to be used by the sub emitter
  70390. */
  70391. particleSystem: ParticleSystem);
  70392. /**
  70393. * Clones the sub emitter
  70394. * @returns the cloned sub emitter
  70395. */
  70396. clone(): SubEmitter;
  70397. /**
  70398. * Serialize current object to a JSON object
  70399. * @returns the serialized object
  70400. */
  70401. serialize(): any;
  70402. /** @hidden */
  70403. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  70404. /**
  70405. * Creates a new SubEmitter from a serialized JSON version
  70406. * @param serializationObject defines the JSON object to read from
  70407. * @param scene defines the hosting scene
  70408. * @param rootUrl defines the rootUrl for data loading
  70409. * @returns a new SubEmitter
  70410. */
  70411. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  70412. /** Release associated resources */
  70413. dispose(): void;
  70414. }
  70415. }
  70416. declare module BABYLON {
  70417. /** @hidden */
  70418. export var clipPlaneFragmentDeclaration: {
  70419. name: string;
  70420. shader: string;
  70421. };
  70422. }
  70423. declare module BABYLON {
  70424. /** @hidden */
  70425. export var imageProcessingDeclaration: {
  70426. name: string;
  70427. shader: string;
  70428. };
  70429. }
  70430. declare module BABYLON {
  70431. /** @hidden */
  70432. export var imageProcessingFunctions: {
  70433. name: string;
  70434. shader: string;
  70435. };
  70436. }
  70437. declare module BABYLON {
  70438. /** @hidden */
  70439. export var clipPlaneFragment: {
  70440. name: string;
  70441. shader: string;
  70442. };
  70443. }
  70444. declare module BABYLON {
  70445. /** @hidden */
  70446. export var particlesPixelShader: {
  70447. name: string;
  70448. shader: string;
  70449. };
  70450. }
  70451. declare module BABYLON {
  70452. /** @hidden */
  70453. export var clipPlaneVertexDeclaration: {
  70454. name: string;
  70455. shader: string;
  70456. };
  70457. }
  70458. declare module BABYLON {
  70459. /** @hidden */
  70460. export var clipPlaneVertex: {
  70461. name: string;
  70462. shader: string;
  70463. };
  70464. }
  70465. declare module BABYLON {
  70466. /** @hidden */
  70467. export var particlesVertexShader: {
  70468. name: string;
  70469. shader: string;
  70470. };
  70471. }
  70472. declare module BABYLON {
  70473. /**
  70474. * This represents a particle system in Babylon.
  70475. * 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.
  70476. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70477. * @example https://doc.babylonjs.com/babylon101/particles
  70478. */
  70479. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  70480. /**
  70481. * Billboard mode will only apply to Y axis
  70482. */
  70483. static readonly BILLBOARDMODE_Y: number;
  70484. /**
  70485. * Billboard mode will apply to all axes
  70486. */
  70487. static readonly BILLBOARDMODE_ALL: number;
  70488. /**
  70489. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70490. */
  70491. static readonly BILLBOARDMODE_STRETCHED: number;
  70492. /**
  70493. * This function can be defined to provide custom update for active particles.
  70494. * This function will be called instead of regular update (age, position, color, etc.).
  70495. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  70496. */
  70497. updateFunction: (particles: Particle[]) => void;
  70498. private _emitterWorldMatrix;
  70499. /**
  70500. * This function can be defined to specify initial direction for every new particle.
  70501. * It by default use the emitterType defined function
  70502. */
  70503. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  70504. /**
  70505. * This function can be defined to specify initial position for every new particle.
  70506. * It by default use the emitterType defined function
  70507. */
  70508. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  70509. /**
  70510. * @hidden
  70511. */
  70512. _inheritedVelocityOffset: Vector3;
  70513. /**
  70514. * An event triggered when the system is disposed
  70515. */
  70516. onDisposeObservable: Observable<ParticleSystem>;
  70517. private _onDisposeObserver;
  70518. /**
  70519. * Sets a callback that will be triggered when the system is disposed
  70520. */
  70521. onDispose: () => void;
  70522. private _particles;
  70523. private _epsilon;
  70524. private _capacity;
  70525. private _stockParticles;
  70526. private _newPartsExcess;
  70527. private _vertexData;
  70528. private _vertexBuffer;
  70529. private _vertexBuffers;
  70530. private _spriteBuffer;
  70531. private _indexBuffer;
  70532. private _effect;
  70533. private _customEffect;
  70534. private _cachedDefines;
  70535. private _scaledColorStep;
  70536. private _colorDiff;
  70537. private _scaledDirection;
  70538. private _scaledGravity;
  70539. private _currentRenderId;
  70540. private _alive;
  70541. private _useInstancing;
  70542. private _started;
  70543. private _stopped;
  70544. private _actualFrame;
  70545. private _scaledUpdateSpeed;
  70546. private _vertexBufferSize;
  70547. /** @hidden */
  70548. _currentEmitRateGradient: Nullable<FactorGradient>;
  70549. /** @hidden */
  70550. _currentEmitRate1: number;
  70551. /** @hidden */
  70552. _currentEmitRate2: number;
  70553. /** @hidden */
  70554. _currentStartSizeGradient: Nullable<FactorGradient>;
  70555. /** @hidden */
  70556. _currentStartSize1: number;
  70557. /** @hidden */
  70558. _currentStartSize2: number;
  70559. private readonly _rawTextureWidth;
  70560. private _rampGradientsTexture;
  70561. private _useRampGradients;
  70562. /** Gets or sets a boolean indicating that ramp gradients must be used
  70563. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70564. */
  70565. useRampGradients: boolean;
  70566. /**
  70567. * 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.
  70568. * 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: [])
  70569. */
  70570. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  70571. private _subEmitters;
  70572. /**
  70573. * @hidden
  70574. * If the particle systems emitter should be disposed when the particle system is disposed
  70575. */
  70576. _disposeEmitterOnDispose: boolean;
  70577. /**
  70578. * The current active Sub-systems, this property is used by the root particle system only.
  70579. */
  70580. activeSubSystems: Array<ParticleSystem>;
  70581. private _rootParticleSystem;
  70582. /**
  70583. * Gets the current list of active particles
  70584. */
  70585. readonly particles: Particle[];
  70586. /**
  70587. * Returns the string "ParticleSystem"
  70588. * @returns a string containing the class name
  70589. */
  70590. getClassName(): string;
  70591. /**
  70592. * Instantiates a particle system.
  70593. * 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.
  70594. * @param name The name of the particle system
  70595. * @param capacity The max number of particles alive at the same time
  70596. * @param scene The scene the particle system belongs to
  70597. * @param customEffect a custom effect used to change the way particles are rendered by default
  70598. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70599. * @param epsilon Offset used to render the particles
  70600. */
  70601. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  70602. private _addFactorGradient;
  70603. private _removeFactorGradient;
  70604. /**
  70605. * Adds a new life time gradient
  70606. * @param gradient defines the gradient to use (between 0 and 1)
  70607. * @param factor defines the life time factor to affect to the specified gradient
  70608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70609. * @returns the current particle system
  70610. */
  70611. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70612. /**
  70613. * Remove a specific life time gradient
  70614. * @param gradient defines the gradient to remove
  70615. * @returns the current particle system
  70616. */
  70617. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70618. /**
  70619. * Adds a new size gradient
  70620. * @param gradient defines the gradient to use (between 0 and 1)
  70621. * @param factor defines the size factor to affect to the specified gradient
  70622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70623. * @returns the current particle system
  70624. */
  70625. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70626. /**
  70627. * Remove a specific size gradient
  70628. * @param gradient defines the gradient to remove
  70629. * @returns the current particle system
  70630. */
  70631. removeSizeGradient(gradient: number): IParticleSystem;
  70632. /**
  70633. * Adds a new color remap gradient
  70634. * @param gradient defines the gradient to use (between 0 and 1)
  70635. * @param min defines the color remap minimal range
  70636. * @param max defines the color remap maximal range
  70637. * @returns the current particle system
  70638. */
  70639. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70640. /**
  70641. * Remove a specific color remap gradient
  70642. * @param gradient defines the gradient to remove
  70643. * @returns the current particle system
  70644. */
  70645. removeColorRemapGradient(gradient: number): IParticleSystem;
  70646. /**
  70647. * Adds a new alpha remap gradient
  70648. * @param gradient defines the gradient to use (between 0 and 1)
  70649. * @param min defines the alpha remap minimal range
  70650. * @param max defines the alpha remap maximal range
  70651. * @returns the current particle system
  70652. */
  70653. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70654. /**
  70655. * Remove a specific alpha remap gradient
  70656. * @param gradient defines the gradient to remove
  70657. * @returns the current particle system
  70658. */
  70659. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  70660. /**
  70661. * Adds a new angular speed gradient
  70662. * @param gradient defines the gradient to use (between 0 and 1)
  70663. * @param factor defines the angular speed to affect to the specified gradient
  70664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70665. * @returns the current particle system
  70666. */
  70667. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70668. /**
  70669. * Remove a specific angular speed gradient
  70670. * @param gradient defines the gradient to remove
  70671. * @returns the current particle system
  70672. */
  70673. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  70674. /**
  70675. * Adds a new velocity gradient
  70676. * @param gradient defines the gradient to use (between 0 and 1)
  70677. * @param factor defines the velocity to affect to the specified gradient
  70678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70679. * @returns the current particle system
  70680. */
  70681. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70682. /**
  70683. * Remove a specific velocity gradient
  70684. * @param gradient defines the gradient to remove
  70685. * @returns the current particle system
  70686. */
  70687. removeVelocityGradient(gradient: number): IParticleSystem;
  70688. /**
  70689. * Adds a new limit velocity gradient
  70690. * @param gradient defines the gradient to use (between 0 and 1)
  70691. * @param factor defines the limit velocity value to affect to the specified gradient
  70692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70693. * @returns the current particle system
  70694. */
  70695. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70696. /**
  70697. * Remove a specific limit velocity gradient
  70698. * @param gradient defines the gradient to remove
  70699. * @returns the current particle system
  70700. */
  70701. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  70702. /**
  70703. * Adds a new drag gradient
  70704. * @param gradient defines the gradient to use (between 0 and 1)
  70705. * @param factor defines the drag value to affect to the specified gradient
  70706. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70707. * @returns the current particle system
  70708. */
  70709. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70710. /**
  70711. * Remove a specific drag gradient
  70712. * @param gradient defines the gradient to remove
  70713. * @returns the current particle system
  70714. */
  70715. removeDragGradient(gradient: number): IParticleSystem;
  70716. /**
  70717. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  70718. * @param gradient defines the gradient to use (between 0 and 1)
  70719. * @param factor defines the emit rate value to affect to the specified gradient
  70720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70721. * @returns the current particle system
  70722. */
  70723. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70724. /**
  70725. * Remove a specific emit rate gradient
  70726. * @param gradient defines the gradient to remove
  70727. * @returns the current particle system
  70728. */
  70729. removeEmitRateGradient(gradient: number): IParticleSystem;
  70730. /**
  70731. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  70732. * @param gradient defines the gradient to use (between 0 and 1)
  70733. * @param factor defines the start size value to affect to the specified gradient
  70734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70735. * @returns the current particle system
  70736. */
  70737. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70738. /**
  70739. * Remove a specific start size gradient
  70740. * @param gradient defines the gradient to remove
  70741. * @returns the current particle system
  70742. */
  70743. removeStartSizeGradient(gradient: number): IParticleSystem;
  70744. private _createRampGradientTexture;
  70745. /**
  70746. * Gets the current list of ramp gradients.
  70747. * You must use addRampGradient and removeRampGradient to udpate this list
  70748. * @returns the list of ramp gradients
  70749. */
  70750. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70751. /**
  70752. * Adds a new ramp gradient used to remap particle colors
  70753. * @param gradient defines the gradient to use (between 0 and 1)
  70754. * @param color defines the color to affect to the specified gradient
  70755. * @returns the current particle system
  70756. */
  70757. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  70758. /**
  70759. * Remove a specific ramp gradient
  70760. * @param gradient defines the gradient to remove
  70761. * @returns the current particle system
  70762. */
  70763. removeRampGradient(gradient: number): ParticleSystem;
  70764. /**
  70765. * Adds a new color gradient
  70766. * @param gradient defines the gradient to use (between 0 and 1)
  70767. * @param color1 defines the color to affect to the specified gradient
  70768. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70769. * @returns this particle system
  70770. */
  70771. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  70772. /**
  70773. * Remove a specific color gradient
  70774. * @param gradient defines the gradient to remove
  70775. * @returns this particle system
  70776. */
  70777. removeColorGradient(gradient: number): IParticleSystem;
  70778. private _fetchR;
  70779. protected _reset(): void;
  70780. private _resetEffect;
  70781. private _createVertexBuffers;
  70782. private _createIndexBuffer;
  70783. /**
  70784. * Gets the maximum number of particles active at the same time.
  70785. * @returns The max number of active particles.
  70786. */
  70787. getCapacity(): number;
  70788. /**
  70789. * Gets whether there are still active particles in the system.
  70790. * @returns True if it is alive, otherwise false.
  70791. */
  70792. isAlive(): boolean;
  70793. /**
  70794. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70795. * @returns True if it has been started, otherwise false.
  70796. */
  70797. isStarted(): boolean;
  70798. private _prepareSubEmitterInternalArray;
  70799. /**
  70800. * Starts the particle system and begins to emit
  70801. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70802. */
  70803. start(delay?: number): void;
  70804. /**
  70805. * Stops the particle system.
  70806. * @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.
  70807. */
  70808. stop(stopSubEmitters?: boolean): void;
  70809. /**
  70810. * Remove all active particles
  70811. */
  70812. reset(): void;
  70813. /**
  70814. * @hidden (for internal use only)
  70815. */
  70816. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  70817. /**
  70818. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  70819. * Its lifetime will start back at 0.
  70820. */
  70821. recycleParticle: (particle: Particle) => void;
  70822. private _stopSubEmitters;
  70823. private _createParticle;
  70824. private _removeFromRoot;
  70825. private _emitFromParticle;
  70826. private _update;
  70827. /** @hidden */
  70828. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  70829. /** @hidden */
  70830. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  70831. /** @hidden */
  70832. private _getEffect;
  70833. /**
  70834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70835. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  70836. */
  70837. animate(preWarmOnly?: boolean): void;
  70838. private _appendParticleVertices;
  70839. /**
  70840. * Rebuilds the particle system.
  70841. */
  70842. rebuild(): void;
  70843. /**
  70844. * Is this system ready to be used/rendered
  70845. * @return true if the system is ready
  70846. */
  70847. isReady(): boolean;
  70848. private _render;
  70849. /**
  70850. * Renders the particle system in its current state.
  70851. * @returns the current number of particles
  70852. */
  70853. render(): number;
  70854. /**
  70855. * Disposes the particle system and free the associated resources
  70856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70857. */
  70858. dispose(disposeTexture?: boolean): void;
  70859. /**
  70860. * Clones the particle system.
  70861. * @param name The name of the cloned object
  70862. * @param newEmitter The new emitter to use
  70863. * @returns the cloned particle system
  70864. */
  70865. clone(name: string, newEmitter: any): ParticleSystem;
  70866. /**
  70867. * Serializes the particle system to a JSON object.
  70868. * @returns the JSON object
  70869. */
  70870. serialize(): any;
  70871. /** @hidden */
  70872. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  70873. /** @hidden */
  70874. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  70875. /**
  70876. * Parses a JSON object to create a particle system.
  70877. * @param parsedParticleSystem The JSON object to parse
  70878. * @param scene The scene to create the particle system in
  70879. * @param rootUrl The root url to use to load external dependencies like texture
  70880. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70881. * @returns the Parsed particle system
  70882. */
  70883. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  70884. }
  70885. }
  70886. declare module BABYLON {
  70887. /**
  70888. * A particle represents one of the element emitted by a particle system.
  70889. * This is mainly define by its coordinates, direction, velocity and age.
  70890. */
  70891. export class Particle {
  70892. /**
  70893. * The particle system the particle belongs to.
  70894. */
  70895. particleSystem: ParticleSystem;
  70896. private static _Count;
  70897. /**
  70898. * Unique ID of the particle
  70899. */
  70900. id: number;
  70901. /**
  70902. * The world position of the particle in the scene.
  70903. */
  70904. position: Vector3;
  70905. /**
  70906. * The world direction of the particle in the scene.
  70907. */
  70908. direction: Vector3;
  70909. /**
  70910. * The color of the particle.
  70911. */
  70912. color: Color4;
  70913. /**
  70914. * The color change of the particle per step.
  70915. */
  70916. colorStep: Color4;
  70917. /**
  70918. * Defines how long will the life of the particle be.
  70919. */
  70920. lifeTime: number;
  70921. /**
  70922. * The current age of the particle.
  70923. */
  70924. age: number;
  70925. /**
  70926. * The current size of the particle.
  70927. */
  70928. size: number;
  70929. /**
  70930. * The current scale of the particle.
  70931. */
  70932. scale: Vector2;
  70933. /**
  70934. * The current angle of the particle.
  70935. */
  70936. angle: number;
  70937. /**
  70938. * Defines how fast is the angle changing.
  70939. */
  70940. angularSpeed: number;
  70941. /**
  70942. * Defines the cell index used by the particle to be rendered from a sprite.
  70943. */
  70944. cellIndex: number;
  70945. /**
  70946. * The information required to support color remapping
  70947. */
  70948. remapData: Vector4;
  70949. /** @hidden */
  70950. _randomCellOffset?: number;
  70951. /** @hidden */
  70952. _initialDirection: Nullable<Vector3>;
  70953. /** @hidden */
  70954. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  70955. /** @hidden */
  70956. _initialStartSpriteCellID: number;
  70957. /** @hidden */
  70958. _initialEndSpriteCellID: number;
  70959. /** @hidden */
  70960. _currentColorGradient: Nullable<ColorGradient>;
  70961. /** @hidden */
  70962. _currentColor1: Color4;
  70963. /** @hidden */
  70964. _currentColor2: Color4;
  70965. /** @hidden */
  70966. _currentSizeGradient: Nullable<FactorGradient>;
  70967. /** @hidden */
  70968. _currentSize1: number;
  70969. /** @hidden */
  70970. _currentSize2: number;
  70971. /** @hidden */
  70972. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  70973. /** @hidden */
  70974. _currentAngularSpeed1: number;
  70975. /** @hidden */
  70976. _currentAngularSpeed2: number;
  70977. /** @hidden */
  70978. _currentVelocityGradient: Nullable<FactorGradient>;
  70979. /** @hidden */
  70980. _currentVelocity1: number;
  70981. /** @hidden */
  70982. _currentVelocity2: number;
  70983. /** @hidden */
  70984. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  70985. /** @hidden */
  70986. _currentLimitVelocity1: number;
  70987. /** @hidden */
  70988. _currentLimitVelocity2: number;
  70989. /** @hidden */
  70990. _currentDragGradient: Nullable<FactorGradient>;
  70991. /** @hidden */
  70992. _currentDrag1: number;
  70993. /** @hidden */
  70994. _currentDrag2: number;
  70995. /** @hidden */
  70996. _randomNoiseCoordinates1: Vector3;
  70997. /** @hidden */
  70998. _randomNoiseCoordinates2: Vector3;
  70999. /**
  71000. * Creates a new instance Particle
  71001. * @param particleSystem the particle system the particle belongs to
  71002. */
  71003. constructor(
  71004. /**
  71005. * The particle system the particle belongs to.
  71006. */
  71007. particleSystem: ParticleSystem);
  71008. private updateCellInfoFromSystem;
  71009. /**
  71010. * Defines how the sprite cell index is updated for the particle
  71011. */
  71012. updateCellIndex(): void;
  71013. /** @hidden */
  71014. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71015. /** @hidden */
  71016. _inheritParticleInfoToSubEmitters(): void;
  71017. /** @hidden */
  71018. _reset(): void;
  71019. /**
  71020. * Copy the properties of particle to another one.
  71021. * @param other the particle to copy the information to.
  71022. */
  71023. copyTo(other: Particle): void;
  71024. }
  71025. }
  71026. declare module BABYLON {
  71027. /**
  71028. * Particle emitter represents a volume emitting particles.
  71029. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71030. */
  71031. export interface IParticleEmitterType {
  71032. /**
  71033. * Called by the particle System when the direction is computed for the created particle.
  71034. * @param worldMatrix is the world matrix of the particle system
  71035. * @param directionToUpdate is the direction vector to update with the result
  71036. * @param particle is the particle we are computed the direction for
  71037. */
  71038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71039. /**
  71040. * Called by the particle System when the position is computed for the created particle.
  71041. * @param worldMatrix is the world matrix of the particle system
  71042. * @param positionToUpdate is the position vector to update with the result
  71043. * @param particle is the particle we are computed the position for
  71044. */
  71045. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71046. /**
  71047. * Clones the current emitter and returns a copy of it
  71048. * @returns the new emitter
  71049. */
  71050. clone(): IParticleEmitterType;
  71051. /**
  71052. * Called by the GPUParticleSystem to setup the update shader
  71053. * @param effect defines the update shader
  71054. */
  71055. applyToShader(effect: Effect): void;
  71056. /**
  71057. * Returns a string to use to update the GPU particles update shader
  71058. * @returns the effect defines string
  71059. */
  71060. getEffectDefines(): string;
  71061. /**
  71062. * Returns a string representing the class name
  71063. * @returns a string containing the class name
  71064. */
  71065. getClassName(): string;
  71066. /**
  71067. * Serializes the particle system to a JSON object.
  71068. * @returns the JSON object
  71069. */
  71070. serialize(): any;
  71071. /**
  71072. * Parse properties from a JSON object
  71073. * @param serializationObject defines the JSON object
  71074. */
  71075. parse(serializationObject: any): void;
  71076. }
  71077. }
  71078. declare module BABYLON {
  71079. /**
  71080. * Particle emitter emitting particles from the inside of a box.
  71081. * It emits the particles randomly between 2 given directions.
  71082. */
  71083. export class BoxParticleEmitter implements IParticleEmitterType {
  71084. /**
  71085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71086. */
  71087. direction1: Vector3;
  71088. /**
  71089. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71090. */
  71091. direction2: Vector3;
  71092. /**
  71093. * 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.
  71094. */
  71095. minEmitBox: Vector3;
  71096. /**
  71097. * 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.
  71098. */
  71099. maxEmitBox: Vector3;
  71100. /**
  71101. * Creates a new instance BoxParticleEmitter
  71102. */
  71103. constructor();
  71104. /**
  71105. * Called by the particle System when the direction is computed for the created particle.
  71106. * @param worldMatrix is the world matrix of the particle system
  71107. * @param directionToUpdate is the direction vector to update with the result
  71108. * @param particle is the particle we are computed the direction for
  71109. */
  71110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71111. /**
  71112. * Called by the particle System when the position is computed for the created particle.
  71113. * @param worldMatrix is the world matrix of the particle system
  71114. * @param positionToUpdate is the position vector to update with the result
  71115. * @param particle is the particle we are computed the position for
  71116. */
  71117. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71118. /**
  71119. * Clones the current emitter and returns a copy of it
  71120. * @returns the new emitter
  71121. */
  71122. clone(): BoxParticleEmitter;
  71123. /**
  71124. * Called by the GPUParticleSystem to setup the update shader
  71125. * @param effect defines the update shader
  71126. */
  71127. applyToShader(effect: Effect): void;
  71128. /**
  71129. * Returns a string to use to update the GPU particles update shader
  71130. * @returns a string containng the defines string
  71131. */
  71132. getEffectDefines(): string;
  71133. /**
  71134. * Returns the string "BoxParticleEmitter"
  71135. * @returns a string containing the class name
  71136. */
  71137. getClassName(): string;
  71138. /**
  71139. * Serializes the particle system to a JSON object.
  71140. * @returns the JSON object
  71141. */
  71142. serialize(): any;
  71143. /**
  71144. * Parse properties from a JSON object
  71145. * @param serializationObject defines the JSON object
  71146. */
  71147. parse(serializationObject: any): void;
  71148. }
  71149. }
  71150. declare module BABYLON {
  71151. /**
  71152. * Particle emitter emitting particles from the inside of a cone.
  71153. * It emits the particles alongside the cone volume from the base to the particle.
  71154. * The emission direction might be randomized.
  71155. */
  71156. export class ConeParticleEmitter implements IParticleEmitterType {
  71157. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71158. directionRandomizer: number;
  71159. private _radius;
  71160. private _angle;
  71161. private _height;
  71162. /**
  71163. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71164. */
  71165. radiusRange: number;
  71166. /**
  71167. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71168. */
  71169. heightRange: number;
  71170. /**
  71171. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71172. */
  71173. emitFromSpawnPointOnly: boolean;
  71174. /**
  71175. * Gets or sets the radius of the emission cone
  71176. */
  71177. radius: number;
  71178. /**
  71179. * Gets or sets the angle of the emission cone
  71180. */
  71181. angle: number;
  71182. private _buildHeight;
  71183. /**
  71184. * Creates a new instance ConeParticleEmitter
  71185. * @param radius the radius of the emission cone (1 by default)
  71186. * @param angle the cone base angle (PI by default)
  71187. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  71188. */
  71189. constructor(radius?: number, angle?: number,
  71190. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71191. directionRandomizer?: number);
  71192. /**
  71193. * Called by the particle System when the direction is computed for the created particle.
  71194. * @param worldMatrix is the world matrix of the particle system
  71195. * @param directionToUpdate is the direction vector to update with the result
  71196. * @param particle is the particle we are computed the direction for
  71197. */
  71198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71199. /**
  71200. * Called by the particle System when the position is computed for the created particle.
  71201. * @param worldMatrix is the world matrix of the particle system
  71202. * @param positionToUpdate is the position vector to update with the result
  71203. * @param particle is the particle we are computed the position for
  71204. */
  71205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71206. /**
  71207. * Clones the current emitter and returns a copy of it
  71208. * @returns the new emitter
  71209. */
  71210. clone(): ConeParticleEmitter;
  71211. /**
  71212. * Called by the GPUParticleSystem to setup the update shader
  71213. * @param effect defines the update shader
  71214. */
  71215. applyToShader(effect: Effect): void;
  71216. /**
  71217. * Returns a string to use to update the GPU particles update shader
  71218. * @returns a string containng the defines string
  71219. */
  71220. getEffectDefines(): string;
  71221. /**
  71222. * Returns the string "ConeParticleEmitter"
  71223. * @returns a string containing the class name
  71224. */
  71225. getClassName(): string;
  71226. /**
  71227. * Serializes the particle system to a JSON object.
  71228. * @returns the JSON object
  71229. */
  71230. serialize(): any;
  71231. /**
  71232. * Parse properties from a JSON object
  71233. * @param serializationObject defines the JSON object
  71234. */
  71235. parse(serializationObject: any): void;
  71236. }
  71237. }
  71238. declare module BABYLON {
  71239. /**
  71240. * Particle emitter emitting particles from the inside of a cylinder.
  71241. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  71242. */
  71243. export class CylinderParticleEmitter implements IParticleEmitterType {
  71244. /**
  71245. * The radius of the emission cylinder.
  71246. */
  71247. radius: number;
  71248. /**
  71249. * The height of the emission cylinder.
  71250. */
  71251. height: number;
  71252. /**
  71253. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71254. */
  71255. radiusRange: number;
  71256. /**
  71257. * How much to randomize the particle direction [0-1].
  71258. */
  71259. directionRandomizer: number;
  71260. /**
  71261. * Creates a new instance CylinderParticleEmitter
  71262. * @param radius the radius of the emission cylinder (1 by default)
  71263. * @param height the height of the emission cylinder (1 by default)
  71264. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71265. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  71266. */
  71267. constructor(
  71268. /**
  71269. * The radius of the emission cylinder.
  71270. */
  71271. radius?: number,
  71272. /**
  71273. * The height of the emission cylinder.
  71274. */
  71275. height?: number,
  71276. /**
  71277. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71278. */
  71279. radiusRange?: number,
  71280. /**
  71281. * How much to randomize the particle direction [0-1].
  71282. */
  71283. directionRandomizer?: number);
  71284. /**
  71285. * Called by the particle System when the direction is computed for the created particle.
  71286. * @param worldMatrix is the world matrix of the particle system
  71287. * @param directionToUpdate is the direction vector to update with the result
  71288. * @param particle is the particle we are computed the direction for
  71289. */
  71290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71291. /**
  71292. * Called by the particle System when the position is computed for the created particle.
  71293. * @param worldMatrix is the world matrix of the particle system
  71294. * @param positionToUpdate is the position vector to update with the result
  71295. * @param particle is the particle we are computed the position for
  71296. */
  71297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71298. /**
  71299. * Clones the current emitter and returns a copy of it
  71300. * @returns the new emitter
  71301. */
  71302. clone(): CylinderParticleEmitter;
  71303. /**
  71304. * Called by the GPUParticleSystem to setup the update shader
  71305. * @param effect defines the update shader
  71306. */
  71307. applyToShader(effect: Effect): void;
  71308. /**
  71309. * Returns a string to use to update the GPU particles update shader
  71310. * @returns a string containng the defines string
  71311. */
  71312. getEffectDefines(): string;
  71313. /**
  71314. * Returns the string "CylinderParticleEmitter"
  71315. * @returns a string containing the class name
  71316. */
  71317. getClassName(): string;
  71318. /**
  71319. * Serializes the particle system to a JSON object.
  71320. * @returns the JSON object
  71321. */
  71322. serialize(): any;
  71323. /**
  71324. * Parse properties from a JSON object
  71325. * @param serializationObject defines the JSON object
  71326. */
  71327. parse(serializationObject: any): void;
  71328. }
  71329. /**
  71330. * Particle emitter emitting particles from the inside of a cylinder.
  71331. * It emits the particles randomly between two vectors.
  71332. */
  71333. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  71334. /**
  71335. * The min limit of the emission direction.
  71336. */
  71337. direction1: Vector3;
  71338. /**
  71339. * The max limit of the emission direction.
  71340. */
  71341. direction2: Vector3;
  71342. /**
  71343. * Creates a new instance CylinderDirectedParticleEmitter
  71344. * @param radius the radius of the emission cylinder (1 by default)
  71345. * @param height the height of the emission cylinder (1 by default)
  71346. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71347. * @param direction1 the min limit of the emission direction (up vector by default)
  71348. * @param direction2 the max limit of the emission direction (up vector by default)
  71349. */
  71350. constructor(radius?: number, height?: number, radiusRange?: number,
  71351. /**
  71352. * The min limit of the emission direction.
  71353. */
  71354. direction1?: Vector3,
  71355. /**
  71356. * The max limit of the emission direction.
  71357. */
  71358. direction2?: Vector3);
  71359. /**
  71360. * Called by the particle System when the direction is computed for the created particle.
  71361. * @param worldMatrix is the world matrix of the particle system
  71362. * @param directionToUpdate is the direction vector to update with the result
  71363. * @param particle is the particle we are computed the direction for
  71364. */
  71365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71366. /**
  71367. * Clones the current emitter and returns a copy of it
  71368. * @returns the new emitter
  71369. */
  71370. clone(): CylinderDirectedParticleEmitter;
  71371. /**
  71372. * Called by the GPUParticleSystem to setup the update shader
  71373. * @param effect defines the update shader
  71374. */
  71375. applyToShader(effect: Effect): void;
  71376. /**
  71377. * Returns a string to use to update the GPU particles update shader
  71378. * @returns a string containng the defines string
  71379. */
  71380. getEffectDefines(): string;
  71381. /**
  71382. * Returns the string "CylinderDirectedParticleEmitter"
  71383. * @returns a string containing the class name
  71384. */
  71385. getClassName(): string;
  71386. /**
  71387. * Serializes the particle system to a JSON object.
  71388. * @returns the JSON object
  71389. */
  71390. serialize(): any;
  71391. /**
  71392. * Parse properties from a JSON object
  71393. * @param serializationObject defines the JSON object
  71394. */
  71395. parse(serializationObject: any): void;
  71396. }
  71397. }
  71398. declare module BABYLON {
  71399. /**
  71400. * Particle emitter emitting particles from the inside of a hemisphere.
  71401. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  71402. */
  71403. export class HemisphericParticleEmitter implements IParticleEmitterType {
  71404. /**
  71405. * The radius of the emission hemisphere.
  71406. */
  71407. radius: number;
  71408. /**
  71409. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71410. */
  71411. radiusRange: number;
  71412. /**
  71413. * How much to randomize the particle direction [0-1].
  71414. */
  71415. directionRandomizer: number;
  71416. /**
  71417. * Creates a new instance HemisphericParticleEmitter
  71418. * @param radius the radius of the emission hemisphere (1 by default)
  71419. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71420. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  71421. */
  71422. constructor(
  71423. /**
  71424. * The radius of the emission hemisphere.
  71425. */
  71426. radius?: number,
  71427. /**
  71428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71429. */
  71430. radiusRange?: number,
  71431. /**
  71432. * How much to randomize the particle direction [0-1].
  71433. */
  71434. directionRandomizer?: number);
  71435. /**
  71436. * Called by the particle System when the direction is computed for the created particle.
  71437. * @param worldMatrix is the world matrix of the particle system
  71438. * @param directionToUpdate is the direction vector to update with the result
  71439. * @param particle is the particle we are computed the direction for
  71440. */
  71441. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71442. /**
  71443. * Called by the particle System when the position is computed for the created particle.
  71444. * @param worldMatrix is the world matrix of the particle system
  71445. * @param positionToUpdate is the position vector to update with the result
  71446. * @param particle is the particle we are computed the position for
  71447. */
  71448. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71449. /**
  71450. * Clones the current emitter and returns a copy of it
  71451. * @returns the new emitter
  71452. */
  71453. clone(): HemisphericParticleEmitter;
  71454. /**
  71455. * Called by the GPUParticleSystem to setup the update shader
  71456. * @param effect defines the update shader
  71457. */
  71458. applyToShader(effect: Effect): void;
  71459. /**
  71460. * Returns a string to use to update the GPU particles update shader
  71461. * @returns a string containng the defines string
  71462. */
  71463. getEffectDefines(): string;
  71464. /**
  71465. * Returns the string "HemisphericParticleEmitter"
  71466. * @returns a string containing the class name
  71467. */
  71468. getClassName(): string;
  71469. /**
  71470. * Serializes the particle system to a JSON object.
  71471. * @returns the JSON object
  71472. */
  71473. serialize(): any;
  71474. /**
  71475. * Parse properties from a JSON object
  71476. * @param serializationObject defines the JSON object
  71477. */
  71478. parse(serializationObject: any): void;
  71479. }
  71480. }
  71481. declare module BABYLON {
  71482. /**
  71483. * Particle emitter emitting particles from a point.
  71484. * It emits the particles randomly between 2 given directions.
  71485. */
  71486. export class PointParticleEmitter implements IParticleEmitterType {
  71487. /**
  71488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71489. */
  71490. direction1: Vector3;
  71491. /**
  71492. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71493. */
  71494. direction2: Vector3;
  71495. /**
  71496. * Creates a new instance PointParticleEmitter
  71497. */
  71498. constructor();
  71499. /**
  71500. * Called by the particle System when the direction is computed for the created particle.
  71501. * @param worldMatrix is the world matrix of the particle system
  71502. * @param directionToUpdate is the direction vector to update with the result
  71503. * @param particle is the particle we are computed the direction for
  71504. */
  71505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71506. /**
  71507. * Called by the particle System when the position is computed for the created particle.
  71508. * @param worldMatrix is the world matrix of the particle system
  71509. * @param positionToUpdate is the position vector to update with the result
  71510. * @param particle is the particle we are computed the position for
  71511. */
  71512. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71513. /**
  71514. * Clones the current emitter and returns a copy of it
  71515. * @returns the new emitter
  71516. */
  71517. clone(): PointParticleEmitter;
  71518. /**
  71519. * Called by the GPUParticleSystem to setup the update shader
  71520. * @param effect defines the update shader
  71521. */
  71522. applyToShader(effect: Effect): void;
  71523. /**
  71524. * Returns a string to use to update the GPU particles update shader
  71525. * @returns a string containng the defines string
  71526. */
  71527. getEffectDefines(): string;
  71528. /**
  71529. * Returns the string "PointParticleEmitter"
  71530. * @returns a string containing the class name
  71531. */
  71532. getClassName(): string;
  71533. /**
  71534. * Serializes the particle system to a JSON object.
  71535. * @returns the JSON object
  71536. */
  71537. serialize(): any;
  71538. /**
  71539. * Parse properties from a JSON object
  71540. * @param serializationObject defines the JSON object
  71541. */
  71542. parse(serializationObject: any): void;
  71543. }
  71544. }
  71545. declare module BABYLON {
  71546. /**
  71547. * Particle emitter emitting particles from the inside of a sphere.
  71548. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  71549. */
  71550. export class SphereParticleEmitter implements IParticleEmitterType {
  71551. /**
  71552. * The radius of the emission sphere.
  71553. */
  71554. radius: number;
  71555. /**
  71556. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71557. */
  71558. radiusRange: number;
  71559. /**
  71560. * How much to randomize the particle direction [0-1].
  71561. */
  71562. directionRandomizer: number;
  71563. /**
  71564. * Creates a new instance SphereParticleEmitter
  71565. * @param radius the radius of the emission sphere (1 by default)
  71566. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71567. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  71568. */
  71569. constructor(
  71570. /**
  71571. * The radius of the emission sphere.
  71572. */
  71573. radius?: number,
  71574. /**
  71575. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  71576. */
  71577. radiusRange?: number,
  71578. /**
  71579. * How much to randomize the particle direction [0-1].
  71580. */
  71581. directionRandomizer?: number);
  71582. /**
  71583. * Called by the particle System when the direction is computed for the created particle.
  71584. * @param worldMatrix is the world matrix of the particle system
  71585. * @param directionToUpdate is the direction vector to update with the result
  71586. * @param particle is the particle we are computed the direction for
  71587. */
  71588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71589. /**
  71590. * Called by the particle System when the position is computed for the created particle.
  71591. * @param worldMatrix is the world matrix of the particle system
  71592. * @param positionToUpdate is the position vector to update with the result
  71593. * @param particle is the particle we are computed the position for
  71594. */
  71595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71596. /**
  71597. * Clones the current emitter and returns a copy of it
  71598. * @returns the new emitter
  71599. */
  71600. clone(): SphereParticleEmitter;
  71601. /**
  71602. * Called by the GPUParticleSystem to setup the update shader
  71603. * @param effect defines the update shader
  71604. */
  71605. applyToShader(effect: Effect): void;
  71606. /**
  71607. * Returns a string to use to update the GPU particles update shader
  71608. * @returns a string containng the defines string
  71609. */
  71610. getEffectDefines(): string;
  71611. /**
  71612. * Returns the string "SphereParticleEmitter"
  71613. * @returns a string containing the class name
  71614. */
  71615. getClassName(): string;
  71616. /**
  71617. * Serializes the particle system to a JSON object.
  71618. * @returns the JSON object
  71619. */
  71620. serialize(): any;
  71621. /**
  71622. * Parse properties from a JSON object
  71623. * @param serializationObject defines the JSON object
  71624. */
  71625. parse(serializationObject: any): void;
  71626. }
  71627. /**
  71628. * Particle emitter emitting particles from the inside of a sphere.
  71629. * It emits the particles randomly between two vectors.
  71630. */
  71631. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  71632. /**
  71633. * The min limit of the emission direction.
  71634. */
  71635. direction1: Vector3;
  71636. /**
  71637. * The max limit of the emission direction.
  71638. */
  71639. direction2: Vector3;
  71640. /**
  71641. * Creates a new instance SphereDirectedParticleEmitter
  71642. * @param radius the radius of the emission sphere (1 by default)
  71643. * @param direction1 the min limit of the emission direction (up vector by default)
  71644. * @param direction2 the max limit of the emission direction (up vector by default)
  71645. */
  71646. constructor(radius?: number,
  71647. /**
  71648. * The min limit of the emission direction.
  71649. */
  71650. direction1?: Vector3,
  71651. /**
  71652. * The max limit of the emission direction.
  71653. */
  71654. direction2?: Vector3);
  71655. /**
  71656. * Called by the particle System when the direction is computed for the created particle.
  71657. * @param worldMatrix is the world matrix of the particle system
  71658. * @param directionToUpdate is the direction vector to update with the result
  71659. * @param particle is the particle we are computed the direction for
  71660. */
  71661. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71662. /**
  71663. * Clones the current emitter and returns a copy of it
  71664. * @returns the new emitter
  71665. */
  71666. clone(): SphereDirectedParticleEmitter;
  71667. /**
  71668. * Called by the GPUParticleSystem to setup the update shader
  71669. * @param effect defines the update shader
  71670. */
  71671. applyToShader(effect: Effect): void;
  71672. /**
  71673. * Returns a string to use to update the GPU particles update shader
  71674. * @returns a string containng the defines string
  71675. */
  71676. getEffectDefines(): string;
  71677. /**
  71678. * Returns the string "SphereDirectedParticleEmitter"
  71679. * @returns a string containing the class name
  71680. */
  71681. getClassName(): string;
  71682. /**
  71683. * Serializes the particle system to a JSON object.
  71684. * @returns the JSON object
  71685. */
  71686. serialize(): any;
  71687. /**
  71688. * Parse properties from a JSON object
  71689. * @param serializationObject defines the JSON object
  71690. */
  71691. parse(serializationObject: any): void;
  71692. }
  71693. }
  71694. declare module BABYLON {
  71695. /**
  71696. * Interface representing a particle system in Babylon.js.
  71697. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  71698. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  71699. */
  71700. export interface IParticleSystem {
  71701. /**
  71702. * List of animations used by the particle system.
  71703. */
  71704. animations: Animation[];
  71705. /**
  71706. * The id of the Particle system.
  71707. */
  71708. id: string;
  71709. /**
  71710. * The name of the Particle system.
  71711. */
  71712. name: string;
  71713. /**
  71714. * The emitter represents the Mesh or position we are attaching the particle system to.
  71715. */
  71716. emitter: Nullable<AbstractMesh | Vector3>;
  71717. /**
  71718. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71719. */
  71720. isBillboardBased: boolean;
  71721. /**
  71722. * The rendering group used by the Particle system to chose when to render.
  71723. */
  71724. renderingGroupId: number;
  71725. /**
  71726. * The layer mask we are rendering the particles through.
  71727. */
  71728. layerMask: number;
  71729. /**
  71730. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71731. */
  71732. updateSpeed: number;
  71733. /**
  71734. * The amount of time the particle system is running (depends of the overall update speed).
  71735. */
  71736. targetStopDuration: number;
  71737. /**
  71738. * The texture used to render each particle. (this can be a spritesheet)
  71739. */
  71740. particleTexture: Nullable<Texture>;
  71741. /**
  71742. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  71743. */
  71744. blendMode: number;
  71745. /**
  71746. * Minimum life time of emitting particles.
  71747. */
  71748. minLifeTime: number;
  71749. /**
  71750. * Maximum life time of emitting particles.
  71751. */
  71752. maxLifeTime: number;
  71753. /**
  71754. * Minimum Size of emitting particles.
  71755. */
  71756. minSize: number;
  71757. /**
  71758. * Maximum Size of emitting particles.
  71759. */
  71760. maxSize: number;
  71761. /**
  71762. * Minimum scale of emitting particles on X axis.
  71763. */
  71764. minScaleX: number;
  71765. /**
  71766. * Maximum scale of emitting particles on X axis.
  71767. */
  71768. maxScaleX: number;
  71769. /**
  71770. * Minimum scale of emitting particles on Y axis.
  71771. */
  71772. minScaleY: number;
  71773. /**
  71774. * Maximum scale of emitting particles on Y axis.
  71775. */
  71776. maxScaleY: number;
  71777. /**
  71778. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  71779. */
  71780. color1: Color4;
  71781. /**
  71782. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  71783. */
  71784. color2: Color4;
  71785. /**
  71786. * Color the particle will have at the end of its lifetime.
  71787. */
  71788. colorDead: Color4;
  71789. /**
  71790. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  71791. */
  71792. emitRate: number;
  71793. /**
  71794. * You can use gravity if you want to give an orientation to your particles.
  71795. */
  71796. gravity: Vector3;
  71797. /**
  71798. * Minimum power of emitting particles.
  71799. */
  71800. minEmitPower: number;
  71801. /**
  71802. * Maximum power of emitting particles.
  71803. */
  71804. maxEmitPower: number;
  71805. /**
  71806. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71807. */
  71808. minAngularSpeed: number;
  71809. /**
  71810. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71811. */
  71812. maxAngularSpeed: number;
  71813. /**
  71814. * Gets or sets the minimal initial rotation in radians.
  71815. */
  71816. minInitialRotation: number;
  71817. /**
  71818. * Gets or sets the maximal initial rotation in radians.
  71819. */
  71820. maxInitialRotation: number;
  71821. /**
  71822. * The particle emitter type defines the emitter used by the particle system.
  71823. * It can be for example box, sphere, or cone...
  71824. */
  71825. particleEmitterType: Nullable<IParticleEmitterType>;
  71826. /**
  71827. * Defines the delay in milliseconds before starting the system (0 by default)
  71828. */
  71829. startDelay: number;
  71830. /**
  71831. * 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
  71832. */
  71833. preWarmCycles: number;
  71834. /**
  71835. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  71836. */
  71837. preWarmStepOffset: number;
  71838. /**
  71839. * 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)
  71840. */
  71841. spriteCellChangeSpeed: number;
  71842. /**
  71843. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71844. */
  71845. startSpriteCellID: number;
  71846. /**
  71847. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71848. */
  71849. endSpriteCellID: number;
  71850. /**
  71851. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71852. */
  71853. spriteCellWidth: number;
  71854. /**
  71855. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71856. */
  71857. spriteCellHeight: number;
  71858. /**
  71859. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71860. */
  71861. spriteRandomStartCell: boolean;
  71862. /**
  71863. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  71864. */
  71865. isAnimationSheetEnabled: boolean;
  71866. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71867. translationPivot: Vector2;
  71868. /**
  71869. * Gets or sets a texture used to add random noise to particle positions
  71870. */
  71871. noiseTexture: Nullable<BaseTexture>;
  71872. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71873. noiseStrength: Vector3;
  71874. /**
  71875. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71876. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71877. */
  71878. billboardMode: number;
  71879. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71880. limitVelocityDamping: number;
  71881. /**
  71882. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71883. */
  71884. beginAnimationOnStart: boolean;
  71885. /**
  71886. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71887. */
  71888. beginAnimationFrom: number;
  71889. /**
  71890. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71891. */
  71892. beginAnimationTo: number;
  71893. /**
  71894. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71895. */
  71896. beginAnimationLoop: boolean;
  71897. /**
  71898. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71899. */
  71900. disposeOnStop: boolean;
  71901. /**
  71902. * Gets the maximum number of particles active at the same time.
  71903. * @returns The max number of active particles.
  71904. */
  71905. getCapacity(): number;
  71906. /**
  71907. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71908. * @returns True if it has been started, otherwise false.
  71909. */
  71910. isStarted(): boolean;
  71911. /**
  71912. * Animates the particle system for this frame.
  71913. */
  71914. animate(): void;
  71915. /**
  71916. * Renders the particle system in its current state.
  71917. * @returns the current number of particles
  71918. */
  71919. render(): number;
  71920. /**
  71921. * Dispose the particle system and frees its associated resources.
  71922. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71923. */
  71924. dispose(disposeTexture?: boolean): void;
  71925. /**
  71926. * Clones the particle system.
  71927. * @param name The name of the cloned object
  71928. * @param newEmitter The new emitter to use
  71929. * @returns the cloned particle system
  71930. */
  71931. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  71932. /**
  71933. * Serializes the particle system to a JSON object.
  71934. * @returns the JSON object
  71935. */
  71936. serialize(): any;
  71937. /**
  71938. * Rebuild the particle system
  71939. */
  71940. rebuild(): void;
  71941. /**
  71942. * Starts the particle system and begins to emit
  71943. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  71944. */
  71945. start(delay?: number): void;
  71946. /**
  71947. * Stops the particle system.
  71948. */
  71949. stop(): void;
  71950. /**
  71951. * Remove all active particles
  71952. */
  71953. reset(): void;
  71954. /**
  71955. * Is this system ready to be used/rendered
  71956. * @return true if the system is ready
  71957. */
  71958. isReady(): boolean;
  71959. /**
  71960. * Adds a new color gradient
  71961. * @param gradient defines the gradient to use (between 0 and 1)
  71962. * @param color1 defines the color to affect to the specified gradient
  71963. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71964. * @returns the current particle system
  71965. */
  71966. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71967. /**
  71968. * Remove a specific color gradient
  71969. * @param gradient defines the gradient to remove
  71970. * @returns the current particle system
  71971. */
  71972. removeColorGradient(gradient: number): IParticleSystem;
  71973. /**
  71974. * Adds a new size gradient
  71975. * @param gradient defines the gradient to use (between 0 and 1)
  71976. * @param factor defines the size factor to affect to the specified gradient
  71977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71978. * @returns the current particle system
  71979. */
  71980. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71981. /**
  71982. * Remove a specific size gradient
  71983. * @param gradient defines the gradient to remove
  71984. * @returns the current particle system
  71985. */
  71986. removeSizeGradient(gradient: number): IParticleSystem;
  71987. /**
  71988. * Gets the current list of color gradients.
  71989. * You must use addColorGradient and removeColorGradient to udpate this list
  71990. * @returns the list of color gradients
  71991. */
  71992. getColorGradients(): Nullable<Array<ColorGradient>>;
  71993. /**
  71994. * Gets the current list of size gradients.
  71995. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71996. * @returns the list of size gradients
  71997. */
  71998. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71999. /**
  72000. * Gets the current list of angular speed gradients.
  72001. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72002. * @returns the list of angular speed gradients
  72003. */
  72004. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72005. /**
  72006. * Adds a new angular speed gradient
  72007. * @param gradient defines the gradient to use (between 0 and 1)
  72008. * @param factor defines the angular speed to affect to the specified gradient
  72009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72010. * @returns the current particle system
  72011. */
  72012. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72013. /**
  72014. * Remove a specific angular speed gradient
  72015. * @param gradient defines the gradient to remove
  72016. * @returns the current particle system
  72017. */
  72018. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72019. /**
  72020. * Gets the current list of velocity gradients.
  72021. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72022. * @returns the list of velocity gradients
  72023. */
  72024. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72025. /**
  72026. * Adds a new velocity gradient
  72027. * @param gradient defines the gradient to use (between 0 and 1)
  72028. * @param factor defines the velocity to affect to the specified gradient
  72029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72030. * @returns the current particle system
  72031. */
  72032. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72033. /**
  72034. * Remove a specific velocity gradient
  72035. * @param gradient defines the gradient to remove
  72036. * @returns the current particle system
  72037. */
  72038. removeVelocityGradient(gradient: number): IParticleSystem;
  72039. /**
  72040. * Gets the current list of limit velocity gradients.
  72041. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72042. * @returns the list of limit velocity gradients
  72043. */
  72044. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72045. /**
  72046. * Adds a new limit velocity gradient
  72047. * @param gradient defines the gradient to use (between 0 and 1)
  72048. * @param factor defines the limit velocity to affect to the specified gradient
  72049. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72050. * @returns the current particle system
  72051. */
  72052. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72053. /**
  72054. * Remove a specific limit velocity gradient
  72055. * @param gradient defines the gradient to remove
  72056. * @returns the current particle system
  72057. */
  72058. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72059. /**
  72060. * Adds a new drag gradient
  72061. * @param gradient defines the gradient to use (between 0 and 1)
  72062. * @param factor defines the drag to affect to the specified gradient
  72063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72064. * @returns the current particle system
  72065. */
  72066. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72067. /**
  72068. * Remove a specific drag gradient
  72069. * @param gradient defines the gradient to remove
  72070. * @returns the current particle system
  72071. */
  72072. removeDragGradient(gradient: number): IParticleSystem;
  72073. /**
  72074. * Gets the current list of drag gradients.
  72075. * You must use addDragGradient and removeDragGradient to udpate this list
  72076. * @returns the list of drag gradients
  72077. */
  72078. getDragGradients(): Nullable<Array<FactorGradient>>;
  72079. /**
  72080. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72081. * @param gradient defines the gradient to use (between 0 and 1)
  72082. * @param factor defines the emit rate to affect to the specified gradient
  72083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72084. * @returns the current particle system
  72085. */
  72086. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72087. /**
  72088. * Remove a specific emit rate gradient
  72089. * @param gradient defines the gradient to remove
  72090. * @returns the current particle system
  72091. */
  72092. removeEmitRateGradient(gradient: number): IParticleSystem;
  72093. /**
  72094. * Gets the current list of emit rate gradients.
  72095. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72096. * @returns the list of emit rate gradients
  72097. */
  72098. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72099. /**
  72100. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72101. * @param gradient defines the gradient to use (between 0 and 1)
  72102. * @param factor defines the start size to affect to the specified gradient
  72103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72104. * @returns the current particle system
  72105. */
  72106. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72107. /**
  72108. * Remove a specific start size gradient
  72109. * @param gradient defines the gradient to remove
  72110. * @returns the current particle system
  72111. */
  72112. removeStartSizeGradient(gradient: number): IParticleSystem;
  72113. /**
  72114. * Gets the current list of start size gradients.
  72115. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72116. * @returns the list of start size gradients
  72117. */
  72118. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72119. /**
  72120. * Adds a new life time gradient
  72121. * @param gradient defines the gradient to use (between 0 and 1)
  72122. * @param factor defines the life time factor to affect to the specified gradient
  72123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72124. * @returns the current particle system
  72125. */
  72126. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72127. /**
  72128. * Remove a specific life time gradient
  72129. * @param gradient defines the gradient to remove
  72130. * @returns the current particle system
  72131. */
  72132. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72133. /**
  72134. * Gets the current list of life time gradients.
  72135. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72136. * @returns the list of life time gradients
  72137. */
  72138. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72139. /**
  72140. * Gets the current list of color gradients.
  72141. * You must use addColorGradient and removeColorGradient to udpate this list
  72142. * @returns the list of color gradients
  72143. */
  72144. getColorGradients(): Nullable<Array<ColorGradient>>;
  72145. /**
  72146. * Adds a new ramp gradient used to remap particle colors
  72147. * @param gradient defines the gradient to use (between 0 and 1)
  72148. * @param color defines the color to affect to the specified gradient
  72149. * @returns the current particle system
  72150. */
  72151. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72152. /**
  72153. * Gets the current list of ramp gradients.
  72154. * You must use addRampGradient and removeRampGradient to udpate this list
  72155. * @returns the list of ramp gradients
  72156. */
  72157. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72158. /** Gets or sets a boolean indicating that ramp gradients must be used
  72159. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72160. */
  72161. useRampGradients: boolean;
  72162. /**
  72163. * Adds a new color remap gradient
  72164. * @param gradient defines the gradient to use (between 0 and 1)
  72165. * @param min defines the color remap minimal range
  72166. * @param max defines the color remap maximal range
  72167. * @returns the current particle system
  72168. */
  72169. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72170. /**
  72171. * Gets the current list of color remap gradients.
  72172. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72173. * @returns the list of color remap gradients
  72174. */
  72175. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72176. /**
  72177. * Adds a new alpha remap gradient
  72178. * @param gradient defines the gradient to use (between 0 and 1)
  72179. * @param min defines the alpha remap minimal range
  72180. * @param max defines the alpha remap maximal range
  72181. * @returns the current particle system
  72182. */
  72183. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72184. /**
  72185. * Gets the current list of alpha remap gradients.
  72186. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72187. * @returns the list of alpha remap gradients
  72188. */
  72189. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72190. /**
  72191. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72192. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72193. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72194. * @returns the emitter
  72195. */
  72196. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72197. /**
  72198. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72199. * @param radius The radius of the hemisphere to emit from
  72200. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72201. * @returns the emitter
  72202. */
  72203. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  72204. /**
  72205. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72206. * @param radius The radius of the sphere to emit from
  72207. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72208. * @returns the emitter
  72209. */
  72210. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  72211. /**
  72212. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72213. * @param radius The radius of the sphere to emit from
  72214. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72215. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72216. * @returns the emitter
  72217. */
  72218. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72219. /**
  72220. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72221. * @param radius The radius of the emission cylinder
  72222. * @param height The height of the emission cylinder
  72223. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72224. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72225. * @returns the emitter
  72226. */
  72227. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  72228. /**
  72229. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72230. * @param radius The radius of the cylinder to emit from
  72231. * @param height The height of the emission cylinder
  72232. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72233. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72234. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72235. * @returns the emitter
  72236. */
  72237. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  72238. /**
  72239. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72240. * @param radius The radius of the cone to emit from
  72241. * @param angle The base angle of the cone
  72242. * @returns the emitter
  72243. */
  72244. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  72245. /**
  72246. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72247. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72248. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72249. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72250. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72251. * @returns the emitter
  72252. */
  72253. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72254. /**
  72255. * Get hosting scene
  72256. * @returns the scene
  72257. */
  72258. getScene(): Scene;
  72259. }
  72260. }
  72261. declare module BABYLON {
  72262. /**
  72263. * Creates an instance based on a source mesh.
  72264. */
  72265. export class InstancedMesh extends AbstractMesh {
  72266. private _sourceMesh;
  72267. private _currentLOD;
  72268. /** @hidden */
  72269. _indexInSourceMeshInstanceArray: number;
  72270. constructor(name: string, source: Mesh);
  72271. /**
  72272. * Returns the string "InstancedMesh".
  72273. */
  72274. getClassName(): string;
  72275. /**
  72276. * If the source mesh receives shadows
  72277. */
  72278. readonly receiveShadows: boolean;
  72279. /**
  72280. * The material of the source mesh
  72281. */
  72282. readonly material: Nullable<Material>;
  72283. /**
  72284. * Visibility of the source mesh
  72285. */
  72286. readonly visibility: number;
  72287. /**
  72288. * Skeleton of the source mesh
  72289. */
  72290. readonly skeleton: Nullable<Skeleton>;
  72291. /**
  72292. * Rendering ground id of the source mesh
  72293. */
  72294. renderingGroupId: number;
  72295. /**
  72296. * Returns the total number of vertices (integer).
  72297. */
  72298. getTotalVertices(): number;
  72299. /**
  72300. * Returns a positive integer : the total number of indices in this mesh geometry.
  72301. * @returns the numner of indices or zero if the mesh has no geometry.
  72302. */
  72303. getTotalIndices(): number;
  72304. /**
  72305. * The source mesh of the instance
  72306. */
  72307. readonly sourceMesh: Mesh;
  72308. /**
  72309. * Is this node ready to be used/rendered
  72310. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  72311. * @return {boolean} is it ready
  72312. */
  72313. isReady(completeCheck?: boolean): boolean;
  72314. /**
  72315. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  72316. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  72317. * @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.
  72318. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  72319. */
  72320. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  72321. /**
  72322. * Sets the vertex data of the mesh geometry for the requested `kind`.
  72323. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  72324. * The `data` are either a numeric array either a Float32Array.
  72325. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  72326. * 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).
  72327. * Note that a new underlying VertexBuffer object is created each call.
  72328. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  72329. *
  72330. * Possible `kind` values :
  72331. * - VertexBuffer.PositionKind
  72332. * - VertexBuffer.UVKind
  72333. * - VertexBuffer.UV2Kind
  72334. * - VertexBuffer.UV3Kind
  72335. * - VertexBuffer.UV4Kind
  72336. * - VertexBuffer.UV5Kind
  72337. * - VertexBuffer.UV6Kind
  72338. * - VertexBuffer.ColorKind
  72339. * - VertexBuffer.MatricesIndicesKind
  72340. * - VertexBuffer.MatricesIndicesExtraKind
  72341. * - VertexBuffer.MatricesWeightsKind
  72342. * - VertexBuffer.MatricesWeightsExtraKind
  72343. *
  72344. * Returns the Mesh.
  72345. */
  72346. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  72347. /**
  72348. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  72349. * If the mesh has no geometry, it is simply returned as it is.
  72350. * The `data` are either a numeric array either a Float32Array.
  72351. * No new underlying VertexBuffer object is created.
  72352. * 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.
  72353. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  72354. *
  72355. * Possible `kind` values :
  72356. * - VertexBuffer.PositionKind
  72357. * - VertexBuffer.UVKind
  72358. * - VertexBuffer.UV2Kind
  72359. * - VertexBuffer.UV3Kind
  72360. * - VertexBuffer.UV4Kind
  72361. * - VertexBuffer.UV5Kind
  72362. * - VertexBuffer.UV6Kind
  72363. * - VertexBuffer.ColorKind
  72364. * - VertexBuffer.MatricesIndicesKind
  72365. * - VertexBuffer.MatricesIndicesExtraKind
  72366. * - VertexBuffer.MatricesWeightsKind
  72367. * - VertexBuffer.MatricesWeightsExtraKind
  72368. *
  72369. * Returns the Mesh.
  72370. */
  72371. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  72372. /**
  72373. * Sets the mesh indices.
  72374. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  72375. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  72376. * This method creates a new index buffer each call.
  72377. * Returns the Mesh.
  72378. */
  72379. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  72380. /**
  72381. * Boolean : True if the mesh owns the requested kind of data.
  72382. */
  72383. isVerticesDataPresent(kind: string): boolean;
  72384. /**
  72385. * Returns an array of indices (IndicesArray).
  72386. */
  72387. getIndices(): Nullable<IndicesArray>;
  72388. readonly _positions: Nullable<Vector3[]>;
  72389. /**
  72390. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  72391. * This means the mesh underlying bounding box and sphere are recomputed.
  72392. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  72393. * @returns the current mesh
  72394. */
  72395. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  72396. /** @hidden */
  72397. _preActivate(): InstancedMesh;
  72398. /** @hidden */
  72399. _activate(renderId: number): InstancedMesh;
  72400. /**
  72401. * Returns the current associated LOD AbstractMesh.
  72402. */
  72403. getLOD(camera: Camera): AbstractMesh;
  72404. /** @hidden */
  72405. _syncSubMeshes(): InstancedMesh;
  72406. /** @hidden */
  72407. _generatePointsArray(): boolean;
  72408. /**
  72409. * Creates a new InstancedMesh from the current mesh.
  72410. * - name (string) : the cloned mesh name
  72411. * - newParent (optional Node) : the optional Node to parent the clone to.
  72412. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  72413. *
  72414. * Returns the clone.
  72415. */
  72416. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  72417. /**
  72418. * Disposes the InstancedMesh.
  72419. * Returns nothing.
  72420. */
  72421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  72422. }
  72423. }
  72424. declare module BABYLON {
  72425. /**
  72426. * Defines the options associated with the creation of a shader material.
  72427. */
  72428. export interface IShaderMaterialOptions {
  72429. /**
  72430. * Does the material work in alpha blend mode
  72431. */
  72432. needAlphaBlending: boolean;
  72433. /**
  72434. * Does the material work in alpha test mode
  72435. */
  72436. needAlphaTesting: boolean;
  72437. /**
  72438. * The list of attribute names used in the shader
  72439. */
  72440. attributes: string[];
  72441. /**
  72442. * The list of unifrom names used in the shader
  72443. */
  72444. uniforms: string[];
  72445. /**
  72446. * The list of UBO names used in the shader
  72447. */
  72448. uniformBuffers: string[];
  72449. /**
  72450. * The list of sampler names used in the shader
  72451. */
  72452. samplers: string[];
  72453. /**
  72454. * The list of defines used in the shader
  72455. */
  72456. defines: string[];
  72457. }
  72458. /**
  72459. * 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.
  72460. *
  72461. * This returned material effects how the mesh will look based on the code in the shaders.
  72462. *
  72463. * @see http://doc.babylonjs.com/how_to/shader_material
  72464. */
  72465. export class ShaderMaterial extends Material {
  72466. private _shaderPath;
  72467. private _options;
  72468. private _textures;
  72469. private _textureArrays;
  72470. private _floats;
  72471. private _ints;
  72472. private _floatsArrays;
  72473. private _colors3;
  72474. private _colors3Arrays;
  72475. private _colors4;
  72476. private _vectors2;
  72477. private _vectors3;
  72478. private _vectors4;
  72479. private _matrices;
  72480. private _matrices3x3;
  72481. private _matrices2x2;
  72482. private _vectors2Arrays;
  72483. private _vectors3Arrays;
  72484. private _cachedWorldViewMatrix;
  72485. private _renderId;
  72486. /**
  72487. * Instantiate a new shader material.
  72488. * 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.
  72489. * This returned material effects how the mesh will look based on the code in the shaders.
  72490. * @see http://doc.babylonjs.com/how_to/shader_material
  72491. * @param name Define the name of the material in the scene
  72492. * @param scene Define the scene the material belongs to
  72493. * @param shaderPath Defines the route to the shader code in one of three ways:
  72494. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  72495. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  72496. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  72497. * @param options Define the options used to create the shader
  72498. */
  72499. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  72500. /**
  72501. * Gets the current class name of the material e.g. "ShaderMaterial"
  72502. * Mainly use in serialization.
  72503. * @returns the class name
  72504. */
  72505. getClassName(): string;
  72506. /**
  72507. * Specifies if the material will require alpha blending
  72508. * @returns a boolean specifying if alpha blending is needed
  72509. */
  72510. needAlphaBlending(): boolean;
  72511. /**
  72512. * Specifies if this material should be rendered in alpha test mode
  72513. * @returns a boolean specifying if an alpha test is needed.
  72514. */
  72515. needAlphaTesting(): boolean;
  72516. private _checkUniform;
  72517. /**
  72518. * Set a texture in the shader.
  72519. * @param name Define the name of the uniform samplers as defined in the shader
  72520. * @param texture Define the texture to bind to this sampler
  72521. * @return the material itself allowing "fluent" like uniform updates
  72522. */
  72523. setTexture(name: string, texture: Texture): ShaderMaterial;
  72524. /**
  72525. * Set a texture array in the shader.
  72526. * @param name Define the name of the uniform sampler array as defined in the shader
  72527. * @param textures Define the list of textures to bind to this sampler
  72528. * @return the material itself allowing "fluent" like uniform updates
  72529. */
  72530. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  72531. /**
  72532. * Set a float in the shader.
  72533. * @param name Define the name of the uniform as defined in the shader
  72534. * @param value Define the value to give to the uniform
  72535. * @return the material itself allowing "fluent" like uniform updates
  72536. */
  72537. setFloat(name: string, value: number): ShaderMaterial;
  72538. /**
  72539. * Set a int in the shader.
  72540. * @param name Define the name of the uniform as defined in the shader
  72541. * @param value Define the value to give to the uniform
  72542. * @return the material itself allowing "fluent" like uniform updates
  72543. */
  72544. setInt(name: string, value: number): ShaderMaterial;
  72545. /**
  72546. * Set an array of floats in the shader.
  72547. * @param name Define the name of the uniform as defined in the shader
  72548. * @param value Define the value to give to the uniform
  72549. * @return the material itself allowing "fluent" like uniform updates
  72550. */
  72551. setFloats(name: string, value: number[]): ShaderMaterial;
  72552. /**
  72553. * Set a vec3 in the shader from a Color3.
  72554. * @param name Define the name of the uniform as defined in the shader
  72555. * @param value Define the value to give to the uniform
  72556. * @return the material itself allowing "fluent" like uniform updates
  72557. */
  72558. setColor3(name: string, value: Color3): ShaderMaterial;
  72559. /**
  72560. * Set a vec3 array in the shader from a Color3 array.
  72561. * @param name Define the name of the uniform as defined in the shader
  72562. * @param value Define the value to give to the uniform
  72563. * @return the material itself allowing "fluent" like uniform updates
  72564. */
  72565. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  72566. /**
  72567. * Set a vec4 in the shader from a Color4.
  72568. * @param name Define the name of the uniform as defined in the shader
  72569. * @param value Define the value to give to the uniform
  72570. * @return the material itself allowing "fluent" like uniform updates
  72571. */
  72572. setColor4(name: string, value: Color4): ShaderMaterial;
  72573. /**
  72574. * Set a vec2 in the shader from a Vector2.
  72575. * @param name Define the name of the uniform as defined in the shader
  72576. * @param value Define the value to give to the uniform
  72577. * @return the material itself allowing "fluent" like uniform updates
  72578. */
  72579. setVector2(name: string, value: Vector2): ShaderMaterial;
  72580. /**
  72581. * Set a vec3 in the shader from a Vector3.
  72582. * @param name Define the name of the uniform as defined in the shader
  72583. * @param value Define the value to give to the uniform
  72584. * @return the material itself allowing "fluent" like uniform updates
  72585. */
  72586. setVector3(name: string, value: Vector3): ShaderMaterial;
  72587. /**
  72588. * Set a vec4 in the shader from a Vector4.
  72589. * @param name Define the name of the uniform as defined in the shader
  72590. * @param value Define the value to give to the uniform
  72591. * @return the material itself allowing "fluent" like uniform updates
  72592. */
  72593. setVector4(name: string, value: Vector4): ShaderMaterial;
  72594. /**
  72595. * Set a mat4 in the shader from a Matrix.
  72596. * @param name Define the name of the uniform as defined in the shader
  72597. * @param value Define the value to give to the uniform
  72598. * @return the material itself allowing "fluent" like uniform updates
  72599. */
  72600. setMatrix(name: string, value: Matrix): ShaderMaterial;
  72601. /**
  72602. * Set a mat3 in the shader from a Float32Array.
  72603. * @param name Define the name of the uniform as defined in the shader
  72604. * @param value Define the value to give to the uniform
  72605. * @return the material itself allowing "fluent" like uniform updates
  72606. */
  72607. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  72608. /**
  72609. * Set a mat2 in the shader from a Float32Array.
  72610. * @param name Define the name of the uniform as defined in the shader
  72611. * @param value Define the value to give to the uniform
  72612. * @return the material itself allowing "fluent" like uniform updates
  72613. */
  72614. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  72615. /**
  72616. * Set a vec2 array in the shader from a number array.
  72617. * @param name Define the name of the uniform as defined in the shader
  72618. * @param value Define the value to give to the uniform
  72619. * @return the material itself allowing "fluent" like uniform updates
  72620. */
  72621. setArray2(name: string, value: number[]): ShaderMaterial;
  72622. /**
  72623. * Set a vec3 array in the shader from a number array.
  72624. * @param name Define the name of the uniform as defined in the shader
  72625. * @param value Define the value to give to the uniform
  72626. * @return the material itself allowing "fluent" like uniform updates
  72627. */
  72628. setArray3(name: string, value: number[]): ShaderMaterial;
  72629. private _checkCache;
  72630. /**
  72631. * Checks if the material is ready to render the requested mesh
  72632. * @param mesh Define the mesh to render
  72633. * @param useInstances Define whether or not the material is used with instances
  72634. * @returns true if ready, otherwise false
  72635. */
  72636. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  72637. /**
  72638. * Binds the world matrix to the material
  72639. * @param world defines the world transformation matrix
  72640. */
  72641. bindOnlyWorldMatrix(world: Matrix): void;
  72642. /**
  72643. * Binds the material to the mesh
  72644. * @param world defines the world transformation matrix
  72645. * @param mesh defines the mesh to bind the material to
  72646. */
  72647. bind(world: Matrix, mesh?: Mesh): void;
  72648. /**
  72649. * Gets the active textures from the material
  72650. * @returns an array of textures
  72651. */
  72652. getActiveTextures(): BaseTexture[];
  72653. /**
  72654. * Specifies if the material uses a texture
  72655. * @param texture defines the texture to check against the material
  72656. * @returns a boolean specifying if the material uses the texture
  72657. */
  72658. hasTexture(texture: BaseTexture): boolean;
  72659. /**
  72660. * Makes a duplicate of the material, and gives it a new name
  72661. * @param name defines the new name for the duplicated material
  72662. * @returns the cloned material
  72663. */
  72664. clone(name: string): ShaderMaterial;
  72665. /**
  72666. * Disposes the material
  72667. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72668. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  72669. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  72670. */
  72671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  72672. /**
  72673. * Serializes this material in a JSON representation
  72674. * @returns the serialized material object
  72675. */
  72676. serialize(): any;
  72677. /**
  72678. * Creates a shader material from parsed shader material data
  72679. * @param source defines the JSON represnetation of the material
  72680. * @param scene defines the hosting scene
  72681. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72682. * @returns a new material
  72683. */
  72684. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  72685. }
  72686. }
  72687. declare module BABYLON {
  72688. /** @hidden */
  72689. export var colorPixelShader: {
  72690. name: string;
  72691. shader: string;
  72692. };
  72693. }
  72694. declare module BABYLON {
  72695. /** @hidden */
  72696. export var colorVertexShader: {
  72697. name: string;
  72698. shader: string;
  72699. };
  72700. }
  72701. declare module BABYLON {
  72702. /**
  72703. * Line mesh
  72704. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  72705. */
  72706. export class LinesMesh extends Mesh {
  72707. /**
  72708. * If vertex color should be applied to the mesh
  72709. */
  72710. useVertexColor?: boolean | undefined;
  72711. /**
  72712. * If vertex alpha should be applied to the mesh
  72713. */
  72714. useVertexAlpha?: boolean | undefined;
  72715. /**
  72716. * Color of the line (Default: White)
  72717. */
  72718. color: Color3;
  72719. /**
  72720. * Alpha of the line (Default: 1)
  72721. */
  72722. alpha: number;
  72723. /**
  72724. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  72725. * This margin is expressed in world space coordinates, so its value may vary.
  72726. * Default value is 0.1
  72727. */
  72728. intersectionThreshold: number;
  72729. private _colorShader;
  72730. /**
  72731. * Creates a new LinesMesh
  72732. * @param name defines the name
  72733. * @param scene defines the hosting scene
  72734. * @param parent defines the parent mesh if any
  72735. * @param source defines the optional source LinesMesh used to clone data from
  72736. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  72737. * When false, achieved by calling a clone(), also passing False.
  72738. * This will make creation of children, recursive.
  72739. * @param useVertexColor defines if this LinesMesh supports vertex color
  72740. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  72741. */
  72742. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  72743. /**
  72744. * If vertex color should be applied to the mesh
  72745. */
  72746. useVertexColor?: boolean | undefined,
  72747. /**
  72748. * If vertex alpha should be applied to the mesh
  72749. */
  72750. useVertexAlpha?: boolean | undefined);
  72751. /**
  72752. * Returns the string "LineMesh"
  72753. */
  72754. getClassName(): string;
  72755. /**
  72756. * @hidden
  72757. */
  72758. /**
  72759. * @hidden
  72760. */
  72761. material: Material;
  72762. /**
  72763. * @hidden
  72764. */
  72765. readonly checkCollisions: boolean;
  72766. /** @hidden */
  72767. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  72768. /** @hidden */
  72769. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  72770. /**
  72771. * Disposes of the line mesh
  72772. * @param doNotRecurse If children should be disposed
  72773. */
  72774. dispose(doNotRecurse?: boolean): void;
  72775. /**
  72776. * Returns a new LineMesh object cloned from the current one.
  72777. */
  72778. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  72779. /**
  72780. * Creates a new InstancedLinesMesh object from the mesh model.
  72781. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  72782. * @param name defines the name of the new instance
  72783. * @returns a new InstancedLinesMesh
  72784. */
  72785. createInstance(name: string): InstancedLinesMesh;
  72786. }
  72787. /**
  72788. * Creates an instance based on a source LinesMesh
  72789. */
  72790. export class InstancedLinesMesh extends InstancedMesh {
  72791. /**
  72792. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  72793. * This margin is expressed in world space coordinates, so its value may vary.
  72794. * Initilized with the intersectionThreshold value of the source LinesMesh
  72795. */
  72796. intersectionThreshold: number;
  72797. constructor(name: string, source: LinesMesh);
  72798. /**
  72799. * Returns the string "InstancedLinesMesh".
  72800. */
  72801. getClassName(): string;
  72802. }
  72803. }
  72804. declare module BABYLON {
  72805. /** @hidden */
  72806. export var linePixelShader: {
  72807. name: string;
  72808. shader: string;
  72809. };
  72810. }
  72811. declare module BABYLON {
  72812. /** @hidden */
  72813. export var lineVertexShader: {
  72814. name: string;
  72815. shader: string;
  72816. };
  72817. }
  72818. declare module BABYLON {
  72819. interface AbstractMesh {
  72820. /**
  72821. * Disables the mesh edge rendering mode
  72822. * @returns the currentAbstractMesh
  72823. */
  72824. disableEdgesRendering(): AbstractMesh;
  72825. /**
  72826. * Enables the edge rendering mode on the mesh.
  72827. * This mode makes the mesh edges visible
  72828. * @param epsilon defines the maximal distance between two angles to detect a face
  72829. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72830. * @returns the currentAbstractMesh
  72831. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72832. */
  72833. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72834. /**
  72835. * Gets the edgesRenderer associated with the mesh
  72836. */
  72837. edgesRenderer: Nullable<EdgesRenderer>;
  72838. }
  72839. interface LinesMesh {
  72840. /**
  72841. * Enables the edge rendering mode on the mesh.
  72842. * This mode makes the mesh edges visible
  72843. * @param epsilon defines the maximal distance between two angles to detect a face
  72844. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72845. * @returns the currentAbstractMesh
  72846. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72847. */
  72848. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72849. }
  72850. interface InstancedLinesMesh {
  72851. /**
  72852. * Enables the edge rendering mode on the mesh.
  72853. * This mode makes the mesh edges visible
  72854. * @param epsilon defines the maximal distance between two angles to detect a face
  72855. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72856. * @returns the current InstancedLinesMesh
  72857. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72858. */
  72859. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  72860. }
  72861. /**
  72862. * Defines the minimum contract an Edges renderer should follow.
  72863. */
  72864. export interface IEdgesRenderer extends IDisposable {
  72865. /**
  72866. * Gets or sets a boolean indicating if the edgesRenderer is active
  72867. */
  72868. isEnabled: boolean;
  72869. /**
  72870. * Renders the edges of the attached mesh,
  72871. */
  72872. render(): void;
  72873. /**
  72874. * Checks wether or not the edges renderer is ready to render.
  72875. * @return true if ready, otherwise false.
  72876. */
  72877. isReady(): boolean;
  72878. }
  72879. /**
  72880. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  72881. */
  72882. export class EdgesRenderer implements IEdgesRenderer {
  72883. /**
  72884. * Define the size of the edges with an orthographic camera
  72885. */
  72886. edgesWidthScalerForOrthographic: number;
  72887. /**
  72888. * Define the size of the edges with a perspective camera
  72889. */
  72890. edgesWidthScalerForPerspective: number;
  72891. protected _source: AbstractMesh;
  72892. protected _linesPositions: number[];
  72893. protected _linesNormals: number[];
  72894. protected _linesIndices: number[];
  72895. protected _epsilon: number;
  72896. protected _indicesCount: number;
  72897. protected _lineShader: ShaderMaterial;
  72898. protected _ib: WebGLBuffer;
  72899. protected _buffers: {
  72900. [key: string]: Nullable<VertexBuffer>;
  72901. };
  72902. protected _checkVerticesInsteadOfIndices: boolean;
  72903. private _meshRebuildObserver;
  72904. private _meshDisposeObserver;
  72905. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  72906. isEnabled: boolean;
  72907. /**
  72908. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  72909. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  72910. * @param source Mesh used to create edges
  72911. * @param epsilon sum of angles in adjacency to check for edge
  72912. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  72913. * @param generateEdgesLines - should generate Lines or only prepare resources.
  72914. */
  72915. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  72916. protected _prepareRessources(): void;
  72917. /** @hidden */
  72918. _rebuild(): void;
  72919. /**
  72920. * Releases the required resources for the edges renderer
  72921. */
  72922. dispose(): void;
  72923. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  72924. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  72925. /**
  72926. * Checks if the pair of p0 and p1 is en edge
  72927. * @param faceIndex
  72928. * @param edge
  72929. * @param faceNormals
  72930. * @param p0
  72931. * @param p1
  72932. * @private
  72933. */
  72934. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  72935. /**
  72936. * push line into the position, normal and index buffer
  72937. * @protected
  72938. */
  72939. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  72940. /**
  72941. * Generates lines edges from adjacencjes
  72942. * @private
  72943. */
  72944. _generateEdgesLines(): void;
  72945. /**
  72946. * Checks wether or not the edges renderer is ready to render.
  72947. * @return true if ready, otherwise false.
  72948. */
  72949. isReady(): boolean;
  72950. /**
  72951. * Renders the edges of the attached mesh,
  72952. */
  72953. render(): void;
  72954. }
  72955. /**
  72956. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  72957. */
  72958. export class LineEdgesRenderer extends EdgesRenderer {
  72959. /**
  72960. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  72961. * @param source LineMesh used to generate edges
  72962. * @param epsilon not important (specified angle for edge detection)
  72963. * @param checkVerticesInsteadOfIndices not important for LineMesh
  72964. */
  72965. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  72966. /**
  72967. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  72968. */
  72969. _generateEdgesLines(): void;
  72970. }
  72971. }
  72972. declare module BABYLON {
  72973. /**
  72974. * This represents the object necessary to create a rendering group.
  72975. * This is exclusively used and created by the rendering manager.
  72976. * To modify the behavior, you use the available helpers in your scene or meshes.
  72977. * @hidden
  72978. */
  72979. export class RenderingGroup {
  72980. index: number;
  72981. private _scene;
  72982. private _opaqueSubMeshes;
  72983. private _transparentSubMeshes;
  72984. private _alphaTestSubMeshes;
  72985. private _depthOnlySubMeshes;
  72986. private _particleSystems;
  72987. private _spriteManagers;
  72988. private _opaqueSortCompareFn;
  72989. private _alphaTestSortCompareFn;
  72990. private _transparentSortCompareFn;
  72991. private _renderOpaque;
  72992. private _renderAlphaTest;
  72993. private _renderTransparent;
  72994. private _edgesRenderers;
  72995. onBeforeTransparentRendering: () => void;
  72996. /**
  72997. * Set the opaque sort comparison function.
  72998. * If null the sub meshes will be render in the order they were created
  72999. */
  73000. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73001. /**
  73002. * Set the alpha test sort comparison function.
  73003. * If null the sub meshes will be render in the order they were created
  73004. */
  73005. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73006. /**
  73007. * Set the transparent sort comparison function.
  73008. * If null the sub meshes will be render in the order they were created
  73009. */
  73010. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73011. /**
  73012. * Creates a new rendering group.
  73013. * @param index The rendering group index
  73014. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73015. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73016. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73017. */
  73018. 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>);
  73019. /**
  73020. * Render all the sub meshes contained in the group.
  73021. * @param customRenderFunction Used to override the default render behaviour of the group.
  73022. * @returns true if rendered some submeshes.
  73023. */
  73024. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73025. /**
  73026. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73027. * @param subMeshes The submeshes to render
  73028. */
  73029. private renderOpaqueSorted;
  73030. /**
  73031. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73032. * @param subMeshes The submeshes to render
  73033. */
  73034. private renderAlphaTestSorted;
  73035. /**
  73036. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73037. * @param subMeshes The submeshes to render
  73038. */
  73039. private renderTransparentSorted;
  73040. /**
  73041. * Renders the submeshes in a specified order.
  73042. * @param subMeshes The submeshes to sort before render
  73043. * @param sortCompareFn The comparison function use to sort
  73044. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73045. * @param transparent Specifies to activate blending if true
  73046. */
  73047. private static renderSorted;
  73048. /**
  73049. * Renders the submeshes in the order they were dispatched (no sort applied).
  73050. * @param subMeshes The submeshes to render
  73051. */
  73052. private static renderUnsorted;
  73053. /**
  73054. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73055. * are rendered back to front if in the same alpha index.
  73056. *
  73057. * @param a The first submesh
  73058. * @param b The second submesh
  73059. * @returns The result of the comparison
  73060. */
  73061. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73062. /**
  73063. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73064. * are rendered back to front.
  73065. *
  73066. * @param a The first submesh
  73067. * @param b The second submesh
  73068. * @returns The result of the comparison
  73069. */
  73070. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73071. /**
  73072. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73073. * are rendered front to back (prevent overdraw).
  73074. *
  73075. * @param a The first submesh
  73076. * @param b The second submesh
  73077. * @returns The result of the comparison
  73078. */
  73079. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73080. /**
  73081. * Resets the different lists of submeshes to prepare a new frame.
  73082. */
  73083. prepare(): void;
  73084. dispose(): void;
  73085. /**
  73086. * Inserts the submesh in its correct queue depending on its material.
  73087. * @param subMesh The submesh to dispatch
  73088. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73089. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73090. */
  73091. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73092. dispatchSprites(spriteManager: ISpriteManager): void;
  73093. dispatchParticles(particleSystem: IParticleSystem): void;
  73094. private _renderParticles;
  73095. private _renderSprites;
  73096. }
  73097. }
  73098. declare module BABYLON {
  73099. /**
  73100. * Interface describing the different options available in the rendering manager
  73101. * regarding Auto Clear between groups.
  73102. */
  73103. export interface IRenderingManagerAutoClearSetup {
  73104. /**
  73105. * Defines whether or not autoclear is enable.
  73106. */
  73107. autoClear: boolean;
  73108. /**
  73109. * Defines whether or not to autoclear the depth buffer.
  73110. */
  73111. depth: boolean;
  73112. /**
  73113. * Defines whether or not to autoclear the stencil buffer.
  73114. */
  73115. stencil: boolean;
  73116. }
  73117. /**
  73118. * This class is used by the onRenderingGroupObservable
  73119. */
  73120. export class RenderingGroupInfo {
  73121. /**
  73122. * The Scene that being rendered
  73123. */
  73124. scene: Scene;
  73125. /**
  73126. * The camera currently used for the rendering pass
  73127. */
  73128. camera: Nullable<Camera>;
  73129. /**
  73130. * The ID of the renderingGroup being processed
  73131. */
  73132. renderingGroupId: number;
  73133. }
  73134. /**
  73135. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73136. * It is enable to manage the different groups as well as the different necessary sort functions.
  73137. * This should not be used directly aside of the few static configurations
  73138. */
  73139. export class RenderingManager {
  73140. /**
  73141. * The max id used for rendering groups (not included)
  73142. */
  73143. static MAX_RENDERINGGROUPS: number;
  73144. /**
  73145. * The min id used for rendering groups (included)
  73146. */
  73147. static MIN_RENDERINGGROUPS: number;
  73148. /**
  73149. * Used to globally prevent autoclearing scenes.
  73150. */
  73151. static AUTOCLEAR: boolean;
  73152. /**
  73153. * @hidden
  73154. */
  73155. _useSceneAutoClearSetup: boolean;
  73156. private _scene;
  73157. private _renderingGroups;
  73158. private _depthStencilBufferAlreadyCleaned;
  73159. private _autoClearDepthStencil;
  73160. private _customOpaqueSortCompareFn;
  73161. private _customAlphaTestSortCompareFn;
  73162. private _customTransparentSortCompareFn;
  73163. private _renderingGroupInfo;
  73164. /**
  73165. * Instantiates a new rendering group for a particular scene
  73166. * @param scene Defines the scene the groups belongs to
  73167. */
  73168. constructor(scene: Scene);
  73169. private _clearDepthStencilBuffer;
  73170. /**
  73171. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73172. * @hidden
  73173. */
  73174. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73175. /**
  73176. * Resets the different information of the group to prepare a new frame
  73177. * @hidden
  73178. */
  73179. reset(): void;
  73180. /**
  73181. * Dispose and release the group and its associated resources.
  73182. * @hidden
  73183. */
  73184. dispose(): void;
  73185. /**
  73186. * Clear the info related to rendering groups preventing retention points during dispose.
  73187. */
  73188. freeRenderingGroups(): void;
  73189. private _prepareRenderingGroup;
  73190. /**
  73191. * Add a sprite manager to the rendering manager in order to render it this frame.
  73192. * @param spriteManager Define the sprite manager to render
  73193. */
  73194. dispatchSprites(spriteManager: ISpriteManager): void;
  73195. /**
  73196. * Add a particle system to the rendering manager in order to render it this frame.
  73197. * @param particleSystem Define the particle system to render
  73198. */
  73199. dispatchParticles(particleSystem: IParticleSystem): void;
  73200. /**
  73201. * Add a submesh to the manager in order to render it this frame
  73202. * @param subMesh The submesh to dispatch
  73203. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73204. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73205. */
  73206. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73207. /**
  73208. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73209. * This allowed control for front to back rendering or reversly depending of the special needs.
  73210. *
  73211. * @param renderingGroupId The rendering group id corresponding to its index
  73212. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73213. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73214. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73215. */
  73216. 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;
  73217. /**
  73218. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73219. *
  73220. * @param renderingGroupId The rendering group id corresponding to its index
  73221. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73222. * @param depth Automatically clears depth between groups if true and autoClear is true.
  73223. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  73224. */
  73225. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  73226. /**
  73227. * Gets the current auto clear configuration for one rendering group of the rendering
  73228. * manager.
  73229. * @param index the rendering group index to get the information for
  73230. * @returns The auto clear setup for the requested rendering group
  73231. */
  73232. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  73233. }
  73234. }
  73235. declare module BABYLON {
  73236. /**
  73237. * This Helps creating a texture that will be created from a camera in your scene.
  73238. * It is basically a dynamic texture that could be used to create special effects for instance.
  73239. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  73240. */
  73241. export class RenderTargetTexture extends Texture {
  73242. isCube: boolean;
  73243. /**
  73244. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  73245. */
  73246. static readonly REFRESHRATE_RENDER_ONCE: number;
  73247. /**
  73248. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  73249. */
  73250. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  73251. /**
  73252. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  73253. * the central point of your effect and can save a lot of performances.
  73254. */
  73255. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  73256. /**
  73257. * Use this predicate to dynamically define the list of mesh you want to render.
  73258. * If set, the renderList property will be overwritten.
  73259. */
  73260. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  73261. private _renderList;
  73262. /**
  73263. * Use this list to define the list of mesh you want to render.
  73264. */
  73265. renderList: Nullable<Array<AbstractMesh>>;
  73266. private _hookArray;
  73267. /**
  73268. * Define if particles should be rendered in your texture.
  73269. */
  73270. renderParticles: boolean;
  73271. /**
  73272. * Define if sprites should be rendered in your texture.
  73273. */
  73274. renderSprites: boolean;
  73275. /**
  73276. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  73277. */
  73278. coordinatesMode: number;
  73279. /**
  73280. * Define the camera used to render the texture.
  73281. */
  73282. activeCamera: Nullable<Camera>;
  73283. /**
  73284. * Override the render function of the texture with your own one.
  73285. */
  73286. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  73287. /**
  73288. * Define if camera post processes should be use while rendering the texture.
  73289. */
  73290. useCameraPostProcesses: boolean;
  73291. /**
  73292. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  73293. */
  73294. ignoreCameraViewport: boolean;
  73295. private _postProcessManager;
  73296. private _postProcesses;
  73297. private _resizeObserver;
  73298. /**
  73299. * An event triggered when the texture is unbind.
  73300. */
  73301. onBeforeBindObservable: Observable<RenderTargetTexture>;
  73302. /**
  73303. * An event triggered when the texture is unbind.
  73304. */
  73305. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  73306. private _onAfterUnbindObserver;
  73307. /**
  73308. * Set a after unbind callback in the texture.
  73309. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  73310. */
  73311. onAfterUnbind: () => void;
  73312. /**
  73313. * An event triggered before rendering the texture
  73314. */
  73315. onBeforeRenderObservable: Observable<number>;
  73316. private _onBeforeRenderObserver;
  73317. /**
  73318. * Set a before render callback in the texture.
  73319. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  73320. */
  73321. onBeforeRender: (faceIndex: number) => void;
  73322. /**
  73323. * An event triggered after rendering the texture
  73324. */
  73325. onAfterRenderObservable: Observable<number>;
  73326. private _onAfterRenderObserver;
  73327. /**
  73328. * Set a after render callback in the texture.
  73329. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  73330. */
  73331. onAfterRender: (faceIndex: number) => void;
  73332. /**
  73333. * An event triggered after the texture clear
  73334. */
  73335. onClearObservable: Observable<Engine>;
  73336. private _onClearObserver;
  73337. /**
  73338. * Set a clear callback in the texture.
  73339. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  73340. */
  73341. onClear: (Engine: Engine) => void;
  73342. /**
  73343. * Define the clear color of the Render Target if it should be different from the scene.
  73344. */
  73345. clearColor: Color4;
  73346. protected _size: number | {
  73347. width: number;
  73348. height: number;
  73349. };
  73350. protected _initialSizeParameter: number | {
  73351. width: number;
  73352. height: number;
  73353. } | {
  73354. ratio: number;
  73355. };
  73356. protected _sizeRatio: Nullable<number>;
  73357. /** @hidden */
  73358. _generateMipMaps: boolean;
  73359. protected _renderingManager: RenderingManager;
  73360. /** @hidden */
  73361. _waitingRenderList: string[];
  73362. protected _doNotChangeAspectRatio: boolean;
  73363. protected _currentRefreshId: number;
  73364. protected _refreshRate: number;
  73365. protected _textureMatrix: Matrix;
  73366. protected _samples: number;
  73367. protected _renderTargetOptions: RenderTargetCreationOptions;
  73368. /**
  73369. * Gets render target creation options that were used.
  73370. */
  73371. readonly renderTargetOptions: RenderTargetCreationOptions;
  73372. protected _engine: Engine;
  73373. protected _onRatioRescale(): void;
  73374. /**
  73375. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  73376. * It must define where the camera used to render the texture is set
  73377. */
  73378. boundingBoxPosition: Vector3;
  73379. private _boundingBoxSize;
  73380. /**
  73381. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  73382. * When defined, the cubemap will switch to local mode
  73383. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73384. * @example https://www.babylonjs-playground.com/#RNASML
  73385. */
  73386. boundingBoxSize: Vector3;
  73387. /**
  73388. * In case the RTT has been created with a depth texture, get the associated
  73389. * depth texture.
  73390. * Otherwise, return null.
  73391. */
  73392. depthStencilTexture: Nullable<InternalTexture>;
  73393. /**
  73394. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  73395. * or used a shadow, depth texture...
  73396. * @param name The friendly name of the texture
  73397. * @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)
  73398. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  73399. * @param generateMipMaps True if mip maps need to be generated after render.
  73400. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  73401. * @param type The type of the buffer in the RTT (int, half float, float...)
  73402. * @param isCube True if a cube texture needs to be created
  73403. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  73404. * @param generateDepthBuffer True to generate a depth buffer
  73405. * @param generateStencilBuffer True to generate a stencil buffer
  73406. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  73407. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  73408. * @param delayAllocation if the texture allocation should be delayed (default: false)
  73409. */
  73410. constructor(name: string, size: number | {
  73411. width: number;
  73412. height: number;
  73413. } | {
  73414. ratio: number;
  73415. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  73416. /**
  73417. * Creates a depth stencil texture.
  73418. * This is only available in WebGL 2 or with the depth texture extension available.
  73419. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  73420. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  73421. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  73422. */
  73423. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  73424. private _processSizeParameter;
  73425. /**
  73426. * Define the number of samples to use in case of MSAA.
  73427. * It defaults to one meaning no MSAA has been enabled.
  73428. */
  73429. samples: number;
  73430. /**
  73431. * Resets the refresh counter of the texture and start bak from scratch.
  73432. * Could be useful to regenerate the texture if it is setup to render only once.
  73433. */
  73434. resetRefreshCounter(): void;
  73435. /**
  73436. * Define the refresh rate of the texture or the rendering frequency.
  73437. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73438. */
  73439. refreshRate: number;
  73440. /**
  73441. * Adds a post process to the render target rendering passes.
  73442. * @param postProcess define the post process to add
  73443. */
  73444. addPostProcess(postProcess: PostProcess): void;
  73445. /**
  73446. * Clear all the post processes attached to the render target
  73447. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  73448. */
  73449. clearPostProcesses(dispose?: boolean): void;
  73450. /**
  73451. * Remove one of the post process from the list of attached post processes to the texture
  73452. * @param postProcess define the post process to remove from the list
  73453. */
  73454. removePostProcess(postProcess: PostProcess): void;
  73455. /** @hidden */
  73456. _shouldRender(): boolean;
  73457. /**
  73458. * Gets the actual render size of the texture.
  73459. * @returns the width of the render size
  73460. */
  73461. getRenderSize(): number;
  73462. /**
  73463. * Gets the actual render width of the texture.
  73464. * @returns the width of the render size
  73465. */
  73466. getRenderWidth(): number;
  73467. /**
  73468. * Gets the actual render height of the texture.
  73469. * @returns the height of the render size
  73470. */
  73471. getRenderHeight(): number;
  73472. /**
  73473. * Get if the texture can be rescaled or not.
  73474. */
  73475. readonly canRescale: boolean;
  73476. /**
  73477. * Resize the texture using a ratio.
  73478. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  73479. */
  73480. scale(ratio: number): void;
  73481. /**
  73482. * Get the texture reflection matrix used to rotate/transform the reflection.
  73483. * @returns the reflection matrix
  73484. */
  73485. getReflectionTextureMatrix(): Matrix;
  73486. /**
  73487. * Resize the texture to a new desired size.
  73488. * Be carrefull as it will recreate all the data in the new texture.
  73489. * @param size Define the new size. It can be:
  73490. * - a number for squared texture,
  73491. * - an object containing { width: number, height: number }
  73492. * - or an object containing a ratio { ratio: number }
  73493. */
  73494. resize(size: number | {
  73495. width: number;
  73496. height: number;
  73497. } | {
  73498. ratio: number;
  73499. }): void;
  73500. /**
  73501. * Renders all the objects from the render list into the texture.
  73502. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  73503. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  73504. */
  73505. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  73506. private _bestReflectionRenderTargetDimension;
  73507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  73508. private renderToTarget;
  73509. /**
  73510. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  73511. * This allowed control for front to back rendering or reversly depending of the special needs.
  73512. *
  73513. * @param renderingGroupId The rendering group id corresponding to its index
  73514. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  73515. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  73516. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  73517. */
  73518. 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;
  73519. /**
  73520. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  73521. *
  73522. * @param renderingGroupId The rendering group id corresponding to its index
  73523. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  73524. */
  73525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  73526. /**
  73527. * Clones the texture.
  73528. * @returns the cloned texture
  73529. */
  73530. clone(): RenderTargetTexture;
  73531. /**
  73532. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  73533. * @returns The JSON representation of the texture
  73534. */
  73535. serialize(): any;
  73536. /**
  73537. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  73538. */
  73539. disposeFramebufferObjects(): void;
  73540. /**
  73541. * Dispose the texture and release its associated resources.
  73542. */
  73543. dispose(): void;
  73544. /** @hidden */
  73545. _rebuild(): void;
  73546. /**
  73547. * Clear the info related to rendering groups preventing retention point in material dispose.
  73548. */
  73549. freeRenderingGroups(): void;
  73550. }
  73551. }
  73552. declare module BABYLON {
  73553. /**
  73554. * Base class for the main features of a material in Babylon.js
  73555. */
  73556. export class Material implements IAnimatable {
  73557. /**
  73558. * Returns the triangle fill mode
  73559. */
  73560. static readonly TriangleFillMode: number;
  73561. /**
  73562. * Returns the wireframe mode
  73563. */
  73564. static readonly WireFrameFillMode: number;
  73565. /**
  73566. * Returns the point fill mode
  73567. */
  73568. static readonly PointFillMode: number;
  73569. /**
  73570. * Returns the point list draw mode
  73571. */
  73572. static readonly PointListDrawMode: number;
  73573. /**
  73574. * Returns the line list draw mode
  73575. */
  73576. static readonly LineListDrawMode: number;
  73577. /**
  73578. * Returns the line loop draw mode
  73579. */
  73580. static readonly LineLoopDrawMode: number;
  73581. /**
  73582. * Returns the line strip draw mode
  73583. */
  73584. static readonly LineStripDrawMode: number;
  73585. /**
  73586. * Returns the triangle strip draw mode
  73587. */
  73588. static readonly TriangleStripDrawMode: number;
  73589. /**
  73590. * Returns the triangle fan draw mode
  73591. */
  73592. static readonly TriangleFanDrawMode: number;
  73593. /**
  73594. * Stores the clock-wise side orientation
  73595. */
  73596. static readonly ClockWiseSideOrientation: number;
  73597. /**
  73598. * Stores the counter clock-wise side orientation
  73599. */
  73600. static readonly CounterClockWiseSideOrientation: number;
  73601. /**
  73602. * The dirty texture flag value
  73603. */
  73604. static readonly TextureDirtyFlag: number;
  73605. /**
  73606. * The dirty light flag value
  73607. */
  73608. static readonly LightDirtyFlag: number;
  73609. /**
  73610. * The dirty fresnel flag value
  73611. */
  73612. static readonly FresnelDirtyFlag: number;
  73613. /**
  73614. * The dirty attribute flag value
  73615. */
  73616. static readonly AttributesDirtyFlag: number;
  73617. /**
  73618. * The dirty misc flag value
  73619. */
  73620. static readonly MiscDirtyFlag: number;
  73621. /**
  73622. * The all dirty flag value
  73623. */
  73624. static readonly AllDirtyFlag: number;
  73625. /**
  73626. * The ID of the material
  73627. */
  73628. id: string;
  73629. /**
  73630. * Gets or sets the unique id of the material
  73631. */
  73632. uniqueId: number;
  73633. /**
  73634. * The name of the material
  73635. */
  73636. name: string;
  73637. /**
  73638. * Gets or sets user defined metadata
  73639. */
  73640. metadata: any;
  73641. /**
  73642. * For internal use only. Please do not use.
  73643. */
  73644. reservedDataStore: any;
  73645. /**
  73646. * Specifies if the ready state should be checked on each call
  73647. */
  73648. checkReadyOnEveryCall: boolean;
  73649. /**
  73650. * Specifies if the ready state should be checked once
  73651. */
  73652. checkReadyOnlyOnce: boolean;
  73653. /**
  73654. * The state of the material
  73655. */
  73656. state: string;
  73657. /**
  73658. * The alpha value of the material
  73659. */
  73660. protected _alpha: number;
  73661. /**
  73662. * Sets the alpha value of the material
  73663. */
  73664. /**
  73665. * Gets the alpha value of the material
  73666. */
  73667. alpha: number;
  73668. /**
  73669. * Specifies if back face culling is enabled
  73670. */
  73671. protected _backFaceCulling: boolean;
  73672. /**
  73673. * Sets the back-face culling state
  73674. */
  73675. /**
  73676. * Gets the back-face culling state
  73677. */
  73678. backFaceCulling: boolean;
  73679. /**
  73680. * Stores the value for side orientation
  73681. */
  73682. sideOrientation: number;
  73683. /**
  73684. * Callback triggered when the material is compiled
  73685. */
  73686. onCompiled: (effect: Effect) => void;
  73687. /**
  73688. * Callback triggered when an error occurs
  73689. */
  73690. onError: (effect: Effect, errors: string) => void;
  73691. /**
  73692. * Callback triggered to get the render target textures
  73693. */
  73694. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  73695. /**
  73696. * Gets a boolean indicating that current material needs to register RTT
  73697. */
  73698. readonly hasRenderTargetTextures: boolean;
  73699. /**
  73700. * Specifies if the material should be serialized
  73701. */
  73702. doNotSerialize: boolean;
  73703. /**
  73704. * @hidden
  73705. */
  73706. _storeEffectOnSubMeshes: boolean;
  73707. /**
  73708. * Stores the animations for the material
  73709. */
  73710. animations: Array<Animation>;
  73711. /**
  73712. * An event triggered when the material is disposed
  73713. */
  73714. onDisposeObservable: Observable<Material>;
  73715. /**
  73716. * An observer which watches for dispose events
  73717. */
  73718. private _onDisposeObserver;
  73719. private _onUnBindObservable;
  73720. /**
  73721. * Called during a dispose event
  73722. */
  73723. onDispose: () => void;
  73724. private _onBindObservable;
  73725. /**
  73726. * An event triggered when the material is bound
  73727. */
  73728. readonly onBindObservable: Observable<AbstractMesh>;
  73729. /**
  73730. * An observer which watches for bind events
  73731. */
  73732. private _onBindObserver;
  73733. /**
  73734. * Called during a bind event
  73735. */
  73736. onBind: (Mesh: AbstractMesh) => void;
  73737. /**
  73738. * An event triggered when the material is unbound
  73739. */
  73740. readonly onUnBindObservable: Observable<Material>;
  73741. /**
  73742. * Stores the value of the alpha mode
  73743. */
  73744. private _alphaMode;
  73745. /**
  73746. * Sets the value of the alpha mode.
  73747. *
  73748. * | Value | Type | Description |
  73749. * | --- | --- | --- |
  73750. * | 0 | ALPHA_DISABLE | |
  73751. * | 1 | ALPHA_ADD | |
  73752. * | 2 | ALPHA_COMBINE | |
  73753. * | 3 | ALPHA_SUBTRACT | |
  73754. * | 4 | ALPHA_MULTIPLY | |
  73755. * | 5 | ALPHA_MAXIMIZED | |
  73756. * | 6 | ALPHA_ONEONE | |
  73757. * | 7 | ALPHA_PREMULTIPLIED | |
  73758. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  73759. * | 9 | ALPHA_INTERPOLATE | |
  73760. * | 10 | ALPHA_SCREENMODE | |
  73761. *
  73762. */
  73763. /**
  73764. * Gets the value of the alpha mode
  73765. */
  73766. alphaMode: number;
  73767. /**
  73768. * Stores the state of the need depth pre-pass value
  73769. */
  73770. private _needDepthPrePass;
  73771. /**
  73772. * Sets the need depth pre-pass value
  73773. */
  73774. /**
  73775. * Gets the depth pre-pass value
  73776. */
  73777. needDepthPrePass: boolean;
  73778. /**
  73779. * Specifies if depth writing should be disabled
  73780. */
  73781. disableDepthWrite: boolean;
  73782. /**
  73783. * Specifies if depth writing should be forced
  73784. */
  73785. forceDepthWrite: boolean;
  73786. /**
  73787. * Specifies if there should be a separate pass for culling
  73788. */
  73789. separateCullingPass: boolean;
  73790. /**
  73791. * Stores the state specifing if fog should be enabled
  73792. */
  73793. private _fogEnabled;
  73794. /**
  73795. * Sets the state for enabling fog
  73796. */
  73797. /**
  73798. * Gets the value of the fog enabled state
  73799. */
  73800. fogEnabled: boolean;
  73801. /**
  73802. * Stores the size of points
  73803. */
  73804. pointSize: number;
  73805. /**
  73806. * Stores the z offset value
  73807. */
  73808. zOffset: number;
  73809. /**
  73810. * Gets a value specifying if wireframe mode is enabled
  73811. */
  73812. /**
  73813. * Sets the state of wireframe mode
  73814. */
  73815. wireframe: boolean;
  73816. /**
  73817. * Gets the value specifying if point clouds are enabled
  73818. */
  73819. /**
  73820. * Sets the state of point cloud mode
  73821. */
  73822. pointsCloud: boolean;
  73823. /**
  73824. * Gets the material fill mode
  73825. */
  73826. /**
  73827. * Sets the material fill mode
  73828. */
  73829. fillMode: number;
  73830. /**
  73831. * @hidden
  73832. * Stores the effects for the material
  73833. */
  73834. _effect: Nullable<Effect>;
  73835. /**
  73836. * @hidden
  73837. * Specifies if the material was previously ready
  73838. */
  73839. _wasPreviouslyReady: boolean;
  73840. /**
  73841. * Specifies if uniform buffers should be used
  73842. */
  73843. private _useUBO;
  73844. /**
  73845. * Stores a reference to the scene
  73846. */
  73847. private _scene;
  73848. /**
  73849. * Stores the fill mode state
  73850. */
  73851. private _fillMode;
  73852. /**
  73853. * Specifies if the depth write state should be cached
  73854. */
  73855. private _cachedDepthWriteState;
  73856. /**
  73857. * Stores the uniform buffer
  73858. */
  73859. protected _uniformBuffer: UniformBuffer;
  73860. /** @hidden */
  73861. _indexInSceneMaterialArray: number;
  73862. /** @hidden */
  73863. meshMap: Nullable<{
  73864. [id: string]: AbstractMesh | undefined;
  73865. }>;
  73866. /**
  73867. * Creates a material instance
  73868. * @param name defines the name of the material
  73869. * @param scene defines the scene to reference
  73870. * @param doNotAdd specifies if the material should be added to the scene
  73871. */
  73872. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  73873. /**
  73874. * Returns a string representation of the current material
  73875. * @param fullDetails defines a boolean indicating which levels of logging is desired
  73876. * @returns a string with material information
  73877. */
  73878. toString(fullDetails?: boolean): string;
  73879. /**
  73880. * Gets the class name of the material
  73881. * @returns a string with the class name of the material
  73882. */
  73883. getClassName(): string;
  73884. /**
  73885. * Specifies if updates for the material been locked
  73886. */
  73887. readonly isFrozen: boolean;
  73888. /**
  73889. * Locks updates for the material
  73890. */
  73891. freeze(): void;
  73892. /**
  73893. * Unlocks updates for the material
  73894. */
  73895. unfreeze(): void;
  73896. /**
  73897. * Specifies if the material is ready to be used
  73898. * @param mesh defines the mesh to check
  73899. * @param useInstances specifies if instances should be used
  73900. * @returns a boolean indicating if the material is ready to be used
  73901. */
  73902. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73903. /**
  73904. * Specifies that the submesh is ready to be used
  73905. * @param mesh defines the mesh to check
  73906. * @param subMesh defines which submesh to check
  73907. * @param useInstances specifies that instances should be used
  73908. * @returns a boolean indicating that the submesh is ready or not
  73909. */
  73910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  73911. /**
  73912. * Returns the material effect
  73913. * @returns the effect associated with the material
  73914. */
  73915. getEffect(): Nullable<Effect>;
  73916. /**
  73917. * Returns the current scene
  73918. * @returns a Scene
  73919. */
  73920. getScene(): Scene;
  73921. /**
  73922. * Specifies if the material will require alpha blending
  73923. * @returns a boolean specifying if alpha blending is needed
  73924. */
  73925. needAlphaBlending(): boolean;
  73926. /**
  73927. * Specifies if the mesh will require alpha blending
  73928. * @param mesh defines the mesh to check
  73929. * @returns a boolean specifying if alpha blending is needed for the mesh
  73930. */
  73931. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  73932. /**
  73933. * Specifies if this material should be rendered in alpha test mode
  73934. * @returns a boolean specifying if an alpha test is needed.
  73935. */
  73936. needAlphaTesting(): boolean;
  73937. /**
  73938. * Gets the texture used for the alpha test
  73939. * @returns the texture to use for alpha testing
  73940. */
  73941. getAlphaTestTexture(): Nullable<BaseTexture>;
  73942. /**
  73943. * Marks the material to indicate that it needs to be re-calculated
  73944. */
  73945. markDirty(): void;
  73946. /** @hidden */
  73947. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  73948. /**
  73949. * Binds the material to the mesh
  73950. * @param world defines the world transformation matrix
  73951. * @param mesh defines the mesh to bind the material to
  73952. */
  73953. bind(world: Matrix, mesh?: Mesh): void;
  73954. /**
  73955. * Binds the submesh to the material
  73956. * @param world defines the world transformation matrix
  73957. * @param mesh defines the mesh containing the submesh
  73958. * @param subMesh defines the submesh to bind the material to
  73959. */
  73960. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  73961. /**
  73962. * Binds the world matrix to the material
  73963. * @param world defines the world transformation matrix
  73964. */
  73965. bindOnlyWorldMatrix(world: Matrix): void;
  73966. /**
  73967. * Binds the scene's uniform buffer to the effect.
  73968. * @param effect defines the effect to bind to the scene uniform buffer
  73969. * @param sceneUbo defines the uniform buffer storing scene data
  73970. */
  73971. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  73972. /**
  73973. * Binds the view matrix to the effect
  73974. * @param effect defines the effect to bind the view matrix to
  73975. */
  73976. bindView(effect: Effect): void;
  73977. /**
  73978. * Binds the view projection matrix to the effect
  73979. * @param effect defines the effect to bind the view projection matrix to
  73980. */
  73981. bindViewProjection(effect: Effect): void;
  73982. /**
  73983. * Specifies if material alpha testing should be turned on for the mesh
  73984. * @param mesh defines the mesh to check
  73985. */
  73986. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  73987. /**
  73988. * Processes to execute after binding the material to a mesh
  73989. * @param mesh defines the rendered mesh
  73990. */
  73991. protected _afterBind(mesh?: Mesh): void;
  73992. /**
  73993. * Unbinds the material from the mesh
  73994. */
  73995. unbind(): void;
  73996. /**
  73997. * Gets the active textures from the material
  73998. * @returns an array of textures
  73999. */
  74000. getActiveTextures(): BaseTexture[];
  74001. /**
  74002. * Specifies if the material uses a texture
  74003. * @param texture defines the texture to check against the material
  74004. * @returns a boolean specifying if the material uses the texture
  74005. */
  74006. hasTexture(texture: BaseTexture): boolean;
  74007. /**
  74008. * Makes a duplicate of the material, and gives it a new name
  74009. * @param name defines the new name for the duplicated material
  74010. * @returns the cloned material
  74011. */
  74012. clone(name: string): Nullable<Material>;
  74013. /**
  74014. * Gets the meshes bound to the material
  74015. * @returns an array of meshes bound to the material
  74016. */
  74017. getBindedMeshes(): AbstractMesh[];
  74018. /**
  74019. * Force shader compilation
  74020. * @param mesh defines the mesh associated with this material
  74021. * @param onCompiled defines a function to execute once the material is compiled
  74022. * @param options defines the options to configure the compilation
  74023. */
  74024. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  74025. clipPlane: boolean;
  74026. }>): void;
  74027. /**
  74028. * Force shader compilation
  74029. * @param mesh defines the mesh that will use this material
  74030. * @param options defines additional options for compiling the shaders
  74031. * @returns a promise that resolves when the compilation completes
  74032. */
  74033. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  74034. clipPlane: boolean;
  74035. }>): Promise<void>;
  74036. private static readonly _ImageProcessingDirtyCallBack;
  74037. private static readonly _TextureDirtyCallBack;
  74038. private static readonly _FresnelDirtyCallBack;
  74039. private static readonly _MiscDirtyCallBack;
  74040. private static readonly _LightsDirtyCallBack;
  74041. private static readonly _AttributeDirtyCallBack;
  74042. private static _FresnelAndMiscDirtyCallBack;
  74043. private static _TextureAndMiscDirtyCallBack;
  74044. private static readonly _DirtyCallbackArray;
  74045. private static readonly _RunDirtyCallBacks;
  74046. /**
  74047. * Marks a define in the material to indicate that it needs to be re-computed
  74048. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  74049. */
  74050. markAsDirty(flag: number): void;
  74051. /**
  74052. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  74053. * @param func defines a function which checks material defines against the submeshes
  74054. */
  74055. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  74056. /**
  74057. * Indicates that image processing needs to be re-calculated for all submeshes
  74058. */
  74059. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  74060. /**
  74061. * Indicates that textures need to be re-calculated for all submeshes
  74062. */
  74063. protected _markAllSubMeshesAsTexturesDirty(): void;
  74064. /**
  74065. * Indicates that fresnel needs to be re-calculated for all submeshes
  74066. */
  74067. protected _markAllSubMeshesAsFresnelDirty(): void;
  74068. /**
  74069. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  74070. */
  74071. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  74072. /**
  74073. * Indicates that lights need to be re-calculated for all submeshes
  74074. */
  74075. protected _markAllSubMeshesAsLightsDirty(): void;
  74076. /**
  74077. * Indicates that attributes need to be re-calculated for all submeshes
  74078. */
  74079. protected _markAllSubMeshesAsAttributesDirty(): void;
  74080. /**
  74081. * Indicates that misc needs to be re-calculated for all submeshes
  74082. */
  74083. protected _markAllSubMeshesAsMiscDirty(): void;
  74084. /**
  74085. * Indicates that textures and misc need to be re-calculated for all submeshes
  74086. */
  74087. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  74088. /**
  74089. * Disposes the material
  74090. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74091. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74092. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74093. */
  74094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74095. /** @hidden */
  74096. private releaseVertexArrayObject;
  74097. /**
  74098. * Serializes this material
  74099. * @returns the serialized material object
  74100. */
  74101. serialize(): any;
  74102. /**
  74103. * Creates a material from parsed material data
  74104. * @param parsedMaterial defines parsed material data
  74105. * @param scene defines the hosting scene
  74106. * @param rootUrl defines the root URL to use to load textures
  74107. * @returns a new material
  74108. */
  74109. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  74110. }
  74111. }
  74112. declare module BABYLON {
  74113. /**
  74114. * Class used to represent data loading progression
  74115. */
  74116. export class SceneLoaderFlags {
  74117. private static _ForceFullSceneLoadingForIncremental;
  74118. private static _ShowLoadingScreen;
  74119. private static _CleanBoneMatrixWeights;
  74120. private static _loggingLevel;
  74121. /**
  74122. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  74123. */
  74124. static ForceFullSceneLoadingForIncremental: boolean;
  74125. /**
  74126. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  74127. */
  74128. static ShowLoadingScreen: boolean;
  74129. /**
  74130. * Defines the current logging level (while loading the scene)
  74131. * @ignorenaming
  74132. */
  74133. static loggingLevel: number;
  74134. /**
  74135. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  74136. */
  74137. static CleanBoneMatrixWeights: boolean;
  74138. }
  74139. }
  74140. declare module BABYLON {
  74141. /**
  74142. * Defines a target to use with MorphTargetManager
  74143. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  74144. */
  74145. export class MorphTarget implements IAnimatable {
  74146. /** defines the name of the target */
  74147. name: string;
  74148. /**
  74149. * Gets or sets the list of animations
  74150. */
  74151. animations: Animation[];
  74152. private _scene;
  74153. private _positions;
  74154. private _normals;
  74155. private _tangents;
  74156. private _influence;
  74157. /**
  74158. * Observable raised when the influence changes
  74159. */
  74160. onInfluenceChanged: Observable<boolean>;
  74161. /** @hidden */
  74162. _onDataLayoutChanged: Observable<void>;
  74163. /**
  74164. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  74165. */
  74166. influence: number;
  74167. /**
  74168. * Gets or sets the id of the morph Target
  74169. */
  74170. id: string;
  74171. private _animationPropertiesOverride;
  74172. /**
  74173. * Gets or sets the animation properties override
  74174. */
  74175. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  74176. /**
  74177. * Creates a new MorphTarget
  74178. * @param name defines the name of the target
  74179. * @param influence defines the influence to use
  74180. * @param scene defines the scene the morphtarget belongs to
  74181. */
  74182. constructor(
  74183. /** defines the name of the target */
  74184. name: string, influence?: number, scene?: Nullable<Scene>);
  74185. /**
  74186. * Gets a boolean defining if the target contains position data
  74187. */
  74188. readonly hasPositions: boolean;
  74189. /**
  74190. * Gets a boolean defining if the target contains normal data
  74191. */
  74192. readonly hasNormals: boolean;
  74193. /**
  74194. * Gets a boolean defining if the target contains tangent data
  74195. */
  74196. readonly hasTangents: boolean;
  74197. /**
  74198. * Affects position data to this target
  74199. * @param data defines the position data to use
  74200. */
  74201. setPositions(data: Nullable<FloatArray>): void;
  74202. /**
  74203. * Gets the position data stored in this target
  74204. * @returns a FloatArray containing the position data (or null if not present)
  74205. */
  74206. getPositions(): Nullable<FloatArray>;
  74207. /**
  74208. * Affects normal data to this target
  74209. * @param data defines the normal data to use
  74210. */
  74211. setNormals(data: Nullable<FloatArray>): void;
  74212. /**
  74213. * Gets the normal data stored in this target
  74214. * @returns a FloatArray containing the normal data (or null if not present)
  74215. */
  74216. getNormals(): Nullable<FloatArray>;
  74217. /**
  74218. * Affects tangent data to this target
  74219. * @param data defines the tangent data to use
  74220. */
  74221. setTangents(data: Nullable<FloatArray>): void;
  74222. /**
  74223. * Gets the tangent data stored in this target
  74224. * @returns a FloatArray containing the tangent data (or null if not present)
  74225. */
  74226. getTangents(): Nullable<FloatArray>;
  74227. /**
  74228. * Serializes the current target into a Serialization object
  74229. * @returns the serialized object
  74230. */
  74231. serialize(): any;
  74232. /**
  74233. * Returns the string "MorphTarget"
  74234. * @returns "MorphTarget"
  74235. */
  74236. getClassName(): string;
  74237. /**
  74238. * Creates a new target from serialized data
  74239. * @param serializationObject defines the serialized data to use
  74240. * @returns a new MorphTarget
  74241. */
  74242. static Parse(serializationObject: any): MorphTarget;
  74243. /**
  74244. * Creates a MorphTarget from mesh data
  74245. * @param mesh defines the source mesh
  74246. * @param name defines the name to use for the new target
  74247. * @param influence defines the influence to attach to the target
  74248. * @returns a new MorphTarget
  74249. */
  74250. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  74251. }
  74252. }
  74253. declare module BABYLON {
  74254. /**
  74255. * This class is used to deform meshes using morphing between different targets
  74256. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  74257. */
  74258. export class MorphTargetManager {
  74259. private _targets;
  74260. private _targetInfluenceChangedObservers;
  74261. private _targetDataLayoutChangedObservers;
  74262. private _activeTargets;
  74263. private _scene;
  74264. private _influences;
  74265. private _supportsNormals;
  74266. private _supportsTangents;
  74267. private _vertexCount;
  74268. private _uniqueId;
  74269. private _tempInfluences;
  74270. /**
  74271. * Creates a new MorphTargetManager
  74272. * @param scene defines the current scene
  74273. */
  74274. constructor(scene?: Nullable<Scene>);
  74275. /**
  74276. * Gets the unique ID of this manager
  74277. */
  74278. readonly uniqueId: number;
  74279. /**
  74280. * Gets the number of vertices handled by this manager
  74281. */
  74282. readonly vertexCount: number;
  74283. /**
  74284. * Gets a boolean indicating if this manager supports morphing of normals
  74285. */
  74286. readonly supportsNormals: boolean;
  74287. /**
  74288. * Gets a boolean indicating if this manager supports morphing of tangents
  74289. */
  74290. readonly supportsTangents: boolean;
  74291. /**
  74292. * Gets the number of targets stored in this manager
  74293. */
  74294. readonly numTargets: number;
  74295. /**
  74296. * Gets the number of influencers (ie. the number of targets with influences > 0)
  74297. */
  74298. readonly numInfluencers: number;
  74299. /**
  74300. * Gets the list of influences (one per target)
  74301. */
  74302. readonly influences: Float32Array;
  74303. /**
  74304. * Gets the active target at specified index. An active target is a target with an influence > 0
  74305. * @param index defines the index to check
  74306. * @returns the requested target
  74307. */
  74308. getActiveTarget(index: number): MorphTarget;
  74309. /**
  74310. * Gets the target at specified index
  74311. * @param index defines the index to check
  74312. * @returns the requested target
  74313. */
  74314. getTarget(index: number): MorphTarget;
  74315. /**
  74316. * Add a new target to this manager
  74317. * @param target defines the target to add
  74318. */
  74319. addTarget(target: MorphTarget): void;
  74320. /**
  74321. * Removes a target from the manager
  74322. * @param target defines the target to remove
  74323. */
  74324. removeTarget(target: MorphTarget): void;
  74325. /**
  74326. * Serializes the current manager into a Serialization object
  74327. * @returns the serialized object
  74328. */
  74329. serialize(): any;
  74330. private _syncActiveTargets;
  74331. /**
  74332. * Syncrhonize the targets with all the meshes using this morph target manager
  74333. */
  74334. synchronize(): void;
  74335. /**
  74336. * Creates a new MorphTargetManager from serialized data
  74337. * @param serializationObject defines the serialized data
  74338. * @param scene defines the hosting scene
  74339. * @returns the new MorphTargetManager
  74340. */
  74341. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  74342. }
  74343. }
  74344. declare module BABYLON {
  74345. /**
  74346. * Interface for Physics-Joint data
  74347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74348. */
  74349. export interface PhysicsJointData {
  74350. /**
  74351. * The main pivot of the joint
  74352. */
  74353. mainPivot?: Vector3;
  74354. /**
  74355. * The connected pivot of the joint
  74356. */
  74357. connectedPivot?: Vector3;
  74358. /**
  74359. * The main axis of the joint
  74360. */
  74361. mainAxis?: Vector3;
  74362. /**
  74363. * The connected axis of the joint
  74364. */
  74365. connectedAxis?: Vector3;
  74366. /**
  74367. * The collision of the joint
  74368. */
  74369. collision?: boolean;
  74370. /**
  74371. * Native Oimo/Cannon/Energy data
  74372. */
  74373. nativeParams?: any;
  74374. }
  74375. /**
  74376. * This is a holder class for the physics joint created by the physics plugin
  74377. * It holds a set of functions to control the underlying joint
  74378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74379. */
  74380. export class PhysicsJoint {
  74381. /**
  74382. * The type of the physics joint
  74383. */
  74384. type: number;
  74385. /**
  74386. * The data for the physics joint
  74387. */
  74388. jointData: PhysicsJointData;
  74389. private _physicsJoint;
  74390. protected _physicsPlugin: IPhysicsEnginePlugin;
  74391. /**
  74392. * Initializes the physics joint
  74393. * @param type The type of the physics joint
  74394. * @param jointData The data for the physics joint
  74395. */
  74396. constructor(
  74397. /**
  74398. * The type of the physics joint
  74399. */
  74400. type: number,
  74401. /**
  74402. * The data for the physics joint
  74403. */
  74404. jointData: PhysicsJointData);
  74405. /**
  74406. * Gets the physics joint
  74407. */
  74408. /**
  74409. * Sets the physics joint
  74410. */
  74411. physicsJoint: any;
  74412. /**
  74413. * Sets the physics plugin
  74414. */
  74415. physicsPlugin: IPhysicsEnginePlugin;
  74416. /**
  74417. * Execute a function that is physics-plugin specific.
  74418. * @param {Function} func the function that will be executed.
  74419. * It accepts two parameters: the physics world and the physics joint
  74420. */
  74421. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  74422. /**
  74423. * Distance-Joint type
  74424. */
  74425. static DistanceJoint: number;
  74426. /**
  74427. * Hinge-Joint type
  74428. */
  74429. static HingeJoint: number;
  74430. /**
  74431. * Ball-and-Socket joint type
  74432. */
  74433. static BallAndSocketJoint: number;
  74434. /**
  74435. * Wheel-Joint type
  74436. */
  74437. static WheelJoint: number;
  74438. /**
  74439. * Slider-Joint type
  74440. */
  74441. static SliderJoint: number;
  74442. /**
  74443. * Prismatic-Joint type
  74444. */
  74445. static PrismaticJoint: number;
  74446. /**
  74447. * Universal-Joint type
  74448. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  74449. */
  74450. static UniversalJoint: number;
  74451. /**
  74452. * Hinge-Joint 2 type
  74453. */
  74454. static Hinge2Joint: number;
  74455. /**
  74456. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  74457. */
  74458. static PointToPointJoint: number;
  74459. /**
  74460. * Spring-Joint type
  74461. */
  74462. static SpringJoint: number;
  74463. /**
  74464. * Lock-Joint type
  74465. */
  74466. static LockJoint: number;
  74467. }
  74468. /**
  74469. * A class representing a physics distance joint
  74470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74471. */
  74472. export class DistanceJoint extends PhysicsJoint {
  74473. /**
  74474. *
  74475. * @param jointData The data for the Distance-Joint
  74476. */
  74477. constructor(jointData: DistanceJointData);
  74478. /**
  74479. * Update the predefined distance.
  74480. * @param maxDistance The maximum preferred distance
  74481. * @param minDistance The minimum preferred distance
  74482. */
  74483. updateDistance(maxDistance: number, minDistance?: number): void;
  74484. }
  74485. /**
  74486. * Represents a Motor-Enabled Joint
  74487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74488. */
  74489. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  74490. /**
  74491. * Initializes the Motor-Enabled Joint
  74492. * @param type The type of the joint
  74493. * @param jointData The physica joint data for the joint
  74494. */
  74495. constructor(type: number, jointData: PhysicsJointData);
  74496. /**
  74497. * Set the motor values.
  74498. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74499. * @param force the force to apply
  74500. * @param maxForce max force for this motor.
  74501. */
  74502. setMotor(force?: number, maxForce?: number): void;
  74503. /**
  74504. * Set the motor's limits.
  74505. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74506. * @param upperLimit The upper limit of the motor
  74507. * @param lowerLimit The lower limit of the motor
  74508. */
  74509. setLimit(upperLimit: number, lowerLimit?: number): void;
  74510. }
  74511. /**
  74512. * This class represents a single physics Hinge-Joint
  74513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74514. */
  74515. export class HingeJoint extends MotorEnabledJoint {
  74516. /**
  74517. * Initializes the Hinge-Joint
  74518. * @param jointData The joint data for the Hinge-Joint
  74519. */
  74520. constructor(jointData: PhysicsJointData);
  74521. /**
  74522. * Set the motor values.
  74523. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74524. * @param {number} force the force to apply
  74525. * @param {number} maxForce max force for this motor.
  74526. */
  74527. setMotor(force?: number, maxForce?: number): void;
  74528. /**
  74529. * Set the motor's limits.
  74530. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74531. * @param upperLimit The upper limit of the motor
  74532. * @param lowerLimit The lower limit of the motor
  74533. */
  74534. setLimit(upperLimit: number, lowerLimit?: number): void;
  74535. }
  74536. /**
  74537. * This class represents a dual hinge physics joint (same as wheel joint)
  74538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74539. */
  74540. export class Hinge2Joint extends MotorEnabledJoint {
  74541. /**
  74542. * Initializes the Hinge2-Joint
  74543. * @param jointData The joint data for the Hinge2-Joint
  74544. */
  74545. constructor(jointData: PhysicsJointData);
  74546. /**
  74547. * Set the motor values.
  74548. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74549. * @param {number} force the force to apply
  74550. * @param {number} maxForce max force for this motor.
  74551. * @param {motorIndex} the motor's index, 0 or 1.
  74552. */
  74553. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74554. /**
  74555. * Set the motor limits.
  74556. * Attention, this function is plugin specific. Engines won't react 100% the same.
  74557. * @param {number} upperLimit the upper limit
  74558. * @param {number} lowerLimit lower limit
  74559. * @param {motorIndex} the motor's index, 0 or 1.
  74560. */
  74561. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74562. }
  74563. /**
  74564. * Interface for a motor enabled joint
  74565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74566. */
  74567. export interface IMotorEnabledJoint {
  74568. /**
  74569. * Physics joint
  74570. */
  74571. physicsJoint: any;
  74572. /**
  74573. * Sets the motor of the motor-enabled joint
  74574. * @param force The force of the motor
  74575. * @param maxForce The maximum force of the motor
  74576. * @param motorIndex The index of the motor
  74577. */
  74578. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  74579. /**
  74580. * Sets the limit of the motor
  74581. * @param upperLimit The upper limit of the motor
  74582. * @param lowerLimit The lower limit of the motor
  74583. * @param motorIndex The index of the motor
  74584. */
  74585. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74586. }
  74587. /**
  74588. * Joint data for a Distance-Joint
  74589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74590. */
  74591. export interface DistanceJointData extends PhysicsJointData {
  74592. /**
  74593. * Max distance the 2 joint objects can be apart
  74594. */
  74595. maxDistance: number;
  74596. }
  74597. /**
  74598. * Joint data from a spring joint
  74599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74600. */
  74601. export interface SpringJointData extends PhysicsJointData {
  74602. /**
  74603. * Length of the spring
  74604. */
  74605. length: number;
  74606. /**
  74607. * Stiffness of the spring
  74608. */
  74609. stiffness: number;
  74610. /**
  74611. * Damping of the spring
  74612. */
  74613. damping: number;
  74614. /** this callback will be called when applying the force to the impostors. */
  74615. forceApplicationCallback: () => void;
  74616. }
  74617. }
  74618. declare module BABYLON {
  74619. /**
  74620. * Interface used to describe a physics joint
  74621. */
  74622. export interface PhysicsImpostorJoint {
  74623. /** Defines the main impostor to which the joint is linked */
  74624. mainImpostor: PhysicsImpostor;
  74625. /** Defines the impostor that is connected to the main impostor using this joint */
  74626. connectedImpostor: PhysicsImpostor;
  74627. /** Defines the joint itself */
  74628. joint: PhysicsJoint;
  74629. }
  74630. /** @hidden */
  74631. export interface IPhysicsEnginePlugin {
  74632. world: any;
  74633. name: string;
  74634. setGravity(gravity: Vector3): void;
  74635. setTimeStep(timeStep: number): void;
  74636. getTimeStep(): number;
  74637. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74638. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74639. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74640. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74641. removePhysicsBody(impostor: PhysicsImpostor): void;
  74642. generateJoint(joint: PhysicsImpostorJoint): void;
  74643. removeJoint(joint: PhysicsImpostorJoint): void;
  74644. isSupported(): boolean;
  74645. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74646. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74647. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74649. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74650. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74651. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74652. getBodyMass(impostor: PhysicsImpostor): number;
  74653. getBodyFriction(impostor: PhysicsImpostor): number;
  74654. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74655. getBodyRestitution(impostor: PhysicsImpostor): number;
  74656. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74657. sleepBody(impostor: PhysicsImpostor): void;
  74658. wakeUpBody(impostor: PhysicsImpostor): void;
  74659. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74660. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  74661. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74662. getRadius(impostor: PhysicsImpostor): number;
  74663. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  74664. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  74665. dispose(): void;
  74666. }
  74667. /**
  74668. * Interface used to define a physics engine
  74669. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  74670. */
  74671. export interface IPhysicsEngine {
  74672. /**
  74673. * Gets the gravity vector used by the simulation
  74674. */
  74675. gravity: Vector3;
  74676. /**
  74677. * Sets the gravity vector used by the simulation
  74678. * @param gravity defines the gravity vector to use
  74679. */
  74680. setGravity(gravity: Vector3): void;
  74681. /**
  74682. * Set the time step of the physics engine.
  74683. * Default is 1/60.
  74684. * To slow it down, enter 1/600 for example.
  74685. * To speed it up, 1/30
  74686. * @param newTimeStep the new timestep to apply to this world.
  74687. */
  74688. setTimeStep(newTimeStep: number): void;
  74689. /**
  74690. * Get the time step of the physics engine.
  74691. * @returns the current time step
  74692. */
  74693. getTimeStep(): number;
  74694. /**
  74695. * Release all resources
  74696. */
  74697. dispose(): void;
  74698. /**
  74699. * Gets the name of the current physics plugin
  74700. * @returns the name of the plugin
  74701. */
  74702. getPhysicsPluginName(): string;
  74703. /**
  74704. * Adding a new impostor for the impostor tracking.
  74705. * This will be done by the impostor itself.
  74706. * @param impostor the impostor to add
  74707. */
  74708. addImpostor(impostor: PhysicsImpostor): void;
  74709. /**
  74710. * Remove an impostor from the engine.
  74711. * This impostor and its mesh will not longer be updated by the physics engine.
  74712. * @param impostor the impostor to remove
  74713. */
  74714. removeImpostor(impostor: PhysicsImpostor): void;
  74715. /**
  74716. * Add a joint to the physics engine
  74717. * @param mainImpostor defines the main impostor to which the joint is added.
  74718. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  74719. * @param joint defines the joint that will connect both impostors.
  74720. */
  74721. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74722. /**
  74723. * Removes a joint from the simulation
  74724. * @param mainImpostor defines the impostor used with the joint
  74725. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  74726. * @param joint defines the joint to remove
  74727. */
  74728. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74729. /**
  74730. * Gets the current plugin used to run the simulation
  74731. * @returns current plugin
  74732. */
  74733. getPhysicsPlugin(): IPhysicsEnginePlugin;
  74734. /**
  74735. * Gets the list of physic impostors
  74736. * @returns an array of PhysicsImpostor
  74737. */
  74738. getImpostors(): Array<PhysicsImpostor>;
  74739. /**
  74740. * Gets the impostor for a physics enabled object
  74741. * @param object defines the object impersonated by the impostor
  74742. * @returns the PhysicsImpostor or null if not found
  74743. */
  74744. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  74745. /**
  74746. * Gets the impostor for a physics body object
  74747. * @param body defines physics body used by the impostor
  74748. * @returns the PhysicsImpostor or null if not found
  74749. */
  74750. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  74751. /**
  74752. * Called by the scene. No need to call it.
  74753. * @param delta defines the timespam between frames
  74754. */
  74755. _step(delta: number): void;
  74756. }
  74757. }
  74758. declare module BABYLON {
  74759. /**
  74760. * The interface for the physics imposter parameters
  74761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74762. */
  74763. export interface PhysicsImpostorParameters {
  74764. /**
  74765. * The mass of the physics imposter
  74766. */
  74767. mass: number;
  74768. /**
  74769. * The friction of the physics imposter
  74770. */
  74771. friction?: number;
  74772. /**
  74773. * The coefficient of restitution of the physics imposter
  74774. */
  74775. restitution?: number;
  74776. /**
  74777. * The native options of the physics imposter
  74778. */
  74779. nativeOptions?: any;
  74780. /**
  74781. * Specifies if the parent should be ignored
  74782. */
  74783. ignoreParent?: boolean;
  74784. /**
  74785. * Specifies if bi-directional transformations should be disabled
  74786. */
  74787. disableBidirectionalTransformation?: boolean;
  74788. }
  74789. /**
  74790. * Interface for a physics-enabled object
  74791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74792. */
  74793. export interface IPhysicsEnabledObject {
  74794. /**
  74795. * The position of the physics-enabled object
  74796. */
  74797. position: Vector3;
  74798. /**
  74799. * The rotation of the physics-enabled object
  74800. */
  74801. rotationQuaternion: Nullable<Quaternion>;
  74802. /**
  74803. * The scale of the physics-enabled object
  74804. */
  74805. scaling: Vector3;
  74806. /**
  74807. * The rotation of the physics-enabled object
  74808. */
  74809. rotation?: Vector3;
  74810. /**
  74811. * The parent of the physics-enabled object
  74812. */
  74813. parent?: any;
  74814. /**
  74815. * The bounding info of the physics-enabled object
  74816. * @returns The bounding info of the physics-enabled object
  74817. */
  74818. getBoundingInfo(): BoundingInfo;
  74819. /**
  74820. * Computes the world matrix
  74821. * @param force Specifies if the world matrix should be computed by force
  74822. * @returns A world matrix
  74823. */
  74824. computeWorldMatrix(force: boolean): Matrix;
  74825. /**
  74826. * Gets the world matrix
  74827. * @returns A world matrix
  74828. */
  74829. getWorldMatrix?(): Matrix;
  74830. /**
  74831. * Gets the child meshes
  74832. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  74833. * @returns An array of abstract meshes
  74834. */
  74835. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  74836. /**
  74837. * Gets the vertex data
  74838. * @param kind The type of vertex data
  74839. * @returns A nullable array of numbers, or a float32 array
  74840. */
  74841. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  74842. /**
  74843. * Gets the indices from the mesh
  74844. * @returns A nullable array of index arrays
  74845. */
  74846. getIndices?(): Nullable<IndicesArray>;
  74847. /**
  74848. * Gets the scene from the mesh
  74849. * @returns the indices array or null
  74850. */
  74851. getScene?(): Scene;
  74852. /**
  74853. * Gets the absolute position from the mesh
  74854. * @returns the absolute position
  74855. */
  74856. getAbsolutePosition(): Vector3;
  74857. /**
  74858. * Gets the absolute pivot point from the mesh
  74859. * @returns the absolute pivot point
  74860. */
  74861. getAbsolutePivotPoint(): Vector3;
  74862. /**
  74863. * Rotates the mesh
  74864. * @param axis The axis of rotation
  74865. * @param amount The amount of rotation
  74866. * @param space The space of the rotation
  74867. * @returns The rotation transform node
  74868. */
  74869. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  74870. /**
  74871. * Translates the mesh
  74872. * @param axis The axis of translation
  74873. * @param distance The distance of translation
  74874. * @param space The space of the translation
  74875. * @returns The transform node
  74876. */
  74877. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  74878. /**
  74879. * Sets the absolute position of the mesh
  74880. * @param absolutePosition The absolute position of the mesh
  74881. * @returns The transform node
  74882. */
  74883. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  74884. /**
  74885. * Gets the class name of the mesh
  74886. * @returns The class name
  74887. */
  74888. getClassName(): string;
  74889. }
  74890. /**
  74891. * Represents a physics imposter
  74892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74893. */
  74894. export class PhysicsImpostor {
  74895. /**
  74896. * The physics-enabled object used as the physics imposter
  74897. */
  74898. object: IPhysicsEnabledObject;
  74899. /**
  74900. * The type of the physics imposter
  74901. */
  74902. type: number;
  74903. private _options;
  74904. private _scene?;
  74905. /**
  74906. * The default object size of the imposter
  74907. */
  74908. static DEFAULT_OBJECT_SIZE: Vector3;
  74909. /**
  74910. * The identity quaternion of the imposter
  74911. */
  74912. static IDENTITY_QUATERNION: Quaternion;
  74913. /** @hidden */
  74914. _pluginData: any;
  74915. private _physicsEngine;
  74916. private _physicsBody;
  74917. private _bodyUpdateRequired;
  74918. private _onBeforePhysicsStepCallbacks;
  74919. private _onAfterPhysicsStepCallbacks;
  74920. /** @hidden */
  74921. _onPhysicsCollideCallbacks: Array<{
  74922. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  74923. otherImpostors: Array<PhysicsImpostor>;
  74924. }>;
  74925. private _deltaPosition;
  74926. private _deltaRotation;
  74927. private _deltaRotationConjugated;
  74928. private _parent;
  74929. private _isDisposed;
  74930. private static _tmpVecs;
  74931. private static _tmpQuat;
  74932. /**
  74933. * Specifies if the physics imposter is disposed
  74934. */
  74935. readonly isDisposed: boolean;
  74936. /**
  74937. * Gets the mass of the physics imposter
  74938. */
  74939. mass: number;
  74940. /**
  74941. * Gets the coefficient of friction
  74942. */
  74943. /**
  74944. * Sets the coefficient of friction
  74945. */
  74946. friction: number;
  74947. /**
  74948. * Gets the coefficient of restitution
  74949. */
  74950. /**
  74951. * Sets the coefficient of restitution
  74952. */
  74953. restitution: number;
  74954. /**
  74955. * The unique id of the physics imposter
  74956. * set by the physics engine when adding this impostor to the array
  74957. */
  74958. uniqueId: number;
  74959. private _joints;
  74960. /**
  74961. * Initializes the physics imposter
  74962. * @param object The physics-enabled object used as the physics imposter
  74963. * @param type The type of the physics imposter
  74964. * @param _options The options for the physics imposter
  74965. * @param _scene The Babylon scene
  74966. */
  74967. constructor(
  74968. /**
  74969. * The physics-enabled object used as the physics imposter
  74970. */
  74971. object: IPhysicsEnabledObject,
  74972. /**
  74973. * The type of the physics imposter
  74974. */
  74975. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  74976. /**
  74977. * This function will completly initialize this impostor.
  74978. * It will create a new body - but only if this mesh has no parent.
  74979. * If it has, this impostor will not be used other than to define the impostor
  74980. * of the child mesh.
  74981. * @hidden
  74982. */
  74983. _init(): void;
  74984. private _getPhysicsParent;
  74985. /**
  74986. * Should a new body be generated.
  74987. * @returns boolean specifying if body initialization is required
  74988. */
  74989. isBodyInitRequired(): boolean;
  74990. /**
  74991. * Sets the updated scaling
  74992. * @param updated Specifies if the scaling is updated
  74993. */
  74994. setScalingUpdated(): void;
  74995. /**
  74996. * Force a regeneration of this or the parent's impostor's body.
  74997. * Use under cautious - This will remove all joints already implemented.
  74998. */
  74999. forceUpdate(): void;
  75000. /**
  75001. * Gets the body that holds this impostor. Either its own, or its parent.
  75002. */
  75003. /**
  75004. * Set the physics body. Used mainly by the physics engine/plugin
  75005. */
  75006. physicsBody: any;
  75007. /**
  75008. * Get the parent of the physics imposter
  75009. * @returns Physics imposter or null
  75010. */
  75011. /**
  75012. * Sets the parent of the physics imposter
  75013. */
  75014. parent: Nullable<PhysicsImpostor>;
  75015. /**
  75016. * Resets the update flags
  75017. */
  75018. resetUpdateFlags(): void;
  75019. /**
  75020. * Gets the object extend size
  75021. * @returns the object extend size
  75022. */
  75023. getObjectExtendSize(): Vector3;
  75024. /**
  75025. * Gets the object center
  75026. * @returns The object center
  75027. */
  75028. getObjectCenter(): Vector3;
  75029. /**
  75030. * Get a specific parametes from the options parameter
  75031. * @param paramName The object parameter name
  75032. * @returns The object parameter
  75033. */
  75034. getParam(paramName: string): any;
  75035. /**
  75036. * Sets a specific parameter in the options given to the physics plugin
  75037. * @param paramName The parameter name
  75038. * @param value The value of the parameter
  75039. */
  75040. setParam(paramName: string, value: number): void;
  75041. /**
  75042. * Specifically change the body's mass option. Won't recreate the physics body object
  75043. * @param mass The mass of the physics imposter
  75044. */
  75045. setMass(mass: number): void;
  75046. /**
  75047. * Gets the linear velocity
  75048. * @returns linear velocity or null
  75049. */
  75050. getLinearVelocity(): Nullable<Vector3>;
  75051. /**
  75052. * Sets the linear velocity
  75053. * @param velocity linear velocity or null
  75054. */
  75055. setLinearVelocity(velocity: Nullable<Vector3>): void;
  75056. /**
  75057. * Gets the angular velocity
  75058. * @returns angular velocity or null
  75059. */
  75060. getAngularVelocity(): Nullable<Vector3>;
  75061. /**
  75062. * Sets the angular velocity
  75063. * @param velocity The velocity or null
  75064. */
  75065. setAngularVelocity(velocity: Nullable<Vector3>): void;
  75066. /**
  75067. * Execute a function with the physics plugin native code
  75068. * Provide a function the will have two variables - the world object and the physics body object
  75069. * @param func The function to execute with the physics plugin native code
  75070. */
  75071. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  75072. /**
  75073. * Register a function that will be executed before the physics world is stepping forward
  75074. * @param func The function to execute before the physics world is stepped forward
  75075. */
  75076. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75077. /**
  75078. * Unregister a function that will be executed before the physics world is stepping forward
  75079. * @param func The function to execute before the physics world is stepped forward
  75080. */
  75081. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75082. /**
  75083. * Register a function that will be executed after the physics step
  75084. * @param func The function to execute after physics step
  75085. */
  75086. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75087. /**
  75088. * Unregisters a function that will be executed after the physics step
  75089. * @param func The function to execute after physics step
  75090. */
  75091. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  75092. /**
  75093. * register a function that will be executed when this impostor collides against a different body
  75094. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  75095. * @param func Callback that is executed on collision
  75096. */
  75097. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  75098. /**
  75099. * Unregisters the physics imposter on contact
  75100. * @param collideAgainst The physics object to collide against
  75101. * @param func Callback to execute on collision
  75102. */
  75103. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  75104. private _tmpQuat;
  75105. private _tmpQuat2;
  75106. /**
  75107. * Get the parent rotation
  75108. * @returns The parent rotation
  75109. */
  75110. getParentsRotation(): Quaternion;
  75111. /**
  75112. * this function is executed by the physics engine.
  75113. */
  75114. beforeStep: () => void;
  75115. /**
  75116. * this function is executed by the physics engine
  75117. */
  75118. afterStep: () => void;
  75119. /**
  75120. * Legacy collision detection event support
  75121. */
  75122. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  75123. /**
  75124. * event and body object due to cannon's event-based architecture.
  75125. */
  75126. onCollide: (e: {
  75127. body: any;
  75128. }) => void;
  75129. /**
  75130. * Apply a force
  75131. * @param force The force to apply
  75132. * @param contactPoint The contact point for the force
  75133. * @returns The physics imposter
  75134. */
  75135. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75136. /**
  75137. * Apply an impulse
  75138. * @param force The impulse force
  75139. * @param contactPoint The contact point for the impulse force
  75140. * @returns The physics imposter
  75141. */
  75142. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  75143. /**
  75144. * A help function to create a joint
  75145. * @param otherImpostor A physics imposter used to create a joint
  75146. * @param jointType The type of joint
  75147. * @param jointData The data for the joint
  75148. * @returns The physics imposter
  75149. */
  75150. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  75151. /**
  75152. * Add a joint to this impostor with a different impostor
  75153. * @param otherImpostor A physics imposter used to add a joint
  75154. * @param joint The joint to add
  75155. * @returns The physics imposter
  75156. */
  75157. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  75158. /**
  75159. * Will keep this body still, in a sleep mode.
  75160. * @returns the physics imposter
  75161. */
  75162. sleep(): PhysicsImpostor;
  75163. /**
  75164. * Wake the body up.
  75165. * @returns The physics imposter
  75166. */
  75167. wakeUp(): PhysicsImpostor;
  75168. /**
  75169. * Clones the physics imposter
  75170. * @param newObject The physics imposter clones to this physics-enabled object
  75171. * @returns A nullable physics imposter
  75172. */
  75173. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75174. /**
  75175. * Disposes the physics imposter
  75176. */
  75177. dispose(): void;
  75178. /**
  75179. * Sets the delta position
  75180. * @param position The delta position amount
  75181. */
  75182. setDeltaPosition(position: Vector3): void;
  75183. /**
  75184. * Sets the delta rotation
  75185. * @param rotation The delta rotation amount
  75186. */
  75187. setDeltaRotation(rotation: Quaternion): void;
  75188. /**
  75189. * Gets the box size of the physics imposter and stores the result in the input parameter
  75190. * @param result Stores the box size
  75191. * @returns The physics imposter
  75192. */
  75193. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  75194. /**
  75195. * Gets the radius of the physics imposter
  75196. * @returns Radius of the physics imposter
  75197. */
  75198. getRadius(): number;
  75199. /**
  75200. * Sync a bone with this impostor
  75201. * @param bone The bone to sync to the impostor.
  75202. * @param boneMesh The mesh that the bone is influencing.
  75203. * @param jointPivot The pivot of the joint / bone in local space.
  75204. * @param distToJoint Optional distance from the impostor to the joint.
  75205. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75206. */
  75207. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  75208. /**
  75209. * Sync impostor to a bone
  75210. * @param bone The bone that the impostor will be synced to.
  75211. * @param boneMesh The mesh that the bone is influencing.
  75212. * @param jointPivot The pivot of the joint / bone in local space.
  75213. * @param distToJoint Optional distance from the impostor to the joint.
  75214. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  75215. * @param boneAxis Optional vector3 axis the bone is aligned with
  75216. */
  75217. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  75218. /**
  75219. * No-Imposter type
  75220. */
  75221. static NoImpostor: number;
  75222. /**
  75223. * Sphere-Imposter type
  75224. */
  75225. static SphereImpostor: number;
  75226. /**
  75227. * Box-Imposter type
  75228. */
  75229. static BoxImpostor: number;
  75230. /**
  75231. * Plane-Imposter type
  75232. */
  75233. static PlaneImpostor: number;
  75234. /**
  75235. * Mesh-imposter type
  75236. */
  75237. static MeshImpostor: number;
  75238. /**
  75239. * Cylinder-Imposter type
  75240. */
  75241. static CylinderImpostor: number;
  75242. /**
  75243. * Particle-Imposter type
  75244. */
  75245. static ParticleImpostor: number;
  75246. /**
  75247. * Heightmap-Imposter type
  75248. */
  75249. static HeightmapImpostor: number;
  75250. }
  75251. }
  75252. declare module BABYLON {
  75253. /**
  75254. * Mesh representing the gorund
  75255. */
  75256. export class GroundMesh extends Mesh {
  75257. /** If octree should be generated */
  75258. generateOctree: boolean;
  75259. private _heightQuads;
  75260. /** @hidden */
  75261. _subdivisionsX: number;
  75262. /** @hidden */
  75263. _subdivisionsY: number;
  75264. /** @hidden */
  75265. _width: number;
  75266. /** @hidden */
  75267. _height: number;
  75268. /** @hidden */
  75269. _minX: number;
  75270. /** @hidden */
  75271. _maxX: number;
  75272. /** @hidden */
  75273. _minZ: number;
  75274. /** @hidden */
  75275. _maxZ: number;
  75276. constructor(name: string, scene: Scene);
  75277. /**
  75278. * "GroundMesh"
  75279. * @returns "GroundMesh"
  75280. */
  75281. getClassName(): string;
  75282. /**
  75283. * The minimum of x and y subdivisions
  75284. */
  75285. readonly subdivisions: number;
  75286. /**
  75287. * X subdivisions
  75288. */
  75289. readonly subdivisionsX: number;
  75290. /**
  75291. * Y subdivisions
  75292. */
  75293. readonly subdivisionsY: number;
  75294. /**
  75295. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75296. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75297. * @param chunksCount the number of subdivisions for x and y
  75298. * @param octreeBlocksSize (Default: 32)
  75299. */
  75300. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75301. /**
  75302. * Returns a height (y) value in the Worl system :
  75303. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75304. * @param x x coordinate
  75305. * @param z z coordinate
  75306. * @returns the ground y position if (x, z) are outside the ground surface.
  75307. */
  75308. getHeightAtCoordinates(x: number, z: number): number;
  75309. /**
  75310. * Returns a normalized vector (Vector3) orthogonal to the ground
  75311. * at the ground coordinates (x, z) expressed in the World system.
  75312. * @param x x coordinate
  75313. * @param z z coordinate
  75314. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75315. */
  75316. getNormalAtCoordinates(x: number, z: number): Vector3;
  75317. /**
  75318. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75319. * at the ground coordinates (x, z) expressed in the World system.
  75320. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75321. * @param x x coordinate
  75322. * @param z z coordinate
  75323. * @param ref vector to store the result
  75324. * @returns the GroundMesh.
  75325. */
  75326. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75327. /**
  75328. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75329. * if the ground has been updated.
  75330. * This can be used in the render loop.
  75331. * @returns the GroundMesh.
  75332. */
  75333. updateCoordinateHeights(): GroundMesh;
  75334. private _getFacetAt;
  75335. private _initHeightQuads;
  75336. private _computeHeightQuads;
  75337. /**
  75338. * Serializes this ground mesh
  75339. * @param serializationObject object to write serialization to
  75340. */
  75341. serialize(serializationObject: any): void;
  75342. /**
  75343. * Parses a serialized ground mesh
  75344. * @param parsedMesh the serialized mesh
  75345. * @param scene the scene to create the ground mesh in
  75346. * @returns the created ground mesh
  75347. */
  75348. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75349. }
  75350. }
  75351. declare module BABYLON {
  75352. /**
  75353. * Class used to represent a specific level of detail of a mesh
  75354. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75355. */
  75356. export class MeshLODLevel {
  75357. /** Defines the distance where this level should star being displayed */
  75358. distance: number;
  75359. /** Defines the mesh to use to render this level */
  75360. mesh: Nullable<Mesh>;
  75361. /**
  75362. * Creates a new LOD level
  75363. * @param distance defines the distance where this level should star being displayed
  75364. * @param mesh defines the mesh to use to render this level
  75365. */
  75366. constructor(
  75367. /** Defines the distance where this level should star being displayed */
  75368. distance: number,
  75369. /** Defines the mesh to use to render this level */
  75370. mesh: Nullable<Mesh>);
  75371. }
  75372. /**
  75373. * @hidden
  75374. **/
  75375. export class _CreationDataStorage {
  75376. closePath?: boolean;
  75377. closeArray?: boolean;
  75378. idx: number[];
  75379. dashSize: number;
  75380. gapSize: number;
  75381. path3D: Path3D;
  75382. pathArray: Vector3[][];
  75383. arc: number;
  75384. radius: number;
  75385. cap: number;
  75386. tessellation: number;
  75387. }
  75388. /**
  75389. * @hidden
  75390. **/
  75391. class _InstanceDataStorage {
  75392. visibleInstances: any;
  75393. renderIdForInstances: number[];
  75394. batchCache: _InstancesBatch;
  75395. instancesBufferSize: number;
  75396. instancesBuffer: Nullable<Buffer>;
  75397. instancesData: Float32Array;
  75398. overridenInstanceCount: number;
  75399. }
  75400. /**
  75401. * @hidden
  75402. **/
  75403. export class _InstancesBatch {
  75404. mustReturn: boolean;
  75405. visibleInstances: Nullable<InstancedMesh[]>[];
  75406. renderSelf: boolean[];
  75407. }
  75408. /**
  75409. * Class used to represent renderable models
  75410. */
  75411. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  75412. /**
  75413. * Mesh side orientation : usually the external or front surface
  75414. */
  75415. static readonly FRONTSIDE: number;
  75416. /**
  75417. * Mesh side orientation : usually the internal or back surface
  75418. */
  75419. static readonly BACKSIDE: number;
  75420. /**
  75421. * Mesh side orientation : both internal and external or front and back surfaces
  75422. */
  75423. static readonly DOUBLESIDE: number;
  75424. /**
  75425. * Mesh side orientation : by default, `FRONTSIDE`
  75426. */
  75427. static readonly DEFAULTSIDE: number;
  75428. /**
  75429. * Mesh cap setting : no cap
  75430. */
  75431. static readonly NO_CAP: number;
  75432. /**
  75433. * Mesh cap setting : one cap at the beginning of the mesh
  75434. */
  75435. static readonly CAP_START: number;
  75436. /**
  75437. * Mesh cap setting : one cap at the end of the mesh
  75438. */
  75439. static readonly CAP_END: number;
  75440. /**
  75441. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  75442. */
  75443. static readonly CAP_ALL: number;
  75444. /**
  75445. * Gets the default side orientation.
  75446. * @param orientation the orientation to value to attempt to get
  75447. * @returns the default orientation
  75448. * @hidden
  75449. */
  75450. static _GetDefaultSideOrientation(orientation?: number): number;
  75451. private _onBeforeRenderObservable;
  75452. private _onBeforeBindObservable;
  75453. private _onAfterRenderObservable;
  75454. private _onBeforeDrawObservable;
  75455. /**
  75456. * An event triggered before rendering the mesh
  75457. */
  75458. readonly onBeforeRenderObservable: Observable<Mesh>;
  75459. /**
  75460. * An event triggered before binding the mesh
  75461. */
  75462. readonly onBeforeBindObservable: Observable<Mesh>;
  75463. /**
  75464. * An event triggered after rendering the mesh
  75465. */
  75466. readonly onAfterRenderObservable: Observable<Mesh>;
  75467. /**
  75468. * An event triggered before drawing the mesh
  75469. */
  75470. readonly onBeforeDrawObservable: Observable<Mesh>;
  75471. private _onBeforeDrawObserver;
  75472. /**
  75473. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  75474. */
  75475. onBeforeDraw: () => void;
  75476. /**
  75477. * Gets the delay loading state of the mesh (when delay loading is turned on)
  75478. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  75479. */
  75480. delayLoadState: number;
  75481. /**
  75482. * Gets the list of instances created from this mesh
  75483. * it is not supposed to be modified manually.
  75484. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  75485. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75486. */
  75487. instances: InstancedMesh[];
  75488. /**
  75489. * Gets the file containing delay loading data for this mesh
  75490. */
  75491. delayLoadingFile: string;
  75492. /** @hidden */
  75493. _binaryInfo: any;
  75494. private _LODLevels;
  75495. /**
  75496. * User defined function used to change how LOD level selection is done
  75497. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  75498. */
  75499. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  75500. private _morphTargetManager;
  75501. /**
  75502. * Gets or sets the morph target manager
  75503. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75504. */
  75505. morphTargetManager: Nullable<MorphTargetManager>;
  75506. /** @hidden */
  75507. _creationDataStorage: Nullable<_CreationDataStorage>;
  75508. /** @hidden */
  75509. _geometry: Nullable<Geometry>;
  75510. /** @hidden */
  75511. _delayInfo: Array<string>;
  75512. /** @hidden */
  75513. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  75514. /** @hidden */
  75515. _instanceDataStorage: _InstanceDataStorage;
  75516. private _effectiveMaterial;
  75517. /** @hidden */
  75518. _shouldGenerateFlatShading: boolean;
  75519. private _preActivateId;
  75520. /** @hidden */
  75521. _originalBuilderSideOrientation: number;
  75522. /**
  75523. * Use this property to change the original side orientation defined at construction time
  75524. */
  75525. overrideMaterialSideOrientation: Nullable<number>;
  75526. private _areNormalsFrozen;
  75527. private _sourcePositions;
  75528. private _sourceNormals;
  75529. private _source;
  75530. private meshMap;
  75531. /**
  75532. * Gets the source mesh (the one used to clone this one from)
  75533. */
  75534. readonly source: Nullable<Mesh>;
  75535. /**
  75536. * Gets or sets a boolean indicating that this mesh does not use index buffer
  75537. */
  75538. isUnIndexed: boolean;
  75539. /**
  75540. * @constructor
  75541. * @param name The value used by scene.getMeshByName() to do a lookup.
  75542. * @param scene The scene to add this mesh to.
  75543. * @param parent The parent of this mesh, if it has one
  75544. * @param source An optional Mesh from which geometry is shared, cloned.
  75545. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75546. * When false, achieved by calling a clone(), also passing False.
  75547. * This will make creation of children, recursive.
  75548. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  75549. */
  75550. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  75551. /**
  75552. * Gets the class name
  75553. * @returns the string "Mesh".
  75554. */
  75555. getClassName(): string;
  75556. /** @hidden */
  75557. readonly _isMesh: boolean;
  75558. /**
  75559. * Returns a description of this mesh
  75560. * @param fullDetails define if full details about this mesh must be used
  75561. * @returns a descriptive string representing this mesh
  75562. */
  75563. toString(fullDetails?: boolean): string;
  75564. /** @hidden */
  75565. _unBindEffect(): void;
  75566. /**
  75567. * Gets a boolean indicating if this mesh has LOD
  75568. */
  75569. readonly hasLODLevels: boolean;
  75570. /**
  75571. * Gets the list of MeshLODLevel associated with the current mesh
  75572. * @returns an array of MeshLODLevel
  75573. */
  75574. getLODLevels(): MeshLODLevel[];
  75575. private _sortLODLevels;
  75576. /**
  75577. * Add a mesh as LOD level triggered at the given distance.
  75578. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75579. * @param distance The distance from the center of the object to show this level
  75580. * @param mesh The mesh to be added as LOD level (can be null)
  75581. * @return This mesh (for chaining)
  75582. */
  75583. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  75584. /**
  75585. * Returns the LOD level mesh at the passed distance or null if not found.
  75586. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75587. * @param distance The distance from the center of the object to show this level
  75588. * @returns a Mesh or `null`
  75589. */
  75590. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  75591. /**
  75592. * Remove a mesh from the LOD array
  75593. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75594. * @param mesh defines the mesh to be removed
  75595. * @return This mesh (for chaining)
  75596. */
  75597. removeLODLevel(mesh: Mesh): Mesh;
  75598. /**
  75599. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  75600. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  75601. * @param camera defines the camera to use to compute distance
  75602. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75603. * @return This mesh (for chaining)
  75604. */
  75605. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75606. /**
  75607. * Gets the mesh internal Geometry object
  75608. */
  75609. readonly geometry: Nullable<Geometry>;
  75610. /**
  75611. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75612. * @returns the total number of vertices
  75613. */
  75614. getTotalVertices(): number;
  75615. /**
  75616. * Returns the content of an associated vertex buffer
  75617. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75618. * - VertexBuffer.PositionKind
  75619. * - VertexBuffer.UVKind
  75620. * - VertexBuffer.UV2Kind
  75621. * - VertexBuffer.UV3Kind
  75622. * - VertexBuffer.UV4Kind
  75623. * - VertexBuffer.UV5Kind
  75624. * - VertexBuffer.UV6Kind
  75625. * - VertexBuffer.ColorKind
  75626. * - VertexBuffer.MatricesIndicesKind
  75627. * - VertexBuffer.MatricesIndicesExtraKind
  75628. * - VertexBuffer.MatricesWeightsKind
  75629. * - VertexBuffer.MatricesWeightsExtraKind
  75630. * @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
  75631. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75632. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75633. */
  75634. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75635. /**
  75636. * Returns the mesh VertexBuffer object from the requested `kind`
  75637. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75638. * - VertexBuffer.PositionKind
  75639. * - VertexBuffer.UVKind
  75640. * - VertexBuffer.UV2Kind
  75641. * - VertexBuffer.UV3Kind
  75642. * - VertexBuffer.UV4Kind
  75643. * - VertexBuffer.UV5Kind
  75644. * - VertexBuffer.UV6Kind
  75645. * - VertexBuffer.ColorKind
  75646. * - VertexBuffer.MatricesIndicesKind
  75647. * - VertexBuffer.MatricesIndicesExtraKind
  75648. * - VertexBuffer.MatricesWeightsKind
  75649. * - VertexBuffer.MatricesWeightsExtraKind
  75650. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75651. */
  75652. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75653. /**
  75654. * Tests if a specific vertex buffer is associated with this mesh
  75655. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75656. * - VertexBuffer.PositionKind
  75657. * - VertexBuffer.UVKind
  75658. * - VertexBuffer.UV2Kind
  75659. * - VertexBuffer.UV3Kind
  75660. * - VertexBuffer.UV4Kind
  75661. * - VertexBuffer.UV5Kind
  75662. * - VertexBuffer.UV6Kind
  75663. * - VertexBuffer.ColorKind
  75664. * - VertexBuffer.MatricesIndicesKind
  75665. * - VertexBuffer.MatricesIndicesExtraKind
  75666. * - VertexBuffer.MatricesWeightsKind
  75667. * - VertexBuffer.MatricesWeightsExtraKind
  75668. * @returns a boolean
  75669. */
  75670. isVerticesDataPresent(kind: string): boolean;
  75671. /**
  75672. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75673. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75674. * - VertexBuffer.PositionKind
  75675. * - VertexBuffer.UVKind
  75676. * - VertexBuffer.UV2Kind
  75677. * - VertexBuffer.UV3Kind
  75678. * - VertexBuffer.UV4Kind
  75679. * - VertexBuffer.UV5Kind
  75680. * - VertexBuffer.UV6Kind
  75681. * - VertexBuffer.ColorKind
  75682. * - VertexBuffer.MatricesIndicesKind
  75683. * - VertexBuffer.MatricesIndicesExtraKind
  75684. * - VertexBuffer.MatricesWeightsKind
  75685. * - VertexBuffer.MatricesWeightsExtraKind
  75686. * @returns a boolean
  75687. */
  75688. isVertexBufferUpdatable(kind: string): boolean;
  75689. /**
  75690. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75691. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75692. * - VertexBuffer.PositionKind
  75693. * - VertexBuffer.UVKind
  75694. * - VertexBuffer.UV2Kind
  75695. * - VertexBuffer.UV3Kind
  75696. * - VertexBuffer.UV4Kind
  75697. * - VertexBuffer.UV5Kind
  75698. * - VertexBuffer.UV6Kind
  75699. * - VertexBuffer.ColorKind
  75700. * - VertexBuffer.MatricesIndicesKind
  75701. * - VertexBuffer.MatricesIndicesExtraKind
  75702. * - VertexBuffer.MatricesWeightsKind
  75703. * - VertexBuffer.MatricesWeightsExtraKind
  75704. * @returns an array of strings
  75705. */
  75706. getVerticesDataKinds(): string[];
  75707. /**
  75708. * Returns a positive integer : the total number of indices in this mesh geometry.
  75709. * @returns the numner of indices or zero if the mesh has no geometry.
  75710. */
  75711. getTotalIndices(): number;
  75712. /**
  75713. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75714. * @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.
  75715. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75716. * @returns the indices array or an empty array if the mesh has no geometry
  75717. */
  75718. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75719. readonly isBlocked: boolean;
  75720. /**
  75721. * Determine if the current mesh is ready to be rendered
  75722. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75723. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75724. * @returns true if all associated assets are ready (material, textures, shaders)
  75725. */
  75726. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75727. /**
  75728. * 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.
  75729. */
  75730. readonly areNormalsFrozen: boolean;
  75731. /**
  75732. * 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.
  75733. * @returns the current mesh
  75734. */
  75735. freezeNormals(): Mesh;
  75736. /**
  75737. * 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
  75738. * @returns the current mesh
  75739. */
  75740. unfreezeNormals(): Mesh;
  75741. /**
  75742. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75743. */
  75744. overridenInstanceCount: number;
  75745. /** @hidden */
  75746. _preActivate(): Mesh;
  75747. /** @hidden */
  75748. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75749. /** @hidden */
  75750. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75751. /**
  75752. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75753. * This means the mesh underlying bounding box and sphere are recomputed.
  75754. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75755. * @returns the current mesh
  75756. */
  75757. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75758. /** @hidden */
  75759. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  75760. /**
  75761. * This function will subdivide the mesh into multiple submeshes
  75762. * @param count defines the expected number of submeshes
  75763. */
  75764. subdivide(count: number): void;
  75765. /**
  75766. * Copy a FloatArray into a specific associated vertex buffer
  75767. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75768. * - VertexBuffer.PositionKind
  75769. * - VertexBuffer.UVKind
  75770. * - VertexBuffer.UV2Kind
  75771. * - VertexBuffer.UV3Kind
  75772. * - VertexBuffer.UV4Kind
  75773. * - VertexBuffer.UV5Kind
  75774. * - VertexBuffer.UV6Kind
  75775. * - VertexBuffer.ColorKind
  75776. * - VertexBuffer.MatricesIndicesKind
  75777. * - VertexBuffer.MatricesIndicesExtraKind
  75778. * - VertexBuffer.MatricesWeightsKind
  75779. * - VertexBuffer.MatricesWeightsExtraKind
  75780. * @param data defines the data source
  75781. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75782. * @param stride defines the data stride size (can be null)
  75783. * @returns the current mesh
  75784. */
  75785. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75786. /**
  75787. * Flags an associated vertex buffer as updatable
  75788. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  75789. * - VertexBuffer.PositionKind
  75790. * - VertexBuffer.UVKind
  75791. * - VertexBuffer.UV2Kind
  75792. * - VertexBuffer.UV3Kind
  75793. * - VertexBuffer.UV4Kind
  75794. * - VertexBuffer.UV5Kind
  75795. * - VertexBuffer.UV6Kind
  75796. * - VertexBuffer.ColorKind
  75797. * - VertexBuffer.MatricesIndicesKind
  75798. * - VertexBuffer.MatricesIndicesExtraKind
  75799. * - VertexBuffer.MatricesWeightsKind
  75800. * - VertexBuffer.MatricesWeightsExtraKind
  75801. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75802. */
  75803. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  75804. /**
  75805. * Sets the mesh global Vertex Buffer
  75806. * @param buffer defines the buffer to use
  75807. * @returns the current mesh
  75808. */
  75809. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  75810. /**
  75811. * Update a specific associated vertex buffer
  75812. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75813. * - VertexBuffer.PositionKind
  75814. * - VertexBuffer.UVKind
  75815. * - VertexBuffer.UV2Kind
  75816. * - VertexBuffer.UV3Kind
  75817. * - VertexBuffer.UV4Kind
  75818. * - VertexBuffer.UV5Kind
  75819. * - VertexBuffer.UV6Kind
  75820. * - VertexBuffer.ColorKind
  75821. * - VertexBuffer.MatricesIndicesKind
  75822. * - VertexBuffer.MatricesIndicesExtraKind
  75823. * - VertexBuffer.MatricesWeightsKind
  75824. * - VertexBuffer.MatricesWeightsExtraKind
  75825. * @param data defines the data source
  75826. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  75827. * @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)
  75828. * @returns the current mesh
  75829. */
  75830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75831. /**
  75832. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  75833. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  75834. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  75835. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  75836. * @returns the current mesh
  75837. */
  75838. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  75839. /**
  75840. * Creates a un-shared specific occurence of the geometry for the mesh.
  75841. * @returns the current mesh
  75842. */
  75843. makeGeometryUnique(): Mesh;
  75844. /**
  75845. * Set the index buffer of this mesh
  75846. * @param indices defines the source data
  75847. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  75848. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  75849. * @returns the current mesh
  75850. */
  75851. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  75852. /**
  75853. * Update the current index buffer
  75854. * @param indices defines the source data
  75855. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  75856. * @returns the current mesh
  75857. */
  75858. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  75859. /**
  75860. * Invert the geometry to move from a right handed system to a left handed one.
  75861. * @returns the current mesh
  75862. */
  75863. toLeftHanded(): Mesh;
  75864. /** @hidden */
  75865. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  75866. /** @hidden */
  75867. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  75868. /**
  75869. * Registers for this mesh a javascript function called just before the rendering process
  75870. * @param func defines the function to call before rendering this mesh
  75871. * @returns the current mesh
  75872. */
  75873. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75874. /**
  75875. * Disposes a previously registered javascript function called before the rendering
  75876. * @param func defines the function to remove
  75877. * @returns the current mesh
  75878. */
  75879. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75880. /**
  75881. * Registers for this mesh a javascript function called just after the rendering is complete
  75882. * @param func defines the function to call after rendering this mesh
  75883. * @returns the current mesh
  75884. */
  75885. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75886. /**
  75887. * Disposes a previously registered javascript function called after the rendering.
  75888. * @param func defines the function to remove
  75889. * @returns the current mesh
  75890. */
  75891. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75892. /** @hidden */
  75893. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  75894. /** @hidden */
  75895. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  75896. /** @hidden */
  75897. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  75898. /**
  75899. * 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
  75900. * @param subMesh defines the subMesh to render
  75901. * @param enableAlphaMode defines if alpha mode can be changed
  75902. * @returns the current mesh
  75903. */
  75904. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  75905. private _onBeforeDraw;
  75906. /**
  75907. * Renormalize the mesh and patch it up if there are no weights
  75908. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  75909. * However in the case of zero weights then we set just a single influence to 1.
  75910. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  75911. */
  75912. cleanMatrixWeights(): void;
  75913. private normalizeSkinFourWeights;
  75914. private normalizeSkinWeightsAndExtra;
  75915. /**
  75916. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  75917. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  75918. * the user know there was an issue with importing the mesh
  75919. * @returns a validation object with skinned, valid and report string
  75920. */
  75921. validateSkinning(): {
  75922. skinned: boolean;
  75923. valid: boolean;
  75924. report: string;
  75925. };
  75926. /** @hidden */
  75927. _checkDelayState(): Mesh;
  75928. private _queueLoad;
  75929. /**
  75930. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  75931. * A mesh is in the frustum if its bounding box intersects the frustum
  75932. * @param frustumPlanes defines the frustum to test
  75933. * @returns true if the mesh is in the frustum planes
  75934. */
  75935. isInFrustum(frustumPlanes: Plane[]): boolean;
  75936. /**
  75937. * Sets the mesh material by the material or multiMaterial `id` property
  75938. * @param id is a string identifying the material or the multiMaterial
  75939. * @returns the current mesh
  75940. */
  75941. setMaterialByID(id: string): Mesh;
  75942. /**
  75943. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  75944. * @returns an array of IAnimatable
  75945. */
  75946. getAnimatables(): IAnimatable[];
  75947. /**
  75948. * Modifies the mesh geometry according to the passed transformation matrix.
  75949. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  75950. * The mesh normals are modified using the same transformation.
  75951. * Note that, under the hood, this method sets a new VertexBuffer each call.
  75952. * @param transform defines the transform matrix to use
  75953. * @see http://doc.babylonjs.com/resources/baking_transformations
  75954. * @returns the current mesh
  75955. */
  75956. bakeTransformIntoVertices(transform: Matrix): Mesh;
  75957. /**
  75958. * Modifies the mesh geometry according to its own current World Matrix.
  75959. * The mesh World Matrix is then reset.
  75960. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  75961. * Note that, under the hood, this method sets a new VertexBuffer each call.
  75962. * @see http://doc.babylonjs.com/resources/baking_transformations
  75963. * @returns the current mesh
  75964. */
  75965. bakeCurrentTransformIntoVertices(): Mesh;
  75966. /** @hidden */
  75967. readonly _positions: Nullable<Vector3[]>;
  75968. /** @hidden */
  75969. _resetPointsArrayCache(): Mesh;
  75970. /** @hidden */
  75971. _generatePointsArray(): boolean;
  75972. /**
  75973. * Returns a new Mesh object generated from the current mesh properties.
  75974. * This method must not get confused with createInstance()
  75975. * @param name is a string, the name given to the new mesh
  75976. * @param newParent can be any Node object (default `null`)
  75977. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  75978. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  75979. * @returns a new mesh
  75980. */
  75981. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  75982. /**
  75983. * Releases resources associated with this mesh.
  75984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75986. */
  75987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75988. /**
  75989. * Modifies the mesh geometry according to a displacement map.
  75990. * 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.
  75991. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  75992. * @param url is a string, the URL from the image file is to be downloaded.
  75993. * @param minHeight is the lower limit of the displacement.
  75994. * @param maxHeight is the upper limit of the displacement.
  75995. * @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.
  75996. * @param uvOffset is an optional vector2 used to offset UV.
  75997. * @param uvScale is an optional vector2 used to scale UV.
  75998. * @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.
  75999. * @returns the Mesh.
  76000. */
  76001. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76002. /**
  76003. * Modifies the mesh geometry according to a displacementMap buffer.
  76004. * 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.
  76005. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  76006. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  76007. * @param heightMapWidth is the width of the buffer image.
  76008. * @param heightMapHeight is the height of the buffer image.
  76009. * @param minHeight is the lower limit of the displacement.
  76010. * @param maxHeight is the upper limit of the displacement.
  76011. * @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.
  76012. * @param uvOffset is an optional vector2 used to offset UV.
  76013. * @param uvScale is an optional vector2 used to scale UV.
  76014. * @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.
  76015. * @returns the Mesh.
  76016. */
  76017. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  76018. /**
  76019. * Modify the mesh to get a flat shading rendering.
  76020. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  76021. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  76022. * @returns current mesh
  76023. */
  76024. convertToFlatShadedMesh(): Mesh;
  76025. /**
  76026. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  76027. * In other words, more vertices, no more indices and a single bigger VBO.
  76028. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  76029. * @returns current mesh
  76030. */
  76031. convertToUnIndexedMesh(): Mesh;
  76032. /**
  76033. * Inverses facet orientations.
  76034. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  76035. * @param flipNormals will also inverts the normals
  76036. * @returns current mesh
  76037. */
  76038. flipFaces(flipNormals?: boolean): Mesh;
  76039. /** @hidden */
  76040. static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  76041. /**
  76042. * Creates a new InstancedMesh object from the mesh model.
  76043. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76044. * @param name defines the name of the new instance
  76045. * @returns a new InstancedMesh
  76046. */
  76047. createInstance(name: string): InstancedMesh;
  76048. /**
  76049. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  76050. * After this call, all the mesh instances have the same submeshes than the current mesh.
  76051. * @returns the current mesh
  76052. */
  76053. synchronizeInstances(): Mesh;
  76054. /**
  76055. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  76056. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  76057. * This should be used together with the simplification to avoid disappearing triangles.
  76058. * @param successCallback an optional success callback to be called after the optimization finished.
  76059. * @returns the current mesh
  76060. */
  76061. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  76062. /**
  76063. * Serialize current mesh
  76064. * @param serializationObject defines the object which will receive the serialization data
  76065. */
  76066. serialize(serializationObject: any): void;
  76067. /** @hidden */
  76068. _syncGeometryWithMorphTargetManager(): void;
  76069. /** @hidden */
  76070. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  76071. /**
  76072. * Returns a new Mesh object parsed from the source provided.
  76073. * @param parsedMesh is the source
  76074. * @param scene defines the hosting scene
  76075. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  76076. * @returns a new Mesh
  76077. */
  76078. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  76079. /**
  76080. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  76081. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76082. * @param name defines the name of the mesh to create
  76083. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  76084. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  76085. * @param closePath creates a seam between the first and the last points of each path of the path array
  76086. * @param offset is taken in account only if the `pathArray` is containing a single path
  76087. * @param scene defines the hosting scene
  76088. * @param updatable defines if the mesh must be flagged as updatable
  76089. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76090. * @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)
  76091. * @returns a new Mesh
  76092. */
  76093. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76094. /**
  76095. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  76096. * @param name defines the name of the mesh to create
  76097. * @param radius sets the radius size (float) of the polygon (default 0.5)
  76098. * @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
  76099. * @param scene defines the hosting scene
  76100. * @param updatable defines if the mesh must be flagged as updatable
  76101. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76102. * @returns a new Mesh
  76103. */
  76104. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76105. /**
  76106. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  76107. * @param name defines the name of the mesh to create
  76108. * @param size sets the size (float) of each box side (default 1)
  76109. * @param scene defines the hosting scene
  76110. * @param updatable defines if the mesh must be flagged as updatable
  76111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76112. * @returns a new Mesh
  76113. */
  76114. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  76115. /**
  76116. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  76117. * @param name defines the name of the mesh to create
  76118. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  76119. * @param diameter sets the diameter size (float) of the sphere (default 1)
  76120. * @param scene defines the hosting scene
  76121. * @param updatable defines if the mesh must be flagged as updatable
  76122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76123. * @returns a new Mesh
  76124. */
  76125. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76126. /**
  76127. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  76128. * @param name defines the name of the mesh to create
  76129. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  76130. * @param diameterTop set the top cap diameter (floats, default 1)
  76131. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  76132. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  76133. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  76134. * @param scene defines the hosting scene
  76135. * @param updatable defines if the mesh must be flagged as updatable
  76136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76137. * @returns a new Mesh
  76138. */
  76139. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  76140. /**
  76141. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  76142. * @param name defines the name of the mesh to create
  76143. * @param diameter sets the diameter size (float) of the torus (default 1)
  76144. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  76145. * @param tessellation sets the number of torus sides (postive integer, default 16)
  76146. * @param scene defines the hosting scene
  76147. * @param updatable defines if the mesh must be flagged as updatable
  76148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76149. * @returns a new Mesh
  76150. */
  76151. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76152. /**
  76153. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  76154. * @param name defines the name of the mesh to create
  76155. * @param radius sets the global radius size (float) of the torus knot (default 2)
  76156. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  76157. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  76158. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  76159. * @param p the number of windings on X axis (positive integers, default 2)
  76160. * @param q the number of windings on Y axis (positive integers, default 3)
  76161. * @param scene defines the hosting scene
  76162. * @param updatable defines if the mesh must be flagged as updatable
  76163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76164. * @returns a new Mesh
  76165. */
  76166. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76167. /**
  76168. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  76169. * @param name defines the name of the mesh to create
  76170. * @param points is an array successive Vector3
  76171. * @param scene defines the hosting scene
  76172. * @param updatable defines if the mesh must be flagged as updatable
  76173. * @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).
  76174. * @returns a new Mesh
  76175. */
  76176. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  76177. /**
  76178. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  76179. * @param name defines the name of the mesh to create
  76180. * @param points is an array successive Vector3
  76181. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  76182. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76183. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  76184. * @param scene defines the hosting scene
  76185. * @param updatable defines if the mesh must be flagged as updatable
  76186. * @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)
  76187. * @returns a new Mesh
  76188. */
  76189. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  76190. /**
  76191. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  76192. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  76193. * 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.
  76194. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76195. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76196. * Remember you can only change the shape positions, not their number when updating a polygon.
  76197. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  76198. * @param name defines the name of the mesh to create
  76199. * @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
  76200. * @param scene defines the hosting scene
  76201. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76202. * @param updatable defines if the mesh must be flagged as updatable
  76203. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76204. * @param earcutInjection can be used to inject your own earcut reference
  76205. * @returns a new Mesh
  76206. */
  76207. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76208. /**
  76209. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  76210. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  76211. * @param name defines the name of the mesh to create
  76212. * @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
  76213. * @param depth defines the height of extrusion
  76214. * @param scene defines the hosting scene
  76215. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  76216. * @param updatable defines if the mesh must be flagged as updatable
  76217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76218. * @param earcutInjection can be used to inject your own earcut reference
  76219. * @returns a new Mesh
  76220. */
  76221. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  76222. /**
  76223. * Creates an extruded shape mesh.
  76224. * 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
  76225. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76226. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76227. * @param name defines the name of the mesh to create
  76228. * @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
  76229. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76230. * @param scale is the value to scale the shape
  76231. * @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
  76232. * @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
  76233. * @param scene defines the hosting scene
  76234. * @param updatable defines if the mesh must be flagged as updatable
  76235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76236. * @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)
  76237. * @returns a new Mesh
  76238. */
  76239. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76240. /**
  76241. * Creates an custom extruded shape mesh.
  76242. * The custom extrusion is a parametric shape.
  76243. * It has no predefined shape. Its final shape will depend on the input parameters.
  76244. * Please consider using the same method from the MeshBuilder class instead
  76245. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  76246. * @param name defines the name of the mesh to create
  76247. * @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
  76248. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  76249. * @param scaleFunction is a custom Javascript function called on each path point
  76250. * @param rotationFunction is a custom Javascript function called on each path point
  76251. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  76252. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  76253. * @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
  76254. * @param scene defines the hosting scene
  76255. * @param updatable defines if the mesh must be flagged as updatable
  76256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76257. * @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)
  76258. * @returns a new Mesh
  76259. */
  76260. 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;
  76261. /**
  76262. * Creates lathe mesh.
  76263. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  76264. * Please consider using the same method from the MeshBuilder class instead
  76265. * @param name defines the name of the mesh to create
  76266. * @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
  76267. * @param radius is the radius value of the lathe
  76268. * @param tessellation is the side number of the lathe.
  76269. * @param scene defines the hosting scene
  76270. * @param updatable defines if the mesh must be flagged as updatable
  76271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76272. * @returns a new Mesh
  76273. */
  76274. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76275. /**
  76276. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  76277. * @param name defines the name of the mesh to create
  76278. * @param size sets the size (float) of both sides of the plane at once (default 1)
  76279. * @param scene defines the hosting scene
  76280. * @param updatable defines if the mesh must be flagged as updatable
  76281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76282. * @returns a new Mesh
  76283. */
  76284. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  76285. /**
  76286. * Creates a ground mesh.
  76287. * Please consider using the same method from the MeshBuilder class instead
  76288. * @param name defines the name of the mesh to create
  76289. * @param width set the width of the ground
  76290. * @param height set the height of the ground
  76291. * @param subdivisions sets the number of subdivisions per side
  76292. * @param scene defines the hosting scene
  76293. * @param updatable defines if the mesh must be flagged as updatable
  76294. * @returns a new Mesh
  76295. */
  76296. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  76297. /**
  76298. * Creates a tiled ground mesh.
  76299. * Please consider using the same method from the MeshBuilder class instead
  76300. * @param name defines the name of the mesh to create
  76301. * @param xmin set the ground minimum X coordinate
  76302. * @param zmin set the ground minimum Y coordinate
  76303. * @param xmax set the ground maximum X coordinate
  76304. * @param zmax set the ground maximum Z coordinate
  76305. * @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
  76306. * @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
  76307. * @param scene defines the hosting scene
  76308. * @param updatable defines if the mesh must be flagged as updatable
  76309. * @returns a new Mesh
  76310. */
  76311. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  76312. w: number;
  76313. h: number;
  76314. }, precision: {
  76315. w: number;
  76316. h: number;
  76317. }, scene: Scene, updatable?: boolean): Mesh;
  76318. /**
  76319. * Creates a ground mesh from a height map.
  76320. * Please consider using the same method from the MeshBuilder class instead
  76321. * @see http://doc.babylonjs.com/babylon101/height_map
  76322. * @param name defines the name of the mesh to create
  76323. * @param url sets the URL of the height map image resource
  76324. * @param width set the ground width size
  76325. * @param height set the ground height size
  76326. * @param subdivisions sets the number of subdivision per side
  76327. * @param minHeight is the minimum altitude on the ground
  76328. * @param maxHeight is the maximum altitude on the ground
  76329. * @param scene defines the hosting scene
  76330. * @param updatable defines if the mesh must be flagged as updatable
  76331. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  76332. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  76333. * @returns a new Mesh
  76334. */
  76335. 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;
  76336. /**
  76337. * Creates a tube mesh.
  76338. * The tube is a parametric shape.
  76339. * It has no predefined shape. Its final shape will depend on the input parameters.
  76340. * Please consider using the same method from the MeshBuilder class instead
  76341. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  76342. * @param name defines the name of the mesh to create
  76343. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  76344. * @param radius sets the tube radius size
  76345. * @param tessellation is the number of sides on the tubular surface
  76346. * @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
  76347. * @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
  76348. * @param scene defines the hosting scene
  76349. * @param updatable defines if the mesh must be flagged as updatable
  76350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  76351. * @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)
  76352. * @returns a new Mesh
  76353. */
  76354. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  76355. (i: number, distance: number): number;
  76356. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  76357. /**
  76358. * Creates a polyhedron mesh.
  76359. * Please consider using the same method from the MeshBuilder class instead.
  76360. * * 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
  76361. * * The parameter `size` (positive float, default 1) sets the polygon size
  76362. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  76363. * * 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`
  76364. * * 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
  76365. * * 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)`)
  76366. * * 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
  76367. * * 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
  76368. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76369. * * If you create a double-sided mesh, you can choose what parts of 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
  76370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76371. * @param name defines the name of the mesh to create
  76372. * @param options defines the options used to create the mesh
  76373. * @param scene defines the hosting scene
  76374. * @returns a new Mesh
  76375. */
  76376. static CreatePolyhedron(name: string, options: {
  76377. type?: number;
  76378. size?: number;
  76379. sizeX?: number;
  76380. sizeY?: number;
  76381. sizeZ?: number;
  76382. custom?: any;
  76383. faceUV?: Vector4[];
  76384. faceColors?: Color4[];
  76385. updatable?: boolean;
  76386. sideOrientation?: number;
  76387. }, scene: Scene): Mesh;
  76388. /**
  76389. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76390. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76391. * * 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`)
  76392. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76393. * * 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
  76394. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  76395. * * If you create a double-sided mesh, you can choose what parts of 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
  76396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76397. * @param name defines the name of the mesh
  76398. * @param options defines the options used to create the mesh
  76399. * @param scene defines the hosting scene
  76400. * @returns a new Mesh
  76401. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76402. */
  76403. static CreateIcoSphere(name: string, options: {
  76404. radius?: number;
  76405. flat?: boolean;
  76406. subdivisions?: number;
  76407. sideOrientation?: number;
  76408. updatable?: boolean;
  76409. }, scene: Scene): Mesh;
  76410. /**
  76411. * Creates a decal mesh.
  76412. * Please consider using the same method from the MeshBuilder class instead.
  76413. * A decal is a mesh usually applied as a model onto the surface of another mesh
  76414. * @param name defines the name of the mesh
  76415. * @param sourceMesh defines the mesh receiving the decal
  76416. * @param position sets the position of the decal in world coordinates
  76417. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  76418. * @param size sets the decal scaling
  76419. * @param angle sets the angle to rotate the decal
  76420. * @returns a new Mesh
  76421. */
  76422. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  76423. /**
  76424. * Prepare internal position array for software CPU skinning
  76425. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  76426. */
  76427. setPositionsForCPUSkinning(): Float32Array;
  76428. /**
  76429. * Prepare internal normal array for software CPU skinning
  76430. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  76431. */
  76432. setNormalsForCPUSkinning(): Float32Array;
  76433. /**
  76434. * Updates the vertex buffer by applying transformation from the bones
  76435. * @param skeleton defines the skeleton to apply to current mesh
  76436. * @returns the current mesh
  76437. */
  76438. applySkeleton(skeleton: Skeleton): Mesh;
  76439. /**
  76440. * 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
  76441. * @param meshes defines the list of meshes to scan
  76442. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  76443. */
  76444. static MinMax(meshes: AbstractMesh[]): {
  76445. min: Vector3;
  76446. max: Vector3;
  76447. };
  76448. /**
  76449. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  76450. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  76451. * @returns a vector3
  76452. */
  76453. static Center(meshesOrMinMaxVector: {
  76454. min: Vector3;
  76455. max: Vector3;
  76456. } | AbstractMesh[]): Vector3;
  76457. /**
  76458. * Merge the array of meshes into a single mesh for performance reasons.
  76459. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  76460. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  76461. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  76462. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  76463. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  76464. * @returns a new mesh
  76465. */
  76466. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  76467. /** @hidden */
  76468. addInstance(instance: InstancedMesh): void;
  76469. /** @hidden */
  76470. removeInstance(instance: InstancedMesh): void;
  76471. }
  76472. }
  76473. declare module BABYLON {
  76474. /**
  76475. * Interface used to define Action
  76476. */
  76477. export interface IAction {
  76478. /**
  76479. * Trigger for the action
  76480. */
  76481. trigger: number;
  76482. /** the trigger, with or without parameters, for the action */
  76483. triggerOptions: any;
  76484. /**
  76485. * Gets the trigger parameters
  76486. * @returns the trigger parameters
  76487. */
  76488. getTriggerParameter(): any;
  76489. /**
  76490. * Internal only - executes current action event
  76491. * @hidden
  76492. */
  76493. _executeCurrent(evt?: ActionEvent): void;
  76494. /**
  76495. * Serialize placeholder for child classes
  76496. * @param parent of child
  76497. * @returns the serialized object
  76498. */
  76499. serialize(parent: any): any;
  76500. }
  76501. /**
  76502. * The action to be carried out following a trigger
  76503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76504. */
  76505. export class Action implements IAction {
  76506. /** the trigger, with or without parameters, for the action */
  76507. triggerOptions: any;
  76508. /**
  76509. * Trigger for the action
  76510. */
  76511. trigger: number;
  76512. /**
  76513. * Internal only - manager for action
  76514. * @hidden
  76515. */
  76516. _actionManager: ActionManager;
  76517. private _nextActiveAction;
  76518. private _child;
  76519. private _condition?;
  76520. private _triggerParameter;
  76521. /**
  76522. * An event triggered prior to action being executed.
  76523. */
  76524. onBeforeExecuteObservable: Observable<Action>;
  76525. /**
  76526. * Creates a new Action
  76527. * @param triggerOptions the trigger, with or without parameters, for the action
  76528. * @param condition an optional determinant of action
  76529. */
  76530. constructor(
  76531. /** the trigger, with or without parameters, for the action */
  76532. triggerOptions: any, condition?: Condition);
  76533. /**
  76534. * Internal only
  76535. * @hidden
  76536. */
  76537. _prepare(): void;
  76538. /**
  76539. * Gets the trigger parameters
  76540. * @returns the trigger parameters
  76541. */
  76542. getTriggerParameter(): any;
  76543. /**
  76544. * Internal only - executes current action event
  76545. * @hidden
  76546. */
  76547. _executeCurrent(evt?: ActionEvent): void;
  76548. /**
  76549. * Execute placeholder for child classes
  76550. * @param evt optional action event
  76551. */
  76552. execute(evt?: ActionEvent): void;
  76553. /**
  76554. * Skips to next active action
  76555. */
  76556. skipToNextActiveAction(): void;
  76557. /**
  76558. * Adds action to chain of actions, may be a DoNothingAction
  76559. * @param action defines the next action to execute
  76560. * @returns The action passed in
  76561. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76562. */
  76563. then(action: Action): Action;
  76564. /**
  76565. * Internal only
  76566. * @hidden
  76567. */
  76568. _getProperty(propertyPath: string): string;
  76569. /**
  76570. * Internal only
  76571. * @hidden
  76572. */
  76573. _getEffectiveTarget(target: any, propertyPath: string): any;
  76574. /**
  76575. * Serialize placeholder for child classes
  76576. * @param parent of child
  76577. * @returns the serialized object
  76578. */
  76579. serialize(parent: any): any;
  76580. /**
  76581. * Internal only called by serialize
  76582. * @hidden
  76583. */
  76584. protected _serialize(serializedAction: any, parent?: any): any;
  76585. /**
  76586. * Internal only
  76587. * @hidden
  76588. */
  76589. static _SerializeValueAsString: (value: any) => string;
  76590. /**
  76591. * Internal only
  76592. * @hidden
  76593. */
  76594. static _GetTargetProperty: (target: Scene | Node) => {
  76595. name: string;
  76596. targetType: string;
  76597. value: string;
  76598. };
  76599. }
  76600. }
  76601. declare module BABYLON {
  76602. /**
  76603. * A Condition applied to an Action
  76604. */
  76605. export class Condition {
  76606. /**
  76607. * Internal only - manager for action
  76608. * @hidden
  76609. */
  76610. _actionManager: ActionManager;
  76611. /**
  76612. * Internal only
  76613. * @hidden
  76614. */
  76615. _evaluationId: number;
  76616. /**
  76617. * Internal only
  76618. * @hidden
  76619. */
  76620. _currentResult: boolean;
  76621. /**
  76622. * Creates a new Condition
  76623. * @param actionManager the manager of the action the condition is applied to
  76624. */
  76625. constructor(actionManager: ActionManager);
  76626. /**
  76627. * Check if the current condition is valid
  76628. * @returns a boolean
  76629. */
  76630. isValid(): boolean;
  76631. /**
  76632. * Internal only
  76633. * @hidden
  76634. */
  76635. _getProperty(propertyPath: string): string;
  76636. /**
  76637. * Internal only
  76638. * @hidden
  76639. */
  76640. _getEffectiveTarget(target: any, propertyPath: string): any;
  76641. /**
  76642. * Serialize placeholder for child classes
  76643. * @returns the serialized object
  76644. */
  76645. serialize(): any;
  76646. /**
  76647. * Internal only
  76648. * @hidden
  76649. */
  76650. protected _serialize(serializedCondition: any): any;
  76651. }
  76652. /**
  76653. * Defines specific conditional operators as extensions of Condition
  76654. */
  76655. export class ValueCondition extends Condition {
  76656. /** path to specify the property of the target the conditional operator uses */
  76657. propertyPath: string;
  76658. /** the value compared by the conditional operator against the current value of the property */
  76659. value: any;
  76660. /** the conditional operator, default ValueCondition.IsEqual */
  76661. operator: number;
  76662. /**
  76663. * Internal only
  76664. * @hidden
  76665. */
  76666. private static _IsEqual;
  76667. /**
  76668. * Internal only
  76669. * @hidden
  76670. */
  76671. private static _IsDifferent;
  76672. /**
  76673. * Internal only
  76674. * @hidden
  76675. */
  76676. private static _IsGreater;
  76677. /**
  76678. * Internal only
  76679. * @hidden
  76680. */
  76681. private static _IsLesser;
  76682. /**
  76683. * returns the number for IsEqual
  76684. */
  76685. static readonly IsEqual: number;
  76686. /**
  76687. * Returns the number for IsDifferent
  76688. */
  76689. static readonly IsDifferent: number;
  76690. /**
  76691. * Returns the number for IsGreater
  76692. */
  76693. static readonly IsGreater: number;
  76694. /**
  76695. * Returns the number for IsLesser
  76696. */
  76697. static readonly IsLesser: number;
  76698. /**
  76699. * Internal only The action manager for the condition
  76700. * @hidden
  76701. */
  76702. _actionManager: ActionManager;
  76703. /**
  76704. * Internal only
  76705. * @hidden
  76706. */
  76707. private _target;
  76708. /**
  76709. * Internal only
  76710. * @hidden
  76711. */
  76712. private _effectiveTarget;
  76713. /**
  76714. * Internal only
  76715. * @hidden
  76716. */
  76717. private _property;
  76718. /**
  76719. * Creates a new ValueCondition
  76720. * @param actionManager manager for the action the condition applies to
  76721. * @param target for the action
  76722. * @param propertyPath path to specify the property of the target the conditional operator uses
  76723. * @param value the value compared by the conditional operator against the current value of the property
  76724. * @param operator the conditional operator, default ValueCondition.IsEqual
  76725. */
  76726. constructor(actionManager: ActionManager, target: any,
  76727. /** path to specify the property of the target the conditional operator uses */
  76728. propertyPath: string,
  76729. /** the value compared by the conditional operator against the current value of the property */
  76730. value: any,
  76731. /** the conditional operator, default ValueCondition.IsEqual */
  76732. operator?: number);
  76733. /**
  76734. * Compares the given value with the property value for the specified conditional operator
  76735. * @returns the result of the comparison
  76736. */
  76737. isValid(): boolean;
  76738. /**
  76739. * Serialize the ValueCondition into a JSON compatible object
  76740. * @returns serialization object
  76741. */
  76742. serialize(): any;
  76743. /**
  76744. * Gets the name of the conditional operator for the ValueCondition
  76745. * @param operator the conditional operator
  76746. * @returns the name
  76747. */
  76748. static GetOperatorName(operator: number): string;
  76749. }
  76750. /**
  76751. * Defines a predicate condition as an extension of Condition
  76752. */
  76753. export class PredicateCondition extends Condition {
  76754. /** defines the predicate function used to validate the condition */
  76755. predicate: () => boolean;
  76756. /**
  76757. * Internal only - manager for action
  76758. * @hidden
  76759. */
  76760. _actionManager: ActionManager;
  76761. /**
  76762. * Creates a new PredicateCondition
  76763. * @param actionManager manager for the action the condition applies to
  76764. * @param predicate defines the predicate function used to validate the condition
  76765. */
  76766. constructor(actionManager: ActionManager,
  76767. /** defines the predicate function used to validate the condition */
  76768. predicate: () => boolean);
  76769. /**
  76770. * @returns the validity of the predicate condition
  76771. */
  76772. isValid(): boolean;
  76773. }
  76774. /**
  76775. * Defines a state condition as an extension of Condition
  76776. */
  76777. export class StateCondition extends Condition {
  76778. /** Value to compare with target state */
  76779. value: string;
  76780. /**
  76781. * Internal only - manager for action
  76782. * @hidden
  76783. */
  76784. _actionManager: ActionManager;
  76785. /**
  76786. * Internal only
  76787. * @hidden
  76788. */
  76789. private _target;
  76790. /**
  76791. * Creates a new StateCondition
  76792. * @param actionManager manager for the action the condition applies to
  76793. * @param target of the condition
  76794. * @param value to compare with target state
  76795. */
  76796. constructor(actionManager: ActionManager, target: any,
  76797. /** Value to compare with target state */
  76798. value: string);
  76799. /**
  76800. * Gets a boolean indicating if the current condition is met
  76801. * @returns the validity of the state
  76802. */
  76803. isValid(): boolean;
  76804. /**
  76805. * Serialize the StateCondition into a JSON compatible object
  76806. * @returns serialization object
  76807. */
  76808. serialize(): any;
  76809. }
  76810. }
  76811. declare module BABYLON {
  76812. /**
  76813. * This defines an action responsible to toggle a boolean once triggered.
  76814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76815. */
  76816. export class SwitchBooleanAction extends Action {
  76817. /**
  76818. * The path to the boolean property in the target object
  76819. */
  76820. propertyPath: string;
  76821. private _target;
  76822. private _effectiveTarget;
  76823. private _property;
  76824. /**
  76825. * Instantiate the action
  76826. * @param triggerOptions defines the trigger options
  76827. * @param target defines the object containing the boolean
  76828. * @param propertyPath defines the path to the boolean property in the target object
  76829. * @param condition defines the trigger related conditions
  76830. */
  76831. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76832. /** @hidden */
  76833. _prepare(): void;
  76834. /**
  76835. * Execute the action toggle the boolean value.
  76836. */
  76837. execute(): void;
  76838. /**
  76839. * Serializes the actions and its related information.
  76840. * @param parent defines the object to serialize in
  76841. * @returns the serialized object
  76842. */
  76843. serialize(parent: any): any;
  76844. }
  76845. /**
  76846. * This defines an action responsible to set a the state field of the target
  76847. * to a desired value once triggered.
  76848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76849. */
  76850. export class SetStateAction extends Action {
  76851. /**
  76852. * The value to store in the state field.
  76853. */
  76854. value: string;
  76855. private _target;
  76856. /**
  76857. * Instantiate the action
  76858. * @param triggerOptions defines the trigger options
  76859. * @param target defines the object containing the state property
  76860. * @param value defines the value to store in the state field
  76861. * @param condition defines the trigger related conditions
  76862. */
  76863. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76864. /**
  76865. * Execute the action and store the value on the target state property.
  76866. */
  76867. execute(): void;
  76868. /**
  76869. * Serializes the actions and its related information.
  76870. * @param parent defines the object to serialize in
  76871. * @returns the serialized object
  76872. */
  76873. serialize(parent: any): any;
  76874. }
  76875. /**
  76876. * This defines an action responsible to set a property of the target
  76877. * to a desired value once triggered.
  76878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76879. */
  76880. export class SetValueAction extends Action {
  76881. /**
  76882. * The path of the property to set in the target.
  76883. */
  76884. propertyPath: string;
  76885. /**
  76886. * The value to set in the property
  76887. */
  76888. value: any;
  76889. private _target;
  76890. private _effectiveTarget;
  76891. private _property;
  76892. /**
  76893. * Instantiate the action
  76894. * @param triggerOptions defines the trigger options
  76895. * @param target defines the object containing the property
  76896. * @param propertyPath defines the path of the property to set in the target
  76897. * @param value defines the value to set in the property
  76898. * @param condition defines the trigger related conditions
  76899. */
  76900. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76901. /** @hidden */
  76902. _prepare(): void;
  76903. /**
  76904. * Execute the action and set the targetted property to the desired value.
  76905. */
  76906. execute(): void;
  76907. /**
  76908. * Serializes the actions and its related information.
  76909. * @param parent defines the object to serialize in
  76910. * @returns the serialized object
  76911. */
  76912. serialize(parent: any): any;
  76913. }
  76914. /**
  76915. * This defines an action responsible to increment the target value
  76916. * to a desired value once triggered.
  76917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76918. */
  76919. export class IncrementValueAction extends Action {
  76920. /**
  76921. * The path of the property to increment in the target.
  76922. */
  76923. propertyPath: string;
  76924. /**
  76925. * The value we should increment the property by.
  76926. */
  76927. value: any;
  76928. private _target;
  76929. private _effectiveTarget;
  76930. private _property;
  76931. /**
  76932. * Instantiate the action
  76933. * @param triggerOptions defines the trigger options
  76934. * @param target defines the object containing the property
  76935. * @param propertyPath defines the path of the property to increment in the target
  76936. * @param value defines the value value we should increment the property by
  76937. * @param condition defines the trigger related conditions
  76938. */
  76939. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76940. /** @hidden */
  76941. _prepare(): void;
  76942. /**
  76943. * Execute the action and increment the target of the value amount.
  76944. */
  76945. execute(): void;
  76946. /**
  76947. * Serializes the actions and its related information.
  76948. * @param parent defines the object to serialize in
  76949. * @returns the serialized object
  76950. */
  76951. serialize(parent: any): any;
  76952. }
  76953. /**
  76954. * This defines an action responsible to start an animation once triggered.
  76955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76956. */
  76957. export class PlayAnimationAction extends Action {
  76958. /**
  76959. * Where the animation should start (animation frame)
  76960. */
  76961. from: number;
  76962. /**
  76963. * Where the animation should stop (animation frame)
  76964. */
  76965. to: number;
  76966. /**
  76967. * Define if the animation should loop or stop after the first play.
  76968. */
  76969. loop?: boolean;
  76970. private _target;
  76971. /**
  76972. * Instantiate the action
  76973. * @param triggerOptions defines the trigger options
  76974. * @param target defines the target animation or animation name
  76975. * @param from defines from where the animation should start (animation frame)
  76976. * @param end defines where the animation should stop (animation frame)
  76977. * @param loop defines if the animation should loop or stop after the first play
  76978. * @param condition defines the trigger related conditions
  76979. */
  76980. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76981. /** @hidden */
  76982. _prepare(): void;
  76983. /**
  76984. * Execute the action and play the animation.
  76985. */
  76986. execute(): void;
  76987. /**
  76988. * Serializes the actions and its related information.
  76989. * @param parent defines the object to serialize in
  76990. * @returns the serialized object
  76991. */
  76992. serialize(parent: any): any;
  76993. }
  76994. /**
  76995. * This defines an action responsible to stop an animation once triggered.
  76996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76997. */
  76998. export class StopAnimationAction extends Action {
  76999. private _target;
  77000. /**
  77001. * Instantiate the action
  77002. * @param triggerOptions defines the trigger options
  77003. * @param target defines the target animation or animation name
  77004. * @param condition defines the trigger related conditions
  77005. */
  77006. constructor(triggerOptions: any, target: any, condition?: Condition);
  77007. /** @hidden */
  77008. _prepare(): void;
  77009. /**
  77010. * Execute the action and stop the animation.
  77011. */
  77012. execute(): void;
  77013. /**
  77014. * Serializes the actions and its related information.
  77015. * @param parent defines the object to serialize in
  77016. * @returns the serialized object
  77017. */
  77018. serialize(parent: any): any;
  77019. }
  77020. /**
  77021. * This defines an action responsible that does nothing once triggered.
  77022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77023. */
  77024. export class DoNothingAction extends Action {
  77025. /**
  77026. * Instantiate the action
  77027. * @param triggerOptions defines the trigger options
  77028. * @param condition defines the trigger related conditions
  77029. */
  77030. constructor(triggerOptions?: any, condition?: Condition);
  77031. /**
  77032. * Execute the action and do nothing.
  77033. */
  77034. execute(): void;
  77035. /**
  77036. * Serializes the actions and its related information.
  77037. * @param parent defines the object to serialize in
  77038. * @returns the serialized object
  77039. */
  77040. serialize(parent: any): any;
  77041. }
  77042. /**
  77043. * This defines an action responsible to trigger several actions once triggered.
  77044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77045. */
  77046. export class CombineAction extends Action {
  77047. /**
  77048. * The list of aggregated animations to run.
  77049. */
  77050. children: Action[];
  77051. /**
  77052. * Instantiate the action
  77053. * @param triggerOptions defines the trigger options
  77054. * @param children defines the list of aggregated animations to run
  77055. * @param condition defines the trigger related conditions
  77056. */
  77057. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77058. /** @hidden */
  77059. _prepare(): void;
  77060. /**
  77061. * Execute the action and executes all the aggregated actions.
  77062. */
  77063. execute(evt: ActionEvent): void;
  77064. /**
  77065. * Serializes the actions and its related information.
  77066. * @param parent defines the object to serialize in
  77067. * @returns the serialized object
  77068. */
  77069. serialize(parent: any): any;
  77070. }
  77071. /**
  77072. * This defines an action responsible to run code (external event) once triggered.
  77073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77074. */
  77075. export class ExecuteCodeAction extends Action {
  77076. /**
  77077. * The callback function to run.
  77078. */
  77079. func: (evt: ActionEvent) => void;
  77080. /**
  77081. * Instantiate the action
  77082. * @param triggerOptions defines the trigger options
  77083. * @param func defines the callback function to run
  77084. * @param condition defines the trigger related conditions
  77085. */
  77086. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77087. /**
  77088. * Execute the action and run the attached code.
  77089. */
  77090. execute(evt: ActionEvent): void;
  77091. }
  77092. /**
  77093. * This defines an action responsible to set the parent property of the target once triggered.
  77094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77095. */
  77096. export class SetParentAction extends Action {
  77097. private _parent;
  77098. private _target;
  77099. /**
  77100. * Instantiate the action
  77101. * @param triggerOptions defines the trigger options
  77102. * @param target defines the target containing the parent property
  77103. * @param parent defines from where the animation should start (animation frame)
  77104. * @param condition defines the trigger related conditions
  77105. */
  77106. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77107. /** @hidden */
  77108. _prepare(): void;
  77109. /**
  77110. * Execute the action and set the parent property.
  77111. */
  77112. execute(): void;
  77113. /**
  77114. * Serializes the actions and its related information.
  77115. * @param parent defines the object to serialize in
  77116. * @returns the serialized object
  77117. */
  77118. serialize(parent: any): any;
  77119. }
  77120. }
  77121. declare module BABYLON {
  77122. /**
  77123. * Abstract class used to decouple action Manager from scene and meshes.
  77124. * Do not instantiate.
  77125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77126. */
  77127. export abstract class AbstractActionManager implements IDisposable {
  77128. /** Gets the list of active triggers */
  77129. static Triggers: {
  77130. [key: string]: number;
  77131. };
  77132. /** Gets the cursor to use when hovering items */
  77133. hoverCursor: string;
  77134. /** Gets the list of actions */
  77135. actions: IAction[];
  77136. /**
  77137. * Releases all associated resources
  77138. */
  77139. abstract dispose(): void;
  77140. /**
  77141. * Does this action manager has pointer triggers
  77142. */
  77143. abstract readonly hasPointerTriggers: boolean;
  77144. /**
  77145. * Does this action manager has pick triggers
  77146. */
  77147. abstract readonly hasPickTriggers: boolean;
  77148. /**
  77149. * Process a specific trigger
  77150. * @param trigger defines the trigger to process
  77151. * @param evt defines the event details to be processed
  77152. */
  77153. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  77154. /**
  77155. * Does this action manager handles actions of any of the given triggers
  77156. * @param triggers defines the triggers to be tested
  77157. * @return a boolean indicating whether one (or more) of the triggers is handled
  77158. */
  77159. abstract hasSpecificTriggers(triggers: number[]): boolean;
  77160. /**
  77161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77162. * speed.
  77163. * @param triggerA defines the trigger to be tested
  77164. * @param triggerB defines the trigger to be tested
  77165. * @return a boolean indicating whether one (or more) of the triggers is handled
  77166. */
  77167. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77168. /**
  77169. * Does this action manager handles actions of a given trigger
  77170. * @param trigger defines the trigger to be tested
  77171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77172. * @return whether the trigger is handled
  77173. */
  77174. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77175. /**
  77176. * Serialize this manager to a JSON object
  77177. * @param name defines the property name to store this manager
  77178. * @returns a JSON representation of this manager
  77179. */
  77180. abstract serialize(name: string): any;
  77181. /**
  77182. * Does exist one action manager with at least one trigger
  77183. **/
  77184. static readonly HasTriggers: boolean;
  77185. /**
  77186. * Does exist one action manager with at least one pick trigger
  77187. **/
  77188. static readonly HasPickTriggers: boolean;
  77189. /**
  77190. * Does exist one action manager that handles actions of a given trigger
  77191. * @param trigger defines the trigger to be tested
  77192. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  77193. **/
  77194. static HasSpecificTrigger(trigger: number): boolean;
  77195. }
  77196. }
  77197. declare module BABYLON {
  77198. /**
  77199. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77200. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77202. */
  77203. export class ActionManager extends AbstractActionManager {
  77204. /**
  77205. * Nothing
  77206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77207. */
  77208. static readonly NothingTrigger: number;
  77209. /**
  77210. * On pick
  77211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77212. */
  77213. static readonly OnPickTrigger: number;
  77214. /**
  77215. * On left pick
  77216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77217. */
  77218. static readonly OnLeftPickTrigger: number;
  77219. /**
  77220. * On right pick
  77221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77222. */
  77223. static readonly OnRightPickTrigger: number;
  77224. /**
  77225. * On center pick
  77226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77227. */
  77228. static readonly OnCenterPickTrigger: number;
  77229. /**
  77230. * On pick down
  77231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77232. */
  77233. static readonly OnPickDownTrigger: number;
  77234. /**
  77235. * On double pick
  77236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77237. */
  77238. static readonly OnDoublePickTrigger: number;
  77239. /**
  77240. * On pick up
  77241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77242. */
  77243. static readonly OnPickUpTrigger: number;
  77244. /**
  77245. * On pick out.
  77246. * This trigger will only be raised if you also declared a OnPickDown
  77247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77248. */
  77249. static readonly OnPickOutTrigger: number;
  77250. /**
  77251. * On long press
  77252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77253. */
  77254. static readonly OnLongPressTrigger: number;
  77255. /**
  77256. * On pointer over
  77257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77258. */
  77259. static readonly OnPointerOverTrigger: number;
  77260. /**
  77261. * On pointer out
  77262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77263. */
  77264. static readonly OnPointerOutTrigger: number;
  77265. /**
  77266. * On every frame
  77267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77268. */
  77269. static readonly OnEveryFrameTrigger: number;
  77270. /**
  77271. * On intersection enter
  77272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77273. */
  77274. static readonly OnIntersectionEnterTrigger: number;
  77275. /**
  77276. * On intersection exit
  77277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77278. */
  77279. static readonly OnIntersectionExitTrigger: number;
  77280. /**
  77281. * On key down
  77282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77283. */
  77284. static readonly OnKeyDownTrigger: number;
  77285. /**
  77286. * On key up
  77287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77288. */
  77289. static readonly OnKeyUpTrigger: number;
  77290. private _scene;
  77291. /**
  77292. * Creates a new action manager
  77293. * @param scene defines the hosting scene
  77294. */
  77295. constructor(scene: Scene);
  77296. /**
  77297. * Releases all associated resources
  77298. */
  77299. dispose(): void;
  77300. /**
  77301. * Gets hosting scene
  77302. * @returns the hosting scene
  77303. */
  77304. getScene(): Scene;
  77305. /**
  77306. * Does this action manager handles actions of any of the given triggers
  77307. * @param triggers defines the triggers to be tested
  77308. * @return a boolean indicating whether one (or more) of the triggers is handled
  77309. */
  77310. hasSpecificTriggers(triggers: number[]): boolean;
  77311. /**
  77312. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77313. * speed.
  77314. * @param triggerA defines the trigger to be tested
  77315. * @param triggerB defines the trigger to be tested
  77316. * @return a boolean indicating whether one (or more) of the triggers is handled
  77317. */
  77318. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77319. /**
  77320. * Does this action manager handles actions of a given trigger
  77321. * @param trigger defines the trigger to be tested
  77322. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77323. * @return whether the trigger is handled
  77324. */
  77325. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77326. /**
  77327. * Does this action manager has pointer triggers
  77328. */
  77329. readonly hasPointerTriggers: boolean;
  77330. /**
  77331. * Does this action manager has pick triggers
  77332. */
  77333. readonly hasPickTriggers: boolean;
  77334. /**
  77335. * Registers an action to this action manager
  77336. * @param action defines the action to be registered
  77337. * @return the action amended (prepared) after registration
  77338. */
  77339. registerAction(action: Action): Nullable<Action>;
  77340. /**
  77341. * Unregisters an action to this action manager
  77342. * @param action defines the action to be unregistered
  77343. * @return a boolean indicating whether the action has been unregistered
  77344. */
  77345. unregisterAction(action: Action): Boolean;
  77346. /**
  77347. * Process a specific trigger
  77348. * @param trigger defines the trigger to process
  77349. * @param evt defines the event details to be processed
  77350. */
  77351. processTrigger(trigger: number, evt?: IActionEvent): void;
  77352. /** @hidden */
  77353. _getEffectiveTarget(target: any, propertyPath: string): any;
  77354. /** @hidden */
  77355. _getProperty(propertyPath: string): string;
  77356. /**
  77357. * Serialize this manager to a JSON object
  77358. * @param name defines the property name to store this manager
  77359. * @returns a JSON representation of this manager
  77360. */
  77361. serialize(name: string): any;
  77362. /**
  77363. * Creates a new ActionManager from a JSON data
  77364. * @param parsedActions defines the JSON data to read from
  77365. * @param object defines the hosting mesh
  77366. * @param scene defines the hosting scene
  77367. */
  77368. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77369. /**
  77370. * Get a trigger name by index
  77371. * @param trigger defines the trigger index
  77372. * @returns a trigger name
  77373. */
  77374. static GetTriggerName(trigger: number): string;
  77375. }
  77376. }
  77377. declare module BABYLON {
  77378. /**
  77379. * Class used to represent a sprite
  77380. * @see http://doc.babylonjs.com/babylon101/sprites
  77381. */
  77382. export class Sprite {
  77383. /** defines the name */
  77384. name: string;
  77385. /** Gets or sets the current world position */
  77386. position: Vector3;
  77387. /** Gets or sets the main color */
  77388. color: Color4;
  77389. /** Gets or sets the width */
  77390. width: number;
  77391. /** Gets or sets the height */
  77392. height: number;
  77393. /** Gets or sets rotation angle */
  77394. angle: number;
  77395. /** Gets or sets the cell index in the sprite sheet */
  77396. cellIndex: number;
  77397. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77398. invertU: number;
  77399. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77400. invertV: number;
  77401. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77402. disposeWhenFinishedAnimating: boolean;
  77403. /** Gets the list of attached animations */
  77404. animations: Animation[];
  77405. /** Gets or sets a boolean indicating if the sprite can be picked */
  77406. isPickable: boolean;
  77407. /**
  77408. * Gets or sets the associated action manager
  77409. */
  77410. actionManager: Nullable<ActionManager>;
  77411. private _animationStarted;
  77412. private _loopAnimation;
  77413. private _fromIndex;
  77414. private _toIndex;
  77415. private _delay;
  77416. private _direction;
  77417. private _manager;
  77418. private _time;
  77419. private _onAnimationEnd;
  77420. /**
  77421. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77422. */
  77423. isVisible: boolean;
  77424. /**
  77425. * Gets or sets the sprite size
  77426. */
  77427. size: number;
  77428. /**
  77429. * Creates a new Sprite
  77430. * @param name defines the name
  77431. * @param manager defines the manager
  77432. */
  77433. constructor(
  77434. /** defines the name */
  77435. name: string, manager: ISpriteManager);
  77436. /**
  77437. * Starts an animation
  77438. * @param from defines the initial key
  77439. * @param to defines the end key
  77440. * @param loop defines if the animation must loop
  77441. * @param delay defines the start delay (in ms)
  77442. * @param onAnimationEnd defines a callback to call when animation ends
  77443. */
  77444. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77445. /** Stops current animation (if any) */
  77446. stopAnimation(): void;
  77447. /** @hidden */
  77448. _animate(deltaTime: number): void;
  77449. /** Release associated resources */
  77450. dispose(): void;
  77451. }
  77452. }
  77453. declare module BABYLON {
  77454. /**
  77455. * Information about the result of picking within a scene
  77456. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77457. */
  77458. export class PickingInfo {
  77459. /**
  77460. * If the pick collided with an object
  77461. */
  77462. hit: boolean;
  77463. /**
  77464. * Distance away where the pick collided
  77465. */
  77466. distance: number;
  77467. /**
  77468. * The location of pick collision
  77469. */
  77470. pickedPoint: Nullable<Vector3>;
  77471. /**
  77472. * The mesh corresponding the the pick collision
  77473. */
  77474. pickedMesh: Nullable<AbstractMesh>;
  77475. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  77476. bu: number;
  77477. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  77478. bv: number;
  77479. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77480. faceId: number;
  77481. /** Id of the the submesh that was picked */
  77482. subMeshId: number;
  77483. /** If a sprite was picked, this will be the sprite the pick collided with */
  77484. pickedSprite: Nullable<Sprite>;
  77485. /**
  77486. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77487. */
  77488. originMesh: Nullable<AbstractMesh>;
  77489. /**
  77490. * The ray that was used to perform the picking.
  77491. */
  77492. ray: Nullable<Ray>;
  77493. /**
  77494. * Gets the normal correspodning to the face the pick collided with
  77495. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77496. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77497. * @returns The normal correspodning to the face the pick collided with
  77498. */
  77499. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77500. /**
  77501. * Gets the texture coordinates of where the pick occured
  77502. * @returns the vector containing the coordnates of the texture
  77503. */
  77504. getTextureCoordinates(): Nullable<Vector2>;
  77505. }
  77506. }
  77507. declare module BABYLON {
  77508. /**
  77509. * Class representing a ray with position and direction
  77510. */
  77511. export class Ray {
  77512. /** origin point */
  77513. origin: Vector3;
  77514. /** direction */
  77515. direction: Vector3;
  77516. /** length of the ray */
  77517. length: number;
  77518. private static readonly TmpVector3;
  77519. private _tmpRay;
  77520. /**
  77521. * Creates a new ray
  77522. * @param origin origin point
  77523. * @param direction direction
  77524. * @param length length of the ray
  77525. */
  77526. constructor(
  77527. /** origin point */
  77528. origin: Vector3,
  77529. /** direction */
  77530. direction: Vector3,
  77531. /** length of the ray */
  77532. length?: number);
  77533. /**
  77534. * Checks if the ray intersects a box
  77535. * @param minimum bound of the box
  77536. * @param maximum bound of the box
  77537. * @param intersectionTreshold extra extend to be added to the box in all direction
  77538. * @returns if the box was hit
  77539. */
  77540. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77541. /**
  77542. * Checks if the ray intersects a box
  77543. * @param box the bounding box to check
  77544. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77545. * @returns if the box was hit
  77546. */
  77547. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77548. /**
  77549. * If the ray hits a sphere
  77550. * @param sphere the bounding sphere to check
  77551. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77552. * @returns true if it hits the sphere
  77553. */
  77554. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77555. /**
  77556. * If the ray hits a triange
  77557. * @param vertex0 triangle vertex
  77558. * @param vertex1 triangle vertex
  77559. * @param vertex2 triangle vertex
  77560. * @returns intersection information if hit
  77561. */
  77562. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77563. /**
  77564. * Checks if ray intersects a plane
  77565. * @param plane the plane to check
  77566. * @returns the distance away it was hit
  77567. */
  77568. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77569. /**
  77570. * Checks if ray intersects a mesh
  77571. * @param mesh the mesh to check
  77572. * @param fastCheck if only the bounding box should checked
  77573. * @returns picking info of the intersecton
  77574. */
  77575. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77576. /**
  77577. * Checks if ray intersects a mesh
  77578. * @param meshes the meshes to check
  77579. * @param fastCheck if only the bounding box should checked
  77580. * @param results array to store result in
  77581. * @returns Array of picking infos
  77582. */
  77583. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77584. private _comparePickingInfo;
  77585. private static smallnum;
  77586. private static rayl;
  77587. /**
  77588. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77589. * @param sega the first point of the segment to test the intersection against
  77590. * @param segb the second point of the segment to test the intersection against
  77591. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77592. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77593. */
  77594. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77595. /**
  77596. * Update the ray from viewport position
  77597. * @param x position
  77598. * @param y y position
  77599. * @param viewportWidth viewport width
  77600. * @param viewportHeight viewport height
  77601. * @param world world matrix
  77602. * @param view view matrix
  77603. * @param projection projection matrix
  77604. * @returns this ray updated
  77605. */
  77606. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77607. /**
  77608. * Creates a ray with origin and direction of 0,0,0
  77609. * @returns the new ray
  77610. */
  77611. static Zero(): Ray;
  77612. /**
  77613. * Creates a new ray from screen space and viewport
  77614. * @param x position
  77615. * @param y y position
  77616. * @param viewportWidth viewport width
  77617. * @param viewportHeight viewport height
  77618. * @param world world matrix
  77619. * @param view view matrix
  77620. * @param projection projection matrix
  77621. * @returns new ray
  77622. */
  77623. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77624. /**
  77625. * 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
  77626. * transformed to the given world matrix.
  77627. * @param origin The origin point
  77628. * @param end The end point
  77629. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77630. * @returns the new ray
  77631. */
  77632. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77633. /**
  77634. * Transforms a ray by a matrix
  77635. * @param ray ray to transform
  77636. * @param matrix matrix to apply
  77637. * @returns the resulting new ray
  77638. */
  77639. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77640. /**
  77641. * Transforms a ray by a matrix
  77642. * @param ray ray to transform
  77643. * @param matrix matrix to apply
  77644. * @param result ray to store result in
  77645. */
  77646. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77647. /**
  77648. * Unproject a ray from screen space to object space
  77649. * @param sourceX defines the screen space x coordinate to use
  77650. * @param sourceY defines the screen space y coordinate to use
  77651. * @param viewportWidth defines the current width of the viewport
  77652. * @param viewportHeight defines the current height of the viewport
  77653. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77654. * @param view defines the view matrix to use
  77655. * @param projection defines the projection matrix to use
  77656. */
  77657. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77658. }
  77659. }
  77660. declare module BABYLON {
  77661. /**
  77662. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77663. * separate meshes. This can be use to improve performances.
  77664. * @see http://doc.babylonjs.com/how_to/multi_materials
  77665. */
  77666. export class MultiMaterial extends Material {
  77667. private _subMaterials;
  77668. /**
  77669. * Gets or Sets the list of Materials used within the multi material.
  77670. * They need to be ordered according to the submeshes order in the associated mesh
  77671. */
  77672. subMaterials: Nullable<Material>[];
  77673. /**
  77674. * Function used to align with Node.getChildren()
  77675. * @returns the list of Materials used within the multi material
  77676. */
  77677. getChildren(): Nullable<Material>[];
  77678. /**
  77679. * Instantiates a new Multi Material
  77680. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77681. * separate meshes. This can be use to improve performances.
  77682. * @see http://doc.babylonjs.com/how_to/multi_materials
  77683. * @param name Define the name in the scene
  77684. * @param scene Define the scene the material belongs to
  77685. */
  77686. constructor(name: string, scene: Scene);
  77687. private _hookArray;
  77688. /**
  77689. * Get one of the submaterial by its index in the submaterials array
  77690. * @param index The index to look the sub material at
  77691. * @returns The Material if the index has been defined
  77692. */
  77693. getSubMaterial(index: number): Nullable<Material>;
  77694. /**
  77695. * Get the list of active textures for the whole sub materials list.
  77696. * @returns All the textures that will be used during the rendering
  77697. */
  77698. getActiveTextures(): BaseTexture[];
  77699. /**
  77700. * Gets the current class name of the material e.g. "MultiMaterial"
  77701. * Mainly use in serialization.
  77702. * @returns the class name
  77703. */
  77704. getClassName(): string;
  77705. /**
  77706. * Checks if the material is ready to render the requested sub mesh
  77707. * @param mesh Define the mesh the submesh belongs to
  77708. * @param subMesh Define the sub mesh to look readyness for
  77709. * @param useInstances Define whether or not the material is used with instances
  77710. * @returns true if ready, otherwise false
  77711. */
  77712. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77713. /**
  77714. * Clones the current material and its related sub materials
  77715. * @param name Define the name of the newly cloned material
  77716. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  77717. * @returns the cloned material
  77718. */
  77719. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  77720. /**
  77721. * Serializes the materials into a JSON representation.
  77722. * @returns the JSON representation
  77723. */
  77724. serialize(): any;
  77725. /**
  77726. * Dispose the material and release its associated resources
  77727. * @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)
  77728. * @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)
  77729. * @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)
  77730. */
  77731. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  77732. /**
  77733. * Creates a MultiMaterial from parsed MultiMaterial data.
  77734. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  77735. * @param scene defines the hosting scene
  77736. * @returns a new MultiMaterial
  77737. */
  77738. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  77739. }
  77740. }
  77741. declare module BABYLON {
  77742. /**
  77743. * Base class for submeshes
  77744. */
  77745. export class BaseSubMesh {
  77746. /** @hidden */
  77747. _materialDefines: Nullable<MaterialDefines>;
  77748. /** @hidden */
  77749. _materialEffect: Nullable<Effect>;
  77750. /**
  77751. * Gets associated effect
  77752. */
  77753. readonly effect: Nullable<Effect>;
  77754. /**
  77755. * Sets associated effect (effect used to render this submesh)
  77756. * @param effect defines the effect to associate with
  77757. * @param defines defines the set of defines used to compile this effect
  77758. */
  77759. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77760. }
  77761. /**
  77762. * Defines a subdivision inside a mesh
  77763. */
  77764. export class SubMesh extends BaseSubMesh implements ICullable {
  77765. /** the material index to use */
  77766. materialIndex: number;
  77767. /** vertex index start */
  77768. verticesStart: number;
  77769. /** vertices count */
  77770. verticesCount: number;
  77771. /** index start */
  77772. indexStart: number;
  77773. /** indices count */
  77774. indexCount: number;
  77775. /** @hidden */
  77776. _linesIndexCount: number;
  77777. private _mesh;
  77778. private _renderingMesh;
  77779. private _boundingInfo;
  77780. private _linesIndexBuffer;
  77781. /** @hidden */
  77782. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77783. /** @hidden */
  77784. _trianglePlanes: Plane[];
  77785. /** @hidden */
  77786. _lastColliderTransformMatrix: Matrix;
  77787. /** @hidden */
  77788. _renderId: number;
  77789. /** @hidden */
  77790. _alphaIndex: number;
  77791. /** @hidden */
  77792. _distanceToCamera: number;
  77793. /** @hidden */
  77794. _id: number;
  77795. private _currentMaterial;
  77796. /**
  77797. * Add a new submesh to a mesh
  77798. * @param materialIndex defines the material index to use
  77799. * @param verticesStart defines vertex index start
  77800. * @param verticesCount defines vertices count
  77801. * @param indexStart defines index start
  77802. * @param indexCount defines indices count
  77803. * @param mesh defines the parent mesh
  77804. * @param renderingMesh defines an optional rendering mesh
  77805. * @param createBoundingBox defines if bounding box should be created for this submesh
  77806. * @returns the new submesh
  77807. */
  77808. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77809. /**
  77810. * Creates a new submesh
  77811. * @param materialIndex defines the material index to use
  77812. * @param verticesStart defines vertex index start
  77813. * @param verticesCount defines vertices count
  77814. * @param indexStart defines index start
  77815. * @param indexCount defines indices count
  77816. * @param mesh defines the parent mesh
  77817. * @param renderingMesh defines an optional rendering mesh
  77818. * @param createBoundingBox defines if bounding box should be created for this submesh
  77819. */
  77820. constructor(
  77821. /** the material index to use */
  77822. materialIndex: number,
  77823. /** vertex index start */
  77824. verticesStart: number,
  77825. /** vertices count */
  77826. verticesCount: number,
  77827. /** index start */
  77828. indexStart: number,
  77829. /** indices count */
  77830. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77831. /**
  77832. * Returns true if this submesh covers the entire parent mesh
  77833. * @ignorenaming
  77834. */
  77835. readonly IsGlobal: boolean;
  77836. /**
  77837. * Returns the submesh BoudingInfo object
  77838. * @returns current bounding info (or mesh's one if the submesh is global)
  77839. */
  77840. getBoundingInfo(): BoundingInfo;
  77841. /**
  77842. * Sets the submesh BoundingInfo
  77843. * @param boundingInfo defines the new bounding info to use
  77844. * @returns the SubMesh
  77845. */
  77846. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77847. /**
  77848. * Returns the mesh of the current submesh
  77849. * @return the parent mesh
  77850. */
  77851. getMesh(): AbstractMesh;
  77852. /**
  77853. * Returns the rendering mesh of the submesh
  77854. * @returns the rendering mesh (could be different from parent mesh)
  77855. */
  77856. getRenderingMesh(): Mesh;
  77857. /**
  77858. * Returns the submesh material
  77859. * @returns null or the current material
  77860. */
  77861. getMaterial(): Nullable<Material>;
  77862. /**
  77863. * Sets a new updated BoundingInfo object to the submesh
  77864. * @returns the SubMesh
  77865. */
  77866. refreshBoundingInfo(): SubMesh;
  77867. /** @hidden */
  77868. _checkCollision(collider: Collider): boolean;
  77869. /**
  77870. * Updates the submesh BoundingInfo
  77871. * @param world defines the world matrix to use to update the bounding info
  77872. * @returns the submesh
  77873. */
  77874. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77875. /**
  77876. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77877. * @param frustumPlanes defines the frustum planes
  77878. * @returns true if the submesh is intersecting with the frustum
  77879. */
  77880. isInFrustum(frustumPlanes: Plane[]): boolean;
  77881. /**
  77882. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77883. * @param frustumPlanes defines the frustum planes
  77884. * @returns true if the submesh is inside the frustum
  77885. */
  77886. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77887. /**
  77888. * Renders the submesh
  77889. * @param enableAlphaMode defines if alpha needs to be used
  77890. * @returns the submesh
  77891. */
  77892. render(enableAlphaMode: boolean): SubMesh;
  77893. /**
  77894. * @hidden
  77895. */
  77896. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77897. /**
  77898. * Checks if the submesh intersects with a ray
  77899. * @param ray defines the ray to test
  77900. * @returns true is the passed ray intersects the submesh bounding box
  77901. */
  77902. canIntersects(ray: Ray): boolean;
  77903. /**
  77904. * Intersects current submesh with a ray
  77905. * @param ray defines the ray to test
  77906. * @param positions defines mesh's positions array
  77907. * @param indices defines mesh's indices array
  77908. * @param fastCheck defines if only bounding info should be used
  77909. * @returns intersection info or null if no intersection
  77910. */
  77911. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77912. /** @hidden */
  77913. private _intersectLines;
  77914. /** @hidden */
  77915. private _intersectTriangles;
  77916. /** @hidden */
  77917. _rebuild(): void;
  77918. /**
  77919. * Creates a new submesh from the passed mesh
  77920. * @param newMesh defines the new hosting mesh
  77921. * @param newRenderingMesh defines an optional rendering mesh
  77922. * @returns the new submesh
  77923. */
  77924. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77925. /**
  77926. * Release associated resources
  77927. */
  77928. dispose(): void;
  77929. /**
  77930. * Gets the class name
  77931. * @returns the string "SubMesh".
  77932. */
  77933. getClassName(): string;
  77934. /**
  77935. * Creates a new submesh from indices data
  77936. * @param materialIndex the index of the main mesh material
  77937. * @param startIndex the index where to start the copy in the mesh indices array
  77938. * @param indexCount the number of indices to copy then from the startIndex
  77939. * @param mesh the main mesh to create the submesh from
  77940. * @param renderingMesh the optional rendering mesh
  77941. * @returns a new submesh
  77942. */
  77943. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77944. }
  77945. }
  77946. declare module BABYLON {
  77947. /**
  77948. * Class used to store geometry data (vertex buffers + index buffer)
  77949. */
  77950. export class Geometry implements IGetSetVerticesData {
  77951. /**
  77952. * Gets or sets the ID of the geometry
  77953. */
  77954. id: string;
  77955. /**
  77956. * Gets or sets the unique ID of the geometry
  77957. */
  77958. uniqueId: number;
  77959. /**
  77960. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77961. */
  77962. delayLoadState: number;
  77963. /**
  77964. * Gets the file containing the data to load when running in delay load state
  77965. */
  77966. delayLoadingFile: Nullable<string>;
  77967. /**
  77968. * Callback called when the geometry is updated
  77969. */
  77970. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77971. private _scene;
  77972. private _engine;
  77973. private _meshes;
  77974. private _totalVertices;
  77975. /** @hidden */
  77976. _indices: IndicesArray;
  77977. /** @hidden */
  77978. _vertexBuffers: {
  77979. [key: string]: VertexBuffer;
  77980. };
  77981. private _isDisposed;
  77982. private _extend;
  77983. private _boundingBias;
  77984. /** @hidden */
  77985. _delayInfo: Array<string>;
  77986. private _indexBuffer;
  77987. private _indexBufferIsUpdatable;
  77988. /** @hidden */
  77989. _boundingInfo: Nullable<BoundingInfo>;
  77990. /** @hidden */
  77991. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77992. /** @hidden */
  77993. _softwareSkinningFrameId: number;
  77994. private _vertexArrayObjects;
  77995. private _updatable;
  77996. /** @hidden */
  77997. _positions: Nullable<Vector3[]>;
  77998. /**
  77999. * 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
  78000. */
  78001. /**
  78002. * 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
  78003. */
  78004. boundingBias: Vector2;
  78005. /**
  78006. * Static function used to attach a new empty geometry to a mesh
  78007. * @param mesh defines the mesh to attach the geometry to
  78008. * @returns the new Geometry
  78009. */
  78010. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  78011. /**
  78012. * Creates a new geometry
  78013. * @param id defines the unique ID
  78014. * @param scene defines the hosting scene
  78015. * @param vertexData defines the VertexData used to get geometry data
  78016. * @param updatable defines if geometry must be updatable (false by default)
  78017. * @param mesh defines the mesh that will be associated with the geometry
  78018. */
  78019. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  78020. /**
  78021. * Gets the current extend of the geometry
  78022. */
  78023. readonly extend: {
  78024. minimum: Vector3;
  78025. maximum: Vector3;
  78026. };
  78027. /**
  78028. * Gets the hosting scene
  78029. * @returns the hosting Scene
  78030. */
  78031. getScene(): Scene;
  78032. /**
  78033. * Gets the hosting engine
  78034. * @returns the hosting Engine
  78035. */
  78036. getEngine(): Engine;
  78037. /**
  78038. * Defines if the geometry is ready to use
  78039. * @returns true if the geometry is ready to be used
  78040. */
  78041. isReady(): boolean;
  78042. /**
  78043. * Gets a value indicating that the geometry should not be serialized
  78044. */
  78045. readonly doNotSerialize: boolean;
  78046. /** @hidden */
  78047. _rebuild(): void;
  78048. /**
  78049. * Affects all geometry data in one call
  78050. * @param vertexData defines the geometry data
  78051. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  78052. */
  78053. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  78054. /**
  78055. * Set specific vertex data
  78056. * @param kind defines the data kind (Position, normal, etc...)
  78057. * @param data defines the vertex data to use
  78058. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78059. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78060. */
  78061. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  78062. /**
  78063. * Removes a specific vertex data
  78064. * @param kind defines the data kind (Position, normal, etc...)
  78065. */
  78066. removeVerticesData(kind: string): void;
  78067. /**
  78068. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  78069. * @param buffer defines the vertex buffer to use
  78070. * @param totalVertices defines the total number of vertices for position kind (could be null)
  78071. */
  78072. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  78073. /**
  78074. * Update a specific vertex buffer
  78075. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  78076. * It will do nothing if the buffer is not updatable
  78077. * @param kind defines the data kind (Position, normal, etc...)
  78078. * @param data defines the data to use
  78079. * @param offset defines the offset in the target buffer where to store the data
  78080. * @param useBytes set to true if the offset is in bytes
  78081. */
  78082. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  78083. /**
  78084. * Update a specific vertex buffer
  78085. * This function will create a new buffer if the current one is not updatable
  78086. * @param kind defines the data kind (Position, normal, etc...)
  78087. * @param data defines the data to use
  78088. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  78089. */
  78090. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  78091. private _updateBoundingInfo;
  78092. /** @hidden */
  78093. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  78094. /**
  78095. * Gets total number of vertices
  78096. * @returns the total number of vertices
  78097. */
  78098. getTotalVertices(): number;
  78099. /**
  78100. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78101. * @param kind defines the data kind (Position, normal, etc...)
  78102. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78103. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78104. * @returns a float array containing vertex data
  78105. */
  78106. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78107. /**
  78108. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  78109. * @param kind defines the data kind (Position, normal, etc...)
  78110. * @returns true if the vertex buffer with the specified kind is updatable
  78111. */
  78112. isVertexBufferUpdatable(kind: string): boolean;
  78113. /**
  78114. * Gets a specific vertex buffer
  78115. * @param kind defines the data kind (Position, normal, etc...)
  78116. * @returns a VertexBuffer
  78117. */
  78118. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78119. /**
  78120. * Returns all vertex buffers
  78121. * @return an object holding all vertex buffers indexed by kind
  78122. */
  78123. getVertexBuffers(): Nullable<{
  78124. [key: string]: VertexBuffer;
  78125. }>;
  78126. /**
  78127. * Gets a boolean indicating if specific vertex buffer is present
  78128. * @param kind defines the data kind (Position, normal, etc...)
  78129. * @returns true if data is present
  78130. */
  78131. isVerticesDataPresent(kind: string): boolean;
  78132. /**
  78133. * Gets a list of all attached data kinds (Position, normal, etc...)
  78134. * @returns a list of string containing all kinds
  78135. */
  78136. getVerticesDataKinds(): string[];
  78137. /**
  78138. * Update index buffer
  78139. * @param indices defines the indices to store in the index buffer
  78140. * @param offset defines the offset in the target buffer where to store the data
  78141. */
  78142. updateIndices(indices: IndicesArray, offset?: number): void;
  78143. /**
  78144. * Creates a new index buffer
  78145. * @param indices defines the indices to store in the index buffer
  78146. * @param totalVertices defines the total number of vertices (could be null)
  78147. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78148. */
  78149. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  78150. /**
  78151. * Return the total number of indices
  78152. * @returns the total number of indices
  78153. */
  78154. getTotalIndices(): number;
  78155. /**
  78156. * Gets the index buffer array
  78157. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78158. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78159. * @returns the index buffer array
  78160. */
  78161. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78162. /**
  78163. * Gets the index buffer
  78164. * @return the index buffer
  78165. */
  78166. getIndexBuffer(): Nullable<WebGLBuffer>;
  78167. /** @hidden */
  78168. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  78169. /**
  78170. * Release the associated resources for a specific mesh
  78171. * @param mesh defines the source mesh
  78172. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  78173. */
  78174. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  78175. /**
  78176. * Apply current geometry to a given mesh
  78177. * @param mesh defines the mesh to apply geometry to
  78178. */
  78179. applyToMesh(mesh: Mesh): void;
  78180. private _updateExtend;
  78181. private _applyToMesh;
  78182. private notifyUpdate;
  78183. /**
  78184. * Load the geometry if it was flagged as delay loaded
  78185. * @param scene defines the hosting scene
  78186. * @param onLoaded defines a callback called when the geometry is loaded
  78187. */
  78188. load(scene: Scene, onLoaded?: () => void): void;
  78189. private _queueLoad;
  78190. /**
  78191. * Invert the geometry to move from a right handed system to a left handed one.
  78192. */
  78193. toLeftHanded(): void;
  78194. /** @hidden */
  78195. _resetPointsArrayCache(): void;
  78196. /** @hidden */
  78197. _generatePointsArray(): boolean;
  78198. /**
  78199. * Gets a value indicating if the geometry is disposed
  78200. * @returns true if the geometry was disposed
  78201. */
  78202. isDisposed(): boolean;
  78203. private _disposeVertexArrayObjects;
  78204. /**
  78205. * Free all associated resources
  78206. */
  78207. dispose(): void;
  78208. /**
  78209. * Clone the current geometry into a new geometry
  78210. * @param id defines the unique ID of the new geometry
  78211. * @returns a new geometry object
  78212. */
  78213. copy(id: string): Geometry;
  78214. /**
  78215. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78216. * @return a JSON representation of the current geometry data (without the vertices data)
  78217. */
  78218. serialize(): any;
  78219. private toNumberArray;
  78220. /**
  78221. * Serialize all vertices data into a JSON oject
  78222. * @returns a JSON representation of the current geometry data
  78223. */
  78224. serializeVerticeData(): any;
  78225. /**
  78226. * Extracts a clone of a mesh geometry
  78227. * @param mesh defines the source mesh
  78228. * @param id defines the unique ID of the new geometry object
  78229. * @returns the new geometry object
  78230. */
  78231. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  78232. /**
  78233. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78234. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78235. * Be aware Math.random() could cause collisions, but:
  78236. * "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"
  78237. * @returns a string containing a new GUID
  78238. */
  78239. static RandomId(): string;
  78240. /** @hidden */
  78241. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  78242. private static _CleanMatricesWeights;
  78243. /**
  78244. * Create a new geometry from persisted data (Using .babylon file format)
  78245. * @param parsedVertexData defines the persisted data
  78246. * @param scene defines the hosting scene
  78247. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78248. * @returns the new geometry object
  78249. */
  78250. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  78251. }
  78252. }
  78253. declare module BABYLON {
  78254. /**
  78255. * Define an interface for all classes that will get and set the data on vertices
  78256. */
  78257. export interface IGetSetVerticesData {
  78258. /**
  78259. * Gets a boolean indicating if specific vertex data is present
  78260. * @param kind defines the vertex data kind to use
  78261. * @returns true is data kind is present
  78262. */
  78263. isVerticesDataPresent(kind: string): boolean;
  78264. /**
  78265. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78266. * @param kind defines the data kind (Position, normal, etc...)
  78267. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78268. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78269. * @returns a float array containing vertex data
  78270. */
  78271. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78272. /**
  78273. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78274. * @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.
  78275. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78276. * @returns the indices array or an empty array if the mesh has no geometry
  78277. */
  78278. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78279. /**
  78280. * Set specific vertex data
  78281. * @param kind defines the data kind (Position, normal, etc...)
  78282. * @param data defines the vertex data to use
  78283. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78284. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78285. */
  78286. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  78287. /**
  78288. * Update a specific associated vertex buffer
  78289. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78290. * - VertexBuffer.PositionKind
  78291. * - VertexBuffer.UVKind
  78292. * - VertexBuffer.UV2Kind
  78293. * - VertexBuffer.UV3Kind
  78294. * - VertexBuffer.UV4Kind
  78295. * - VertexBuffer.UV5Kind
  78296. * - VertexBuffer.UV6Kind
  78297. * - VertexBuffer.ColorKind
  78298. * - VertexBuffer.MatricesIndicesKind
  78299. * - VertexBuffer.MatricesIndicesExtraKind
  78300. * - VertexBuffer.MatricesWeightsKind
  78301. * - VertexBuffer.MatricesWeightsExtraKind
  78302. * @param data defines the data source
  78303. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78304. * @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)
  78305. */
  78306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  78307. /**
  78308. * Creates a new index buffer
  78309. * @param indices defines the indices to store in the index buffer
  78310. * @param totalVertices defines the total number of vertices (could be null)
  78311. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78312. */
  78313. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  78314. }
  78315. /**
  78316. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  78317. */
  78318. export class VertexData {
  78319. /**
  78320. * Mesh side orientation : usually the external or front surface
  78321. */
  78322. static readonly FRONTSIDE: number;
  78323. /**
  78324. * Mesh side orientation : usually the internal or back surface
  78325. */
  78326. static readonly BACKSIDE: number;
  78327. /**
  78328. * Mesh side orientation : both internal and external or front and back surfaces
  78329. */
  78330. static readonly DOUBLESIDE: number;
  78331. /**
  78332. * Mesh side orientation : by default, `FRONTSIDE`
  78333. */
  78334. static readonly DEFAULTSIDE: number;
  78335. /**
  78336. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  78337. */
  78338. positions: Nullable<FloatArray>;
  78339. /**
  78340. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  78341. */
  78342. normals: Nullable<FloatArray>;
  78343. /**
  78344. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  78345. */
  78346. tangents: Nullable<FloatArray>;
  78347. /**
  78348. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78349. */
  78350. uvs: Nullable<FloatArray>;
  78351. /**
  78352. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78353. */
  78354. uvs2: Nullable<FloatArray>;
  78355. /**
  78356. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78357. */
  78358. uvs3: Nullable<FloatArray>;
  78359. /**
  78360. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78361. */
  78362. uvs4: Nullable<FloatArray>;
  78363. /**
  78364. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78365. */
  78366. uvs5: Nullable<FloatArray>;
  78367. /**
  78368. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  78369. */
  78370. uvs6: Nullable<FloatArray>;
  78371. /**
  78372. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  78373. */
  78374. colors: Nullable<FloatArray>;
  78375. /**
  78376. * 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).
  78377. */
  78378. matricesIndices: Nullable<FloatArray>;
  78379. /**
  78380. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  78381. */
  78382. matricesWeights: Nullable<FloatArray>;
  78383. /**
  78384. * An array extending the number of possible indices
  78385. */
  78386. matricesIndicesExtra: Nullable<FloatArray>;
  78387. /**
  78388. * An array extending the number of possible weights when the number of indices is extended
  78389. */
  78390. matricesWeightsExtra: Nullable<FloatArray>;
  78391. /**
  78392. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  78393. */
  78394. indices: Nullable<IndicesArray>;
  78395. /**
  78396. * Uses the passed data array to set the set the values for the specified kind of data
  78397. * @param data a linear array of floating numbers
  78398. * @param kind the type of data that is being set, eg positions, colors etc
  78399. */
  78400. set(data: FloatArray, kind: string): void;
  78401. /**
  78402. * Associates the vertexData to the passed Mesh.
  78403. * Sets it as updatable or not (default `false`)
  78404. * @param mesh the mesh the vertexData is applied to
  78405. * @param updatable when used and having the value true allows new data to update the vertexData
  78406. * @returns the VertexData
  78407. */
  78408. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  78409. /**
  78410. * Associates the vertexData to the passed Geometry.
  78411. * Sets it as updatable or not (default `false`)
  78412. * @param geometry the geometry the vertexData is applied to
  78413. * @param updatable when used and having the value true allows new data to update the vertexData
  78414. * @returns VertexData
  78415. */
  78416. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  78417. /**
  78418. * Updates the associated mesh
  78419. * @param mesh the mesh to be updated
  78420. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  78421. * @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
  78422. * @returns VertexData
  78423. */
  78424. updateMesh(mesh: Mesh): VertexData;
  78425. /**
  78426. * Updates the associated geometry
  78427. * @param geometry the geometry to be updated
  78428. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  78429. * @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
  78430. * @returns VertexData.
  78431. */
  78432. updateGeometry(geometry: Geometry): VertexData;
  78433. private _applyTo;
  78434. private _update;
  78435. /**
  78436. * Transforms each position and each normal of the vertexData according to the passed Matrix
  78437. * @param matrix the transforming matrix
  78438. * @returns the VertexData
  78439. */
  78440. transform(matrix: Matrix): VertexData;
  78441. /**
  78442. * Merges the passed VertexData into the current one
  78443. * @param other the VertexData to be merged into the current one
  78444. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  78445. * @returns the modified VertexData
  78446. */
  78447. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  78448. private _mergeElement;
  78449. private _validate;
  78450. /**
  78451. * Serializes the VertexData
  78452. * @returns a serialized object
  78453. */
  78454. serialize(): any;
  78455. /**
  78456. * Extracts the vertexData from a mesh
  78457. * @param mesh the mesh from which to extract the VertexData
  78458. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  78459. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78460. * @returns the object VertexData associated to the passed mesh
  78461. */
  78462. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78463. /**
  78464. * Extracts the vertexData from the geometry
  78465. * @param geometry the geometry from which to extract the VertexData
  78466. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  78467. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  78468. * @returns the object VertexData associated to the passed mesh
  78469. */
  78470. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  78471. private static _ExtractFrom;
  78472. /**
  78473. * Creates the VertexData for a Ribbon
  78474. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  78475. * * pathArray array of paths, each of which an array of successive Vector3
  78476. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  78477. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  78478. * * 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
  78479. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78480. * * 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)
  78481. * * 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)
  78482. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  78483. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  78484. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  78485. * @returns the VertexData of the ribbon
  78486. */
  78487. static CreateRibbon(options: {
  78488. pathArray: Vector3[][];
  78489. closeArray?: boolean;
  78490. closePath?: boolean;
  78491. offset?: number;
  78492. sideOrientation?: number;
  78493. frontUVs?: Vector4;
  78494. backUVs?: Vector4;
  78495. invertUV?: boolean;
  78496. uvs?: Vector2[];
  78497. colors?: Color4[];
  78498. }): VertexData;
  78499. /**
  78500. * Creates the VertexData for a box
  78501. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78502. * * size sets the width, height and depth of the box to the value of size, optional default 1
  78503. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  78504. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  78505. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  78506. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  78507. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  78508. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78509. * * 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)
  78510. * * 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)
  78511. * @returns the VertexData of the box
  78512. */
  78513. static CreateBox(options: {
  78514. size?: number;
  78515. width?: number;
  78516. height?: number;
  78517. depth?: number;
  78518. faceUV?: Vector4[];
  78519. faceColors?: Color4[];
  78520. sideOrientation?: number;
  78521. frontUVs?: Vector4;
  78522. backUVs?: Vector4;
  78523. }): VertexData;
  78524. /**
  78525. * Creates the VertexData for an ellipsoid, defaults to a sphere
  78526. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78527. * * segments sets the number of horizontal strips optional, default 32
  78528. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  78529. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  78530. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  78531. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  78532. * * 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
  78533. * * 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
  78534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78535. * * 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)
  78536. * * 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)
  78537. * @returns the VertexData of the ellipsoid
  78538. */
  78539. static CreateSphere(options: {
  78540. segments?: number;
  78541. diameter?: number;
  78542. diameterX?: number;
  78543. diameterY?: number;
  78544. diameterZ?: number;
  78545. arc?: number;
  78546. slice?: number;
  78547. sideOrientation?: number;
  78548. frontUVs?: Vector4;
  78549. backUVs?: Vector4;
  78550. }): VertexData;
  78551. /**
  78552. * Creates the VertexData for a cylinder, cone or prism
  78553. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78554. * * height sets the height (y direction) of the cylinder, optional, default 2
  78555. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  78556. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  78557. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  78558. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78559. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  78560. * * 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
  78561. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78562. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78563. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  78564. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  78565. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78566. * * 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)
  78567. * * 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)
  78568. * @returns the VertexData of the cylinder, cone or prism
  78569. */
  78570. static CreateCylinder(options: {
  78571. height?: number;
  78572. diameterTop?: number;
  78573. diameterBottom?: number;
  78574. diameter?: number;
  78575. tessellation?: number;
  78576. subdivisions?: number;
  78577. arc?: number;
  78578. faceColors?: Color4[];
  78579. faceUV?: Vector4[];
  78580. hasRings?: boolean;
  78581. enclose?: boolean;
  78582. sideOrientation?: number;
  78583. frontUVs?: Vector4;
  78584. backUVs?: Vector4;
  78585. }): VertexData;
  78586. /**
  78587. * Creates the VertexData for a torus
  78588. * @param options an object used to set the following optional parameters for the box, required but can be empty
  78589. * * diameter the diameter of the torus, optional default 1
  78590. * * thickness the diameter of the tube forming the torus, optional default 0.5
  78591. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  78592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78593. * * 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)
  78594. * * 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)
  78595. * @returns the VertexData of the torus
  78596. */
  78597. static CreateTorus(options: {
  78598. diameter?: number;
  78599. thickness?: number;
  78600. tessellation?: number;
  78601. sideOrientation?: number;
  78602. frontUVs?: Vector4;
  78603. backUVs?: Vector4;
  78604. }): VertexData;
  78605. /**
  78606. * Creates the VertexData of the LineSystem
  78607. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78608. * - lines an array of lines, each line being an array of successive Vector3
  78609. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78610. * @returns the VertexData of the LineSystem
  78611. */
  78612. static CreateLineSystem(options: {
  78613. lines: Vector3[][];
  78614. colors?: Nullable<Color4[][]>;
  78615. }): VertexData;
  78616. /**
  78617. * Create the VertexData for a DashedLines
  78618. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78619. * - points an array successive Vector3
  78620. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78621. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78622. * - dashNb the intended total number of dashes, optional, default 200
  78623. * @returns the VertexData for the DashedLines
  78624. */
  78625. static CreateDashedLines(options: {
  78626. points: Vector3[];
  78627. dashSize?: number;
  78628. gapSize?: number;
  78629. dashNb?: number;
  78630. }): VertexData;
  78631. /**
  78632. * Creates the VertexData for a Ground
  78633. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78634. * - width the width (x direction) of the ground, optional, default 1
  78635. * - height the height (z direction) of the ground, optional, default 1
  78636. * - subdivisions the number of subdivisions per side, optional, default 1
  78637. * @returns the VertexData of the Ground
  78638. */
  78639. static CreateGround(options: {
  78640. width?: number;
  78641. height?: number;
  78642. subdivisions?: number;
  78643. subdivisionsX?: number;
  78644. subdivisionsY?: number;
  78645. }): VertexData;
  78646. /**
  78647. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78648. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78649. * * xmin the ground minimum X coordinate, optional, default -1
  78650. * * zmin the ground minimum Z coordinate, optional, default -1
  78651. * * xmax the ground maximum X coordinate, optional, default 1
  78652. * * zmax the ground maximum Z coordinate, optional, default 1
  78653. * * 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}
  78654. * * 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}
  78655. * @returns the VertexData of the TiledGround
  78656. */
  78657. static CreateTiledGround(options: {
  78658. xmin: number;
  78659. zmin: number;
  78660. xmax: number;
  78661. zmax: number;
  78662. subdivisions?: {
  78663. w: number;
  78664. h: number;
  78665. };
  78666. precision?: {
  78667. w: number;
  78668. h: number;
  78669. };
  78670. }): VertexData;
  78671. /**
  78672. * Creates the VertexData of the Ground designed from a heightmap
  78673. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78674. * * width the width (x direction) of the ground
  78675. * * height the height (z direction) of the ground
  78676. * * subdivisions the number of subdivisions per side
  78677. * * minHeight the minimum altitude on the ground, optional, default 0
  78678. * * maxHeight the maximum altitude on the ground, optional default 1
  78679. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78680. * * buffer the array holding the image color data
  78681. * * bufferWidth the width of image
  78682. * * bufferHeight the height of image
  78683. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78684. * @returns the VertexData of the Ground designed from a heightmap
  78685. */
  78686. static CreateGroundFromHeightMap(options: {
  78687. width: number;
  78688. height: number;
  78689. subdivisions: number;
  78690. minHeight: number;
  78691. maxHeight: number;
  78692. colorFilter: Color3;
  78693. buffer: Uint8Array;
  78694. bufferWidth: number;
  78695. bufferHeight: number;
  78696. alphaFilter: number;
  78697. }): VertexData;
  78698. /**
  78699. * Creates the VertexData for a Plane
  78700. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78701. * * size sets the width and height of the plane to the value of size, optional default 1
  78702. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78703. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78705. * * 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)
  78706. * * 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)
  78707. * @returns the VertexData of the box
  78708. */
  78709. static CreatePlane(options: {
  78710. size?: number;
  78711. width?: number;
  78712. height?: number;
  78713. sideOrientation?: number;
  78714. frontUVs?: Vector4;
  78715. backUVs?: Vector4;
  78716. }): VertexData;
  78717. /**
  78718. * Creates the VertexData of the Disc or regular Polygon
  78719. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78720. * * radius the radius of the disc, optional default 0.5
  78721. * * tessellation the number of polygon sides, optional, default 64
  78722. * * 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
  78723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78724. * * 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)
  78725. * * 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)
  78726. * @returns the VertexData of the box
  78727. */
  78728. static CreateDisc(options: {
  78729. radius?: number;
  78730. tessellation?: number;
  78731. arc?: number;
  78732. sideOrientation?: number;
  78733. frontUVs?: Vector4;
  78734. backUVs?: Vector4;
  78735. }): VertexData;
  78736. /**
  78737. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78738. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78739. * @param polygon a mesh built from polygonTriangulation.build()
  78740. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78741. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78742. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78743. * @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)
  78744. * @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)
  78745. * @returns the VertexData of the Polygon
  78746. */
  78747. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78748. /**
  78749. * Creates the VertexData of the IcoSphere
  78750. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78751. * * radius the radius of the IcoSphere, optional default 1
  78752. * * radiusX allows stretching in the x direction, optional, default radius
  78753. * * radiusY allows stretching in the y direction, optional, default radius
  78754. * * radiusZ allows stretching in the z direction, optional, default radius
  78755. * * flat when true creates a flat shaded mesh, optional, default true
  78756. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78758. * * 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)
  78759. * * 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)
  78760. * @returns the VertexData of the IcoSphere
  78761. */
  78762. static CreateIcoSphere(options: {
  78763. radius?: number;
  78764. radiusX?: number;
  78765. radiusY?: number;
  78766. radiusZ?: number;
  78767. flat?: boolean;
  78768. subdivisions?: number;
  78769. sideOrientation?: number;
  78770. frontUVs?: Vector4;
  78771. backUVs?: Vector4;
  78772. }): VertexData;
  78773. /**
  78774. * Creates the VertexData for a Polyhedron
  78775. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78776. * * type provided types are:
  78777. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78778. * * 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)
  78779. * * size the size of the IcoSphere, optional default 1
  78780. * * sizeX allows stretching in the x direction, optional, default size
  78781. * * sizeY allows stretching in the y direction, optional, default size
  78782. * * sizeZ allows stretching in the z direction, optional, default size
  78783. * * 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
  78784. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78785. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78786. * * flat when true creates a flat shaded mesh, optional, default true
  78787. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78789. * * 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)
  78790. * * 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)
  78791. * @returns the VertexData of the Polyhedron
  78792. */
  78793. static CreatePolyhedron(options: {
  78794. type?: number;
  78795. size?: number;
  78796. sizeX?: number;
  78797. sizeY?: number;
  78798. sizeZ?: number;
  78799. custom?: any;
  78800. faceUV?: Vector4[];
  78801. faceColors?: Color4[];
  78802. flat?: boolean;
  78803. sideOrientation?: number;
  78804. frontUVs?: Vector4;
  78805. backUVs?: Vector4;
  78806. }): VertexData;
  78807. /**
  78808. * Creates the VertexData for a TorusKnot
  78809. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78810. * * radius the radius of the torus knot, optional, default 2
  78811. * * tube the thickness of the tube, optional, default 0.5
  78812. * * radialSegments the number of sides on each tube segments, optional, default 32
  78813. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78814. * * p the number of windings around the z axis, optional, default 2
  78815. * * q the number of windings around the x axis, optional, default 3
  78816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78817. * * 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)
  78818. * * 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)
  78819. * @returns the VertexData of the Torus Knot
  78820. */
  78821. static CreateTorusKnot(options: {
  78822. radius?: number;
  78823. tube?: number;
  78824. radialSegments?: number;
  78825. tubularSegments?: number;
  78826. p?: number;
  78827. q?: number;
  78828. sideOrientation?: number;
  78829. frontUVs?: Vector4;
  78830. backUVs?: Vector4;
  78831. }): VertexData;
  78832. /**
  78833. * Compute normals for given positions and indices
  78834. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78835. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78836. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78837. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78838. * * facetNormals : optional array of facet normals (vector3)
  78839. * * facetPositions : optional array of facet positions (vector3)
  78840. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78841. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78842. * * bInfo : optional bounding info, required for facetPartitioning computation
  78843. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78844. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78845. * * useRightHandedSystem: optional boolean to for right handed system computation
  78846. * * depthSort : optional boolean to enable the facet depth sort computation
  78847. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78848. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78849. */
  78850. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78851. facetNormals?: any;
  78852. facetPositions?: any;
  78853. facetPartitioning?: any;
  78854. ratio?: number;
  78855. bInfo?: any;
  78856. bbSize?: Vector3;
  78857. subDiv?: any;
  78858. useRightHandedSystem?: boolean;
  78859. depthSort?: boolean;
  78860. distanceTo?: Vector3;
  78861. depthSortedFacets?: any;
  78862. }): void;
  78863. /** @hidden */
  78864. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  78865. /**
  78866. * Applies VertexData created from the imported parameters to the geometry
  78867. * @param parsedVertexData the parsed data from an imported file
  78868. * @param geometry the geometry to apply the VertexData to
  78869. */
  78870. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /**
  78875. * Class containing static functions to help procedurally build meshes
  78876. */
  78877. export class DiscBuilder {
  78878. /**
  78879. * Creates a plane polygonal mesh. By default, this is a disc
  78880. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78881. * * 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
  78882. * * 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
  78883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78886. * @param name defines the name of the mesh
  78887. * @param options defines the options used to create the mesh
  78888. * @param scene defines the hosting scene
  78889. * @returns the plane polygonal mesh
  78890. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78891. */
  78892. static CreateDisc(name: string, options: {
  78893. radius?: number;
  78894. tessellation?: number;
  78895. arc?: number;
  78896. updatable?: boolean;
  78897. sideOrientation?: number;
  78898. frontUVs?: Vector4;
  78899. backUVs?: Vector4;
  78900. }, scene?: Nullable<Scene>): Mesh;
  78901. }
  78902. }
  78903. declare module BABYLON {
  78904. /**
  78905. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  78906. *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.
  78907. * The SPS is also a particle system. It provides some methods to manage the particles.
  78908. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  78909. *
  78910. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  78911. */
  78912. export class SolidParticleSystem implements IDisposable {
  78913. /**
  78914. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  78915. * Example : var p = SPS.particles[i];
  78916. */
  78917. particles: SolidParticle[];
  78918. /**
  78919. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  78920. */
  78921. nbParticles: number;
  78922. /**
  78923. * If the particles must ever face the camera (default false). Useful for planar particles.
  78924. */
  78925. billboard: boolean;
  78926. /**
  78927. * Recompute normals when adding a shape
  78928. */
  78929. recomputeNormals: boolean;
  78930. /**
  78931. * This a counter ofr your own usage. It's not set by any SPS functions.
  78932. */
  78933. counter: number;
  78934. /**
  78935. * The SPS name. This name is also given to the underlying mesh.
  78936. */
  78937. name: string;
  78938. /**
  78939. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  78940. */
  78941. mesh: Mesh;
  78942. /**
  78943. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  78944. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  78945. */
  78946. vars: any;
  78947. /**
  78948. * This array is populated when the SPS is set as 'pickable'.
  78949. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  78950. * Each element of this array is an object `{idx: int, faceId: int}`.
  78951. * `idx` is the picked particle index in the `SPS.particles` array
  78952. * `faceId` is the picked face index counted within this particle.
  78953. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  78954. */
  78955. pickedParticles: {
  78956. idx: number;
  78957. faceId: number;
  78958. }[];
  78959. /**
  78960. * This array is populated when `enableDepthSort` is set to true.
  78961. * Each element of this array is an instance of the class DepthSortedParticle.
  78962. */
  78963. depthSortedParticles: DepthSortedParticle[];
  78964. /**
  78965. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  78966. * @hidden
  78967. */
  78968. _bSphereOnly: boolean;
  78969. /**
  78970. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  78971. * @hidden
  78972. */
  78973. _bSphereRadiusFactor: number;
  78974. private _scene;
  78975. private _positions;
  78976. private _indices;
  78977. private _normals;
  78978. private _colors;
  78979. private _uvs;
  78980. private _indices32;
  78981. private _positions32;
  78982. private _normals32;
  78983. private _fixedNormal32;
  78984. private _colors32;
  78985. private _uvs32;
  78986. private _index;
  78987. private _updatable;
  78988. private _pickable;
  78989. private _isVisibilityBoxLocked;
  78990. private _alwaysVisible;
  78991. private _depthSort;
  78992. private _shapeCounter;
  78993. private _copy;
  78994. private _color;
  78995. private _computeParticleColor;
  78996. private _computeParticleTexture;
  78997. private _computeParticleRotation;
  78998. private _computeParticleVertex;
  78999. private _computeBoundingBox;
  79000. private _depthSortParticles;
  79001. private _camera;
  79002. private _mustUnrotateFixedNormals;
  79003. private _particlesIntersect;
  79004. private _needs32Bits;
  79005. /**
  79006. * Creates a SPS (Solid Particle System) object.
  79007. * @param name (String) is the SPS name, this will be the underlying mesh name.
  79008. * @param scene (Scene) is the scene in which the SPS is added.
  79009. * @param options defines the options of the sps e.g.
  79010. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  79011. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  79012. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  79013. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  79014. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  79015. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  79016. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  79017. */
  79018. constructor(name: string, scene: Scene, options?: {
  79019. updatable?: boolean;
  79020. isPickable?: boolean;
  79021. enableDepthSort?: boolean;
  79022. particleIntersection?: boolean;
  79023. boundingSphereOnly?: boolean;
  79024. bSphereRadiusFactor?: number;
  79025. });
  79026. /**
  79027. * Builds the SPS underlying mesh. Returns a standard Mesh.
  79028. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  79029. * @returns the created mesh
  79030. */
  79031. buildMesh(): Mesh;
  79032. /**
  79033. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  79034. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  79035. * Thus the particles generated from `digest()` have their property `position` set yet.
  79036. * @param mesh ( Mesh ) is the mesh to be digested
  79037. * @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
  79038. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  79039. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  79040. * @returns the current SPS
  79041. */
  79042. digest(mesh: Mesh, options?: {
  79043. facetNb?: number;
  79044. number?: number;
  79045. delta?: number;
  79046. }): SolidParticleSystem;
  79047. private _unrotateFixedNormals;
  79048. private _resetCopy;
  79049. private _meshBuilder;
  79050. private _posToShape;
  79051. private _uvsToShapeUV;
  79052. private _addParticle;
  79053. /**
  79054. * Adds some particles to the SPS from the model shape. Returns the shape id.
  79055. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  79056. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  79057. * @param nb (positive integer) the number of particles to be created from this model
  79058. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  79059. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  79060. * @returns the number of shapes in the system
  79061. */
  79062. addShape(mesh: Mesh, nb: number, options?: {
  79063. positionFunction?: any;
  79064. vertexFunction?: any;
  79065. }): number;
  79066. private _rebuildParticle;
  79067. /**
  79068. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  79069. * @returns the SPS.
  79070. */
  79071. rebuildMesh(): SolidParticleSystem;
  79072. /**
  79073. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  79074. * This method calls `updateParticle()` for each particle of the SPS.
  79075. * For an animated SPS, it is usually called within the render loop.
  79076. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  79077. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  79078. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  79079. * @returns the SPS.
  79080. */
  79081. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  79082. /**
  79083. * Disposes the SPS.
  79084. */
  79085. dispose(): void;
  79086. /**
  79087. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  79088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79089. * @returns the SPS.
  79090. */
  79091. refreshVisibleSize(): SolidParticleSystem;
  79092. /**
  79093. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  79094. * @param size the size (float) of the visibility box
  79095. * note : this doesn't lock the SPS mesh bounding box.
  79096. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79097. */
  79098. setVisibilityBox(size: number): void;
  79099. /**
  79100. * Gets whether the SPS as always visible or not
  79101. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79102. */
  79103. /**
  79104. * Sets the SPS as always visible or not
  79105. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79106. */
  79107. isAlwaysVisible: boolean;
  79108. /**
  79109. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79110. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79111. */
  79112. /**
  79113. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79114. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79115. */
  79116. isVisibilityBoxLocked: boolean;
  79117. /**
  79118. * Tells to `setParticles()` to compute the particle rotations or not.
  79119. * Default value : true. The SPS is faster when it's set to false.
  79120. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79121. */
  79122. /**
  79123. * Gets if `setParticles()` computes the particle rotations or not.
  79124. * Default value : true. The SPS is faster when it's set to false.
  79125. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79126. */
  79127. computeParticleRotation: boolean;
  79128. /**
  79129. * Tells to `setParticles()` to compute the particle colors or not.
  79130. * Default value : true. The SPS is faster when it's set to false.
  79131. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79132. */
  79133. /**
  79134. * Gets if `setParticles()` computes the particle colors or not.
  79135. * Default value : true. The SPS is faster when it's set to false.
  79136. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79137. */
  79138. computeParticleColor: boolean;
  79139. /**
  79140. * Gets if `setParticles()` computes the particle textures or not.
  79141. * Default value : true. The SPS is faster when it's set to false.
  79142. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  79143. */
  79144. computeParticleTexture: boolean;
  79145. /**
  79146. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  79147. * Default value : false. The SPS is faster when it's set to false.
  79148. * Note : the particle custom vertex positions aren't stored values.
  79149. */
  79150. /**
  79151. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  79152. * Default value : false. The SPS is faster when it's set to false.
  79153. * Note : the particle custom vertex positions aren't stored values.
  79154. */
  79155. computeParticleVertex: boolean;
  79156. /**
  79157. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  79158. */
  79159. /**
  79160. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  79161. */
  79162. computeBoundingBox: boolean;
  79163. /**
  79164. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  79165. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79166. * Default : `true`
  79167. */
  79168. /**
  79169. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  79170. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79171. * Default : `true`
  79172. */
  79173. depthSortParticles: boolean;
  79174. /**
  79175. * This function does nothing. It may be overwritten to set all the particle first values.
  79176. * The SPS doesn't call this function, you may have to call it by your own.
  79177. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79178. */
  79179. initParticles(): void;
  79180. /**
  79181. * This function does nothing. It may be overwritten to recycle a particle.
  79182. * The SPS doesn't call this function, you may have to call it by your own.
  79183. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79184. * @param particle The particle to recycle
  79185. * @returns the recycled particle
  79186. */
  79187. recycleParticle(particle: SolidParticle): SolidParticle;
  79188. /**
  79189. * Updates a particle : this function should be overwritten by the user.
  79190. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  79191. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79192. * @example : just set a particle position or velocity and recycle conditions
  79193. * @param particle The particle to update
  79194. * @returns the updated particle
  79195. */
  79196. updateParticle(particle: SolidParticle): SolidParticle;
  79197. /**
  79198. * Updates a vertex of a particle : it can be overwritten by the user.
  79199. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  79200. * @param particle the current particle
  79201. * @param vertex the current index of the current particle
  79202. * @param pt the index of the current vertex in the particle shape
  79203. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  79204. * @example : just set a vertex particle position
  79205. * @returns the updated vertex
  79206. */
  79207. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  79208. /**
  79209. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  79210. * This does nothing and may be overwritten by the user.
  79211. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79212. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79213. * @param update the boolean update value actually passed to setParticles()
  79214. */
  79215. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79216. /**
  79217. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  79218. * This will be passed three parameters.
  79219. * This does nothing and may be overwritten by the user.
  79220. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79221. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79222. * @param update the boolean update value actually passed to setParticles()
  79223. */
  79224. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79225. }
  79226. }
  79227. declare module BABYLON {
  79228. /**
  79229. * Represents one particle of a solid particle system.
  79230. */
  79231. export class SolidParticle {
  79232. /**
  79233. * particle global index
  79234. */
  79235. idx: number;
  79236. /**
  79237. * The color of the particle
  79238. */
  79239. color: Nullable<Color4>;
  79240. /**
  79241. * The world space position of the particle.
  79242. */
  79243. position: Vector3;
  79244. /**
  79245. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  79246. */
  79247. rotation: Vector3;
  79248. /**
  79249. * The world space rotation quaternion of the particle.
  79250. */
  79251. rotationQuaternion: Nullable<Quaternion>;
  79252. /**
  79253. * The scaling of the particle.
  79254. */
  79255. scaling: Vector3;
  79256. /**
  79257. * The uvs of the particle.
  79258. */
  79259. uvs: Vector4;
  79260. /**
  79261. * The current speed of the particle.
  79262. */
  79263. velocity: Vector3;
  79264. /**
  79265. * The pivot point in the particle local space.
  79266. */
  79267. pivot: Vector3;
  79268. /**
  79269. * Must the particle be translated from its pivot point in its local space ?
  79270. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  79271. * Default : false
  79272. */
  79273. translateFromPivot: boolean;
  79274. /**
  79275. * Is the particle active or not ?
  79276. */
  79277. alive: boolean;
  79278. /**
  79279. * Is the particle visible or not ?
  79280. */
  79281. isVisible: boolean;
  79282. /**
  79283. * Index of this particle in the global "positions" array (Internal use)
  79284. * @hidden
  79285. */
  79286. _pos: number;
  79287. /**
  79288. * @hidden Index of this particle in the global "indices" array (Internal use)
  79289. */
  79290. _ind: number;
  79291. /**
  79292. * @hidden ModelShape of this particle (Internal use)
  79293. */
  79294. _model: ModelShape;
  79295. /**
  79296. * ModelShape id of this particle
  79297. */
  79298. shapeId: number;
  79299. /**
  79300. * Index of the particle in its shape id (Internal use)
  79301. */
  79302. idxInShape: number;
  79303. /**
  79304. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  79305. */
  79306. _modelBoundingInfo: BoundingInfo;
  79307. /**
  79308. * @hidden Particle BoundingInfo object (Internal use)
  79309. */
  79310. _boundingInfo: BoundingInfo;
  79311. /**
  79312. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  79313. */
  79314. _sps: SolidParticleSystem;
  79315. /**
  79316. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  79317. */
  79318. _stillInvisible: boolean;
  79319. /**
  79320. * @hidden Last computed particle rotation matrix
  79321. */
  79322. _rotationMatrix: number[];
  79323. /**
  79324. * Parent particle Id, if any.
  79325. * Default null.
  79326. */
  79327. parentId: Nullable<number>;
  79328. /**
  79329. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  79330. * The possible values are :
  79331. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79332. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79333. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79334. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79335. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79336. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  79337. * */
  79338. cullingStrategy: number;
  79339. /**
  79340. * @hidden Internal global position in the SPS.
  79341. */
  79342. _globalPosition: Vector3;
  79343. /**
  79344. * Creates a Solid Particle object.
  79345. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  79346. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  79347. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  79348. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  79349. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  79350. * @param shapeId (integer) is the model shape identifier in the SPS.
  79351. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  79352. * @param sps defines the sps it is associated to
  79353. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  79354. */
  79355. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  79356. /**
  79357. * Legacy support, changed scale to scaling
  79358. */
  79359. /**
  79360. * Legacy support, changed scale to scaling
  79361. */
  79362. scale: Vector3;
  79363. /**
  79364. * Legacy support, changed quaternion to rotationQuaternion
  79365. */
  79366. /**
  79367. * Legacy support, changed quaternion to rotationQuaternion
  79368. */
  79369. quaternion: Nullable<Quaternion>;
  79370. /**
  79371. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  79372. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  79373. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  79374. * @returns true if it intersects
  79375. */
  79376. intersectsMesh(target: Mesh | SolidParticle): boolean;
  79377. /**
  79378. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  79379. * A particle is in the frustum if its bounding box intersects the frustum
  79380. * @param frustumPlanes defines the frustum to test
  79381. * @returns true if the particle is in the frustum planes
  79382. */
  79383. isInFrustum(frustumPlanes: Plane[]): boolean;
  79384. /**
  79385. * get the rotation matrix of the particle
  79386. * @hidden
  79387. */
  79388. getRotationMatrix(m: Matrix): void;
  79389. }
  79390. /**
  79391. * Represents the shape of the model used by one particle of a solid particle system.
  79392. * SPS internal tool, don't use it manually.
  79393. */
  79394. export class ModelShape {
  79395. /**
  79396. * The shape id
  79397. * @hidden
  79398. */
  79399. shapeID: number;
  79400. /**
  79401. * flat array of model positions (internal use)
  79402. * @hidden
  79403. */
  79404. _shape: Vector3[];
  79405. /**
  79406. * flat array of model UVs (internal use)
  79407. * @hidden
  79408. */
  79409. _shapeUV: number[];
  79410. /**
  79411. * length of the shape in the model indices array (internal use)
  79412. * @hidden
  79413. */
  79414. _indicesLength: number;
  79415. /**
  79416. * Custom position function (internal use)
  79417. * @hidden
  79418. */
  79419. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  79420. /**
  79421. * Custom vertex function (internal use)
  79422. * @hidden
  79423. */
  79424. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  79425. /**
  79426. * 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.
  79427. * SPS internal tool, don't use it manually.
  79428. * @hidden
  79429. */
  79430. 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>);
  79431. }
  79432. /**
  79433. * Represents a Depth Sorted Particle in the solid particle system.
  79434. */
  79435. export class DepthSortedParticle {
  79436. /**
  79437. * Index of the particle in the "indices" array
  79438. */
  79439. ind: number;
  79440. /**
  79441. * Length of the particle shape in the "indices" array
  79442. */
  79443. indicesLength: number;
  79444. /**
  79445. * Squared distance from the particle to the camera
  79446. */
  79447. sqDistance: number;
  79448. }
  79449. }
  79450. declare module BABYLON {
  79451. /**
  79452. * Class used to store all common mesh properties
  79453. */
  79454. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  79455. /** No occlusion */
  79456. static OCCLUSION_TYPE_NONE: number;
  79457. /** Occlusion set to optimisitic */
  79458. static OCCLUSION_TYPE_OPTIMISTIC: number;
  79459. /** Occlusion set to strict */
  79460. static OCCLUSION_TYPE_STRICT: number;
  79461. /** Use an accurante occlusion algorithm */
  79462. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  79463. /** Use a conservative occlusion algorithm */
  79464. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  79465. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79466. * Test order :
  79467. * Is the bounding sphere outside the frustum ?
  79468. * If not, are the bounding box vertices outside the frustum ?
  79469. * It not, then the cullable object is in the frustum.
  79470. */
  79471. static readonly CULLINGSTRATEGY_STANDARD: number;
  79472. /** Culling strategy : Bounding Sphere Only.
  79473. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79474. * It's also less accurate than the standard because some not visible objects can still be selected.
  79475. * Test : is the bounding sphere outside the frustum ?
  79476. * If not, then the cullable object is in the frustum.
  79477. */
  79478. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79479. /** Culling strategy : Optimistic Inclusion.
  79480. * This in an inclusion test first, then the standard exclusion test.
  79481. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79482. * 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.
  79483. * Anyway, it's as accurate as the standard strategy.
  79484. * Test :
  79485. * Is the cullable object bounding sphere center in the frustum ?
  79486. * If not, apply the default culling strategy.
  79487. */
  79488. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79489. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79490. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79491. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79492. * 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.
  79493. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79494. * Test :
  79495. * Is the cullable object bounding sphere center in the frustum ?
  79496. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79497. */
  79498. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79499. /**
  79500. * No billboard
  79501. */
  79502. static readonly BILLBOARDMODE_NONE: number;
  79503. /** Billboard on X axis */
  79504. static readonly BILLBOARDMODE_X: number;
  79505. /** Billboard on Y axis */
  79506. static readonly BILLBOARDMODE_Y: number;
  79507. /** Billboard on Z axis */
  79508. static readonly BILLBOARDMODE_Z: number;
  79509. /** Billboard on all axes */
  79510. static readonly BILLBOARDMODE_ALL: number;
  79511. private _facetData;
  79512. /**
  79513. * The culling strategy to use to check whether the mesh must be rendered or not.
  79514. * This value can be changed at any time and will be used on the next render mesh selection.
  79515. * The possible values are :
  79516. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79517. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79518. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79519. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  79520. * Please read each static variable documentation to get details about the culling process.
  79521. * */
  79522. cullingStrategy: number;
  79523. /**
  79524. * Gets the number of facets in the mesh
  79525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79526. */
  79527. readonly facetNb: number;
  79528. /**
  79529. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  79530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79531. */
  79532. partitioningSubdivisions: number;
  79533. /**
  79534. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  79535. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  79536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79537. */
  79538. partitioningBBoxRatio: number;
  79539. /**
  79540. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  79541. * Works only for updatable meshes.
  79542. * Doesn't work with multi-materials
  79543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79544. */
  79545. mustDepthSortFacets: boolean;
  79546. /**
  79547. * The location (Vector3) where the facet depth sort must be computed from.
  79548. * By default, the active camera position.
  79549. * Used only when facet depth sort is enabled
  79550. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79551. */
  79552. facetDepthSortFrom: Vector3;
  79553. /**
  79554. * gets a boolean indicating if facetData is enabled
  79555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79556. */
  79557. readonly isFacetDataEnabled: boolean;
  79558. /** @hidden */
  79559. _updateNonUniformScalingState(value: boolean): boolean;
  79560. /**
  79561. * An event triggered when this mesh collides with another one
  79562. */
  79563. onCollideObservable: Observable<AbstractMesh>;
  79564. private _onCollideObserver;
  79565. /** Set a function to call when this mesh collides with another one */
  79566. onCollide: () => void;
  79567. /**
  79568. * An event triggered when the collision's position changes
  79569. */
  79570. onCollisionPositionChangeObservable: Observable<Vector3>;
  79571. private _onCollisionPositionChangeObserver;
  79572. /** Set a function to call when the collision's position changes */
  79573. onCollisionPositionChange: () => void;
  79574. /**
  79575. * An event triggered when material is changed
  79576. */
  79577. onMaterialChangedObservable: Observable<AbstractMesh>;
  79578. /**
  79579. * Gets or sets the orientation for POV movement & rotation
  79580. */
  79581. definedFacingForward: boolean;
  79582. /** @hidden */
  79583. _occlusionQuery: Nullable<WebGLQuery>;
  79584. private _visibility;
  79585. /**
  79586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79587. */
  79588. /**
  79589. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79590. */
  79591. visibility: number;
  79592. /** Gets or sets the alpha index used to sort transparent meshes
  79593. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  79594. */
  79595. alphaIndex: number;
  79596. /**
  79597. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  79598. */
  79599. isVisible: boolean;
  79600. /**
  79601. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79602. */
  79603. isPickable: boolean;
  79604. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79605. showSubMeshesBoundingBox: boolean;
  79606. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79607. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79608. */
  79609. isBlocker: boolean;
  79610. /**
  79611. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79612. */
  79613. enablePointerMoveEvents: boolean;
  79614. /**
  79615. * Specifies the rendering group id for this mesh (0 by default)
  79616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79617. */
  79618. renderingGroupId: number;
  79619. private _material;
  79620. /** Gets or sets current material */
  79621. material: Nullable<Material>;
  79622. private _receiveShadows;
  79623. /**
  79624. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79625. * @see http://doc.babylonjs.com/babylon101/shadows
  79626. */
  79627. receiveShadows: boolean;
  79628. /** Defines color to use when rendering outline */
  79629. outlineColor: Color3;
  79630. /** Define width to use when rendering outline */
  79631. outlineWidth: number;
  79632. /** Defines color to use when rendering overlay */
  79633. overlayColor: Color3;
  79634. /** Defines alpha to use when rendering overlay */
  79635. overlayAlpha: number;
  79636. private _hasVertexAlpha;
  79637. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79638. hasVertexAlpha: boolean;
  79639. private _useVertexColors;
  79640. /** 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) */
  79641. useVertexColors: boolean;
  79642. private _computeBonesUsingShaders;
  79643. /**
  79644. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79645. */
  79646. computeBonesUsingShaders: boolean;
  79647. private _numBoneInfluencers;
  79648. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79649. numBoneInfluencers: number;
  79650. private _applyFog;
  79651. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79652. applyFog: boolean;
  79653. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79654. useOctreeForRenderingSelection: boolean;
  79655. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79656. useOctreeForPicking: boolean;
  79657. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79658. useOctreeForCollisions: boolean;
  79659. private _layerMask;
  79660. /**
  79661. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79662. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79663. */
  79664. layerMask: number;
  79665. /**
  79666. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79667. */
  79668. alwaysSelectAsActiveMesh: boolean;
  79669. /**
  79670. * Gets or sets the current action manager
  79671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79672. */
  79673. actionManager: Nullable<AbstractActionManager>;
  79674. private _checkCollisions;
  79675. private _collisionMask;
  79676. private _collisionGroup;
  79677. /**
  79678. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79680. */
  79681. ellipsoid: Vector3;
  79682. /**
  79683. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79684. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79685. */
  79686. ellipsoidOffset: Vector3;
  79687. private _collider;
  79688. private _oldPositionForCollisions;
  79689. private _diffPositionForCollisions;
  79690. /**
  79691. * Gets or sets a collision mask used to mask collisions (default is -1).
  79692. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79693. */
  79694. collisionMask: number;
  79695. /**
  79696. * Gets or sets the current collision group mask (-1 by default).
  79697. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79698. */
  79699. collisionGroup: number;
  79700. /**
  79701. * Defines edge width used when edgesRenderer is enabled
  79702. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79703. */
  79704. edgesWidth: number;
  79705. /**
  79706. * Defines edge color used when edgesRenderer is enabled
  79707. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79708. */
  79709. edgesColor: Color4;
  79710. /** @hidden */
  79711. _edgesRenderer: Nullable<IEdgesRenderer>;
  79712. /** @hidden */
  79713. _masterMesh: Nullable<AbstractMesh>;
  79714. /** @hidden */
  79715. _boundingInfo: Nullable<BoundingInfo>;
  79716. /** @hidden */
  79717. _renderId: number;
  79718. /**
  79719. * Gets or sets the list of subMeshes
  79720. * @see http://doc.babylonjs.com/how_to/multi_materials
  79721. */
  79722. subMeshes: SubMesh[];
  79723. /** @hidden */
  79724. _intersectionsInProgress: AbstractMesh[];
  79725. /** @hidden */
  79726. _unIndexed: boolean;
  79727. /** @hidden */
  79728. _lightSources: Light[];
  79729. /** @hidden */
  79730. readonly _positions: Nullable<Vector3[]>;
  79731. /** @hidden */
  79732. _waitingActions: any;
  79733. /** @hidden */
  79734. _waitingFreezeWorldMatrix: Nullable<boolean>;
  79735. private _skeleton;
  79736. /** @hidden */
  79737. _bonesTransformMatrices: Nullable<Float32Array>;
  79738. /**
  79739. * Gets or sets a skeleton to apply skining transformations
  79740. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79741. */
  79742. skeleton: Nullable<Skeleton>;
  79743. /**
  79744. * An event triggered when the mesh is rebuilt.
  79745. */
  79746. onRebuildObservable: Observable<AbstractMesh>;
  79747. /**
  79748. * Creates a new AbstractMesh
  79749. * @param name defines the name of the mesh
  79750. * @param scene defines the hosting scene
  79751. */
  79752. constructor(name: string, scene?: Nullable<Scene>);
  79753. /**
  79754. * Returns the string "AbstractMesh"
  79755. * @returns "AbstractMesh"
  79756. */
  79757. getClassName(): string;
  79758. /**
  79759. * Gets a string representation of the current mesh
  79760. * @param fullDetails defines a boolean indicating if full details must be included
  79761. * @returns a string representation of the current mesh
  79762. */
  79763. toString(fullDetails?: boolean): string;
  79764. /** @hidden */
  79765. _rebuild(): void;
  79766. /** @hidden */
  79767. _resyncLightSources(): void;
  79768. /** @hidden */
  79769. _resyncLighSource(light: Light): void;
  79770. /** @hidden */
  79771. _unBindEffect(): void;
  79772. /** @hidden */
  79773. _removeLightSource(light: Light): void;
  79774. private _markSubMeshesAsDirty;
  79775. /** @hidden */
  79776. _markSubMeshesAsLightDirty(): void;
  79777. /** @hidden */
  79778. _markSubMeshesAsAttributesDirty(): void;
  79779. /** @hidden */
  79780. _markSubMeshesAsMiscDirty(): void;
  79781. /**
  79782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79783. */
  79784. scaling: Vector3;
  79785. /**
  79786. * Returns true if the mesh is blocked. Implemented by child classes
  79787. */
  79788. readonly isBlocked: boolean;
  79789. /**
  79790. * Returns the mesh itself by default. Implemented by child classes
  79791. * @param camera defines the camera to use to pick the right LOD level
  79792. * @returns the currentAbstractMesh
  79793. */
  79794. getLOD(camera: Camera): Nullable<AbstractMesh>;
  79795. /**
  79796. * Returns 0 by default. Implemented by child classes
  79797. * @returns an integer
  79798. */
  79799. getTotalVertices(): number;
  79800. /**
  79801. * Returns a positive integer : the total number of indices in this mesh geometry.
  79802. * @returns the numner of indices or zero if the mesh has no geometry.
  79803. */
  79804. getTotalIndices(): number;
  79805. /**
  79806. * Returns null by default. Implemented by child classes
  79807. * @returns null
  79808. */
  79809. getIndices(): Nullable<IndicesArray>;
  79810. /**
  79811. * Returns the array of the requested vertex data kind. Implemented by child classes
  79812. * @param kind defines the vertex data kind to use
  79813. * @returns null
  79814. */
  79815. getVerticesData(kind: string): Nullable<FloatArray>;
  79816. /**
  79817. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79818. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79819. * Note that a new underlying VertexBuffer object is created each call.
  79820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79821. * @param kind defines vertex data kind:
  79822. * * VertexBuffer.PositionKind
  79823. * * VertexBuffer.UVKind
  79824. * * VertexBuffer.UV2Kind
  79825. * * VertexBuffer.UV3Kind
  79826. * * VertexBuffer.UV4Kind
  79827. * * VertexBuffer.UV5Kind
  79828. * * VertexBuffer.UV6Kind
  79829. * * VertexBuffer.ColorKind
  79830. * * VertexBuffer.MatricesIndicesKind
  79831. * * VertexBuffer.MatricesIndicesExtraKind
  79832. * * VertexBuffer.MatricesWeightsKind
  79833. * * VertexBuffer.MatricesWeightsExtraKind
  79834. * @param data defines the data source
  79835. * @param updatable defines if the data must be flagged as updatable (or static)
  79836. * @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
  79837. * @returns the current mesh
  79838. */
  79839. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  79840. /**
  79841. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79842. * If the mesh has no geometry, it is simply returned as it is.
  79843. * @param kind defines vertex data kind:
  79844. * * VertexBuffer.PositionKind
  79845. * * VertexBuffer.UVKind
  79846. * * VertexBuffer.UV2Kind
  79847. * * VertexBuffer.UV3Kind
  79848. * * VertexBuffer.UV4Kind
  79849. * * VertexBuffer.UV5Kind
  79850. * * VertexBuffer.UV6Kind
  79851. * * VertexBuffer.ColorKind
  79852. * * VertexBuffer.MatricesIndicesKind
  79853. * * VertexBuffer.MatricesIndicesExtraKind
  79854. * * VertexBuffer.MatricesWeightsKind
  79855. * * VertexBuffer.MatricesWeightsExtraKind
  79856. * @param data defines the data source
  79857. * @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
  79858. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79859. * @returns the current mesh
  79860. */
  79861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  79862. /**
  79863. * Sets the mesh indices,
  79864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79865. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79866. * @param totalVertices Defines the total number of vertices
  79867. * @returns the current mesh
  79868. */
  79869. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  79870. /**
  79871. * Gets a boolean indicating if specific vertex data is present
  79872. * @param kind defines the vertex data kind to use
  79873. * @returns true is data kind is present
  79874. */
  79875. isVerticesDataPresent(kind: string): boolean;
  79876. /**
  79877. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79878. * @returns a BoundingInfo
  79879. */
  79880. getBoundingInfo(): BoundingInfo;
  79881. /**
  79882. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79883. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79884. * @returns the current mesh
  79885. */
  79886. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  79887. /**
  79888. * Overwrite the current bounding info
  79889. * @param boundingInfo defines the new bounding info
  79890. * @returns the current mesh
  79891. */
  79892. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  79893. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79894. readonly useBones: boolean;
  79895. /** @hidden */
  79896. _preActivate(): void;
  79897. /** @hidden */
  79898. _preActivateForIntermediateRendering(renderId: number): void;
  79899. /** @hidden */
  79900. _activate(renderId: number): void;
  79901. /**
  79902. * Gets the current world matrix
  79903. * @returns a Matrix
  79904. */
  79905. getWorldMatrix(): Matrix;
  79906. /** @hidden */
  79907. _getWorldMatrixDeterminant(): number;
  79908. /**
  79909. * Perform relative position change from the point of view of behind the front of the mesh.
  79910. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79911. * Supports definition of mesh facing forward or backward
  79912. * @param amountRight defines the distance on the right axis
  79913. * @param amountUp defines the distance on the up axis
  79914. * @param amountForward defines the distance on the forward axis
  79915. * @returns the current mesh
  79916. */
  79917. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  79918. /**
  79919. * Calculate relative position change from the point of view of behind the front of the mesh.
  79920. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79921. * Supports definition of mesh facing forward or backward
  79922. * @param amountRight defines the distance on the right axis
  79923. * @param amountUp defines the distance on the up axis
  79924. * @param amountForward defines the distance on the forward axis
  79925. * @returns the new displacement vector
  79926. */
  79927. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  79928. /**
  79929. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79930. * Supports definition of mesh facing forward or backward
  79931. * @param flipBack defines the flip
  79932. * @param twirlClockwise defines the twirl
  79933. * @param tiltRight defines the tilt
  79934. * @returns the current mesh
  79935. */
  79936. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  79937. /**
  79938. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79939. * Supports definition of mesh facing forward or backward.
  79940. * @param flipBack defines the flip
  79941. * @param twirlClockwise defines the twirl
  79942. * @param tiltRight defines the tilt
  79943. * @returns the new rotation vector
  79944. */
  79945. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  79946. /**
  79947. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79948. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79949. * @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
  79950. * @returns the new bounding vectors
  79951. */
  79952. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  79953. min: Vector3;
  79954. max: Vector3;
  79955. };
  79956. /**
  79957. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79958. * This means the mesh underlying bounding box and sphere are recomputed.
  79959. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79960. * @returns the current mesh
  79961. */
  79962. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  79963. /** @hidden */
  79964. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  79965. /** @hidden */
  79966. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  79967. /** @hidden */
  79968. _updateBoundingInfo(): AbstractMesh;
  79969. /** @hidden */
  79970. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  79971. /** @hidden */
  79972. protected _afterComputeWorldMatrix(): void;
  79973. /**
  79974. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79975. * A mesh is in the frustum if its bounding box intersects the frustum
  79976. * @param frustumPlanes defines the frustum to test
  79977. * @returns true if the mesh is in the frustum planes
  79978. */
  79979. isInFrustum(frustumPlanes: Plane[]): boolean;
  79980. /**
  79981. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79982. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79983. * @param frustumPlanes defines the frustum to test
  79984. * @returns true if the mesh is completely in the frustum planes
  79985. */
  79986. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79987. /**
  79988. * True if the mesh intersects another mesh or a SolidParticle object
  79989. * @param mesh defines a target mesh or SolidParticle to test
  79990. * @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)
  79991. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79992. * @returns true if there is an intersection
  79993. */
  79994. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  79995. /**
  79996. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79997. * @param point defines the point to test
  79998. * @returns true if there is an intersection
  79999. */
  80000. intersectsPoint(point: Vector3): boolean;
  80001. /**
  80002. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  80003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80004. */
  80005. checkCollisions: boolean;
  80006. /**
  80007. * Gets Collider object used to compute collisions (not physics)
  80008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80009. */
  80010. readonly collider: Collider;
  80011. /**
  80012. * Move the mesh using collision engine
  80013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80014. * @param displacement defines the requested displacement vector
  80015. * @returns the current mesh
  80016. */
  80017. moveWithCollisions(displacement: Vector3): AbstractMesh;
  80018. private _onCollisionPositionChange;
  80019. /** @hidden */
  80020. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  80021. /** @hidden */
  80022. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  80023. /** @hidden */
  80024. _checkCollision(collider: Collider): AbstractMesh;
  80025. /** @hidden */
  80026. _generatePointsArray(): boolean;
  80027. /**
  80028. * Checks if the passed Ray intersects with the mesh
  80029. * @param ray defines the ray to use
  80030. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80031. * @returns the picking info
  80032. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80033. */
  80034. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  80035. /**
  80036. * Clones the current mesh
  80037. * @param name defines the mesh name
  80038. * @param newParent defines the new mesh parent
  80039. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  80040. * @returns the new mesh
  80041. */
  80042. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  80043. /**
  80044. * Disposes all the submeshes of the current meshnp
  80045. * @returns the current mesh
  80046. */
  80047. releaseSubMeshes(): AbstractMesh;
  80048. /**
  80049. * Releases resources associated with this abstract mesh.
  80050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80052. */
  80053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80054. /**
  80055. * Adds the passed mesh as a child to the current mesh
  80056. * @param mesh defines the child mesh
  80057. * @returns the current mesh
  80058. */
  80059. addChild(mesh: AbstractMesh): AbstractMesh;
  80060. /**
  80061. * Removes the passed mesh from the current mesh children list
  80062. * @param mesh defines the child mesh
  80063. * @returns the current mesh
  80064. */
  80065. removeChild(mesh: AbstractMesh): AbstractMesh;
  80066. /** @hidden */
  80067. private _initFacetData;
  80068. /**
  80069. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  80070. * This method can be called within the render loop.
  80071. * 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
  80072. * @returns the current mesh
  80073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80074. */
  80075. updateFacetData(): AbstractMesh;
  80076. /**
  80077. * Returns the facetLocalNormals array.
  80078. * The normals are expressed in the mesh local spac
  80079. * @returns an array of Vector3
  80080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80081. */
  80082. getFacetLocalNormals(): Vector3[];
  80083. /**
  80084. * Returns the facetLocalPositions array.
  80085. * The facet positions are expressed in the mesh local space
  80086. * @returns an array of Vector3
  80087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80088. */
  80089. getFacetLocalPositions(): Vector3[];
  80090. /**
  80091. * Returns the facetLocalPartioning array
  80092. * @returns an array of array of numbers
  80093. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80094. */
  80095. getFacetLocalPartitioning(): number[][];
  80096. /**
  80097. * Returns the i-th facet position in the world system.
  80098. * This method allocates a new Vector3 per call
  80099. * @param i defines the facet index
  80100. * @returns a new Vector3
  80101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80102. */
  80103. getFacetPosition(i: number): Vector3;
  80104. /**
  80105. * Sets the reference Vector3 with the i-th facet position in the world system
  80106. * @param i defines the facet index
  80107. * @param ref defines the target vector
  80108. * @returns the current mesh
  80109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80110. */
  80111. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  80112. /**
  80113. * Returns the i-th facet normal in the world system.
  80114. * This method allocates a new Vector3 per call
  80115. * @param i defines the facet index
  80116. * @returns a new Vector3
  80117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80118. */
  80119. getFacetNormal(i: number): Vector3;
  80120. /**
  80121. * Sets the reference Vector3 with the i-th facet normal in the world system
  80122. * @param i defines the facet index
  80123. * @param ref defines the target vector
  80124. * @returns the current mesh
  80125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80126. */
  80127. getFacetNormalToRef(i: number, ref: Vector3): this;
  80128. /**
  80129. * 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)
  80130. * @param x defines x coordinate
  80131. * @param y defines y coordinate
  80132. * @param z defines z coordinate
  80133. * @returns the array of facet indexes
  80134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80135. */
  80136. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  80137. /**
  80138. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80139. * @param projected sets as the (x,y,z) world projection on the facet
  80140. * @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
  80141. * @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
  80142. * @param x defines x coordinate
  80143. * @param y defines y coordinate
  80144. * @param z defines z coordinate
  80145. * @returns the face index if found (or null instead)
  80146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80147. */
  80148. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80149. /**
  80150. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80151. * @param projected sets as the (x,y,z) local projection on the facet
  80152. * @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
  80153. * @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
  80154. * @param x defines x coordinate
  80155. * @param y defines y coordinate
  80156. * @param z defines z coordinate
  80157. * @returns the face index if found (or null instead)
  80158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80159. */
  80160. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80161. /**
  80162. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80163. * @returns the parameters
  80164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80165. */
  80166. getFacetDataParameters(): any;
  80167. /**
  80168. * Disables the feature FacetData and frees the related memory
  80169. * @returns the current mesh
  80170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80171. */
  80172. disableFacetData(): AbstractMesh;
  80173. /**
  80174. * Updates the AbstractMesh indices array
  80175. * @param indices defines the data source
  80176. * @returns the current mesh
  80177. */
  80178. updateIndices(indices: IndicesArray): AbstractMesh;
  80179. /**
  80180. * Creates new normals data for the mesh
  80181. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80182. * @returns the current mesh
  80183. */
  80184. createNormals(updatable: boolean): AbstractMesh;
  80185. /**
  80186. * Align the mesh with a normal
  80187. * @param normal defines the normal to use
  80188. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80189. * @returns the current mesh
  80190. */
  80191. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  80192. /** @hidden */
  80193. _checkOcclusionQuery(): boolean;
  80194. }
  80195. }
  80196. declare module BABYLON {
  80197. /**
  80198. * Defines how a node can be built from a string name.
  80199. */
  80200. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80201. /**
  80202. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80203. */
  80204. export class Node implements IBehaviorAware<Node> {
  80205. /** @hidden */
  80206. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80207. private static _NodeConstructors;
  80208. /**
  80209. * Add a new node constructor
  80210. * @param type defines the type name of the node to construct
  80211. * @param constructorFunc defines the constructor function
  80212. */
  80213. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80214. /**
  80215. * Returns a node constructor based on type name
  80216. * @param type defines the type name
  80217. * @param name defines the new node name
  80218. * @param scene defines the hosting scene
  80219. * @param options defines optional options to transmit to constructors
  80220. * @returns the new constructor or null
  80221. */
  80222. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80223. /**
  80224. * Gets or sets the name of the node
  80225. */
  80226. name: string;
  80227. /**
  80228. * Gets or sets the id of the node
  80229. */
  80230. id: string;
  80231. /**
  80232. * Gets or sets the unique id of the node
  80233. */
  80234. uniqueId: number;
  80235. /**
  80236. * Gets or sets a string used to store user defined state for the node
  80237. */
  80238. state: string;
  80239. /**
  80240. * Gets or sets an object used to store user defined information for the node
  80241. */
  80242. metadata: any;
  80243. /**
  80244. * For internal use only. Please do not use.
  80245. */
  80246. reservedDataStore: any;
  80247. /**
  80248. * Gets or sets a boolean used to define if the node must be serialized
  80249. */
  80250. doNotSerialize: boolean;
  80251. /** @hidden */
  80252. _isDisposed: boolean;
  80253. /**
  80254. * Gets a list of Animations associated with the node
  80255. */
  80256. animations: Animation[];
  80257. protected _ranges: {
  80258. [name: string]: Nullable<AnimationRange>;
  80259. };
  80260. /**
  80261. * Callback raised when the node is ready to be used
  80262. */
  80263. onReady: (node: Node) => void;
  80264. private _isEnabled;
  80265. private _isParentEnabled;
  80266. private _isReady;
  80267. /** @hidden */
  80268. _currentRenderId: number;
  80269. private _parentRenderId;
  80270. protected _childRenderId: number;
  80271. /** @hidden */
  80272. _waitingParentId: Nullable<string>;
  80273. /** @hidden */
  80274. _scene: Scene;
  80275. /** @hidden */
  80276. _cache: any;
  80277. private _parentNode;
  80278. private _children;
  80279. /** @hidden */
  80280. _worldMatrix: Matrix;
  80281. /** @hidden */
  80282. _worldMatrixDeterminant: number;
  80283. /** @hidden */
  80284. private _sceneRootNodesIndex;
  80285. /**
  80286. * Gets a boolean indicating if the node has been disposed
  80287. * @returns true if the node was disposed
  80288. */
  80289. isDisposed(): boolean;
  80290. /**
  80291. * Gets or sets the parent of the node
  80292. */
  80293. parent: Nullable<Node>;
  80294. private addToSceneRootNodes;
  80295. private removeFromSceneRootNodes;
  80296. private _animationPropertiesOverride;
  80297. /**
  80298. * Gets or sets the animation properties override
  80299. */
  80300. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80301. /**
  80302. * Gets a string idenfifying the name of the class
  80303. * @returns "Node" string
  80304. */
  80305. getClassName(): string;
  80306. /** @hidden */
  80307. readonly _isNode: boolean;
  80308. /**
  80309. * An event triggered when the mesh is disposed
  80310. */
  80311. onDisposeObservable: Observable<Node>;
  80312. private _onDisposeObserver;
  80313. /**
  80314. * Sets a callback that will be raised when the node will be disposed
  80315. */
  80316. onDispose: () => void;
  80317. /**
  80318. * Creates a new Node
  80319. * @param name the name and id to be given to this node
  80320. * @param scene the scene this node will be added to
  80321. * @param addToRootNodes the node will be added to scene.rootNodes
  80322. */
  80323. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80324. /**
  80325. * Gets the scene of the node
  80326. * @returns a scene
  80327. */
  80328. getScene(): Scene;
  80329. /**
  80330. * Gets the engine of the node
  80331. * @returns a Engine
  80332. */
  80333. getEngine(): Engine;
  80334. private _behaviors;
  80335. /**
  80336. * Attach a behavior to the node
  80337. * @see http://doc.babylonjs.com/features/behaviour
  80338. * @param behavior defines the behavior to attach
  80339. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  80340. * @returns the current Node
  80341. */
  80342. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  80343. /**
  80344. * Remove an attached behavior
  80345. * @see http://doc.babylonjs.com/features/behaviour
  80346. * @param behavior defines the behavior to attach
  80347. * @returns the current Node
  80348. */
  80349. removeBehavior(behavior: Behavior<Node>): Node;
  80350. /**
  80351. * Gets the list of attached behaviors
  80352. * @see http://doc.babylonjs.com/features/behaviour
  80353. */
  80354. readonly behaviors: Behavior<Node>[];
  80355. /**
  80356. * Gets an attached behavior by name
  80357. * @param name defines the name of the behavior to look for
  80358. * @see http://doc.babylonjs.com/features/behaviour
  80359. * @returns null if behavior was not found else the requested behavior
  80360. */
  80361. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  80362. /**
  80363. * Returns the latest update of the World matrix
  80364. * @returns a Matrix
  80365. */
  80366. getWorldMatrix(): Matrix;
  80367. /** @hidden */
  80368. _getWorldMatrixDeterminant(): number;
  80369. /**
  80370. * Returns directly the latest state of the mesh World matrix.
  80371. * A Matrix is returned.
  80372. */
  80373. readonly worldMatrixFromCache: Matrix;
  80374. /** @hidden */
  80375. _initCache(): void;
  80376. /** @hidden */
  80377. updateCache(force?: boolean): void;
  80378. /** @hidden */
  80379. _updateCache(ignoreParentClass?: boolean): void;
  80380. /** @hidden */
  80381. _isSynchronized(): boolean;
  80382. /** @hidden */
  80383. _markSyncedWithParent(): void;
  80384. /** @hidden */
  80385. isSynchronizedWithParent(): boolean;
  80386. /** @hidden */
  80387. isSynchronized(): boolean;
  80388. /**
  80389. * Is this node ready to be used/rendered
  80390. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80391. * @return true if the node is ready
  80392. */
  80393. isReady(completeCheck?: boolean): boolean;
  80394. /**
  80395. * Is this node enabled?
  80396. * 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
  80397. * @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
  80398. * @return whether this node (and its parent) is enabled
  80399. */
  80400. isEnabled(checkAncestors?: boolean): boolean;
  80401. /** @hidden */
  80402. protected _syncParentEnabledState(): void;
  80403. /**
  80404. * Set the enabled state of this node
  80405. * @param value defines the new enabled state
  80406. */
  80407. setEnabled(value: boolean): void;
  80408. /**
  80409. * Is this node a descendant of the given node?
  80410. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  80411. * @param ancestor defines the parent node to inspect
  80412. * @returns a boolean indicating if this node is a descendant of the given node
  80413. */
  80414. isDescendantOf(ancestor: Node): boolean;
  80415. /** @hidden */
  80416. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  80417. /**
  80418. * Will return all nodes that have this node as ascendant
  80419. * @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
  80420. * @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
  80421. * @return all children nodes of all types
  80422. */
  80423. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  80424. /**
  80425. * Get all child-meshes of this node
  80426. * @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
  80427. * @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
  80428. * @returns an array of AbstractMesh
  80429. */
  80430. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  80431. /**
  80432. * Get all direct children of this node
  80433. * @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
  80434. * @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)
  80435. * @returns an array of Node
  80436. */
  80437. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  80438. /** @hidden */
  80439. _setReady(state: boolean): void;
  80440. /**
  80441. * Get an animation by name
  80442. * @param name defines the name of the animation to look for
  80443. * @returns null if not found else the requested animation
  80444. */
  80445. getAnimationByName(name: string): Nullable<Animation>;
  80446. /**
  80447. * Creates an animation range for this node
  80448. * @param name defines the name of the range
  80449. * @param from defines the starting key
  80450. * @param to defines the end key
  80451. */
  80452. createAnimationRange(name: string, from: number, to: number): void;
  80453. /**
  80454. * Delete a specific animation range
  80455. * @param name defines the name of the range to delete
  80456. * @param deleteFrames defines if animation frames from the range must be deleted as well
  80457. */
  80458. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80459. /**
  80460. * Get an animation range by name
  80461. * @param name defines the name of the animation range to look for
  80462. * @returns null if not found else the requested animation range
  80463. */
  80464. getAnimationRange(name: string): Nullable<AnimationRange>;
  80465. /**
  80466. * Will start the animation sequence
  80467. * @param name defines the range frames for animation sequence
  80468. * @param loop defines if the animation should loop (false by default)
  80469. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  80470. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  80471. * @returns the object created for this animation. If range does not exist, it will return null
  80472. */
  80473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80474. /**
  80475. * Serialize animation ranges into a JSON compatible object
  80476. * @returns serialization object
  80477. */
  80478. serializeAnimationRanges(): any;
  80479. /**
  80480. * Computes the world matrix of the node
  80481. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80482. * @returns the world matrix
  80483. */
  80484. computeWorldMatrix(force?: boolean): Matrix;
  80485. /**
  80486. * Releases resources associated with this node.
  80487. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80488. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80489. */
  80490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80491. /**
  80492. * Parse animation range data from a serialization object and store them into a given node
  80493. * @param node defines where to store the animation ranges
  80494. * @param parsedNode defines the serialization object to read data from
  80495. * @param scene defines the hosting scene
  80496. */
  80497. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  80498. }
  80499. }
  80500. declare module BABYLON {
  80501. /**
  80502. * Represents the range of an animation
  80503. */
  80504. export class AnimationRange {
  80505. /**The name of the animation range**/
  80506. name: string;
  80507. /**The starting frame of the animation */
  80508. from: number;
  80509. /**The ending frame of the animation*/
  80510. to: number;
  80511. /**
  80512. * Initializes the range of an animation
  80513. * @param name The name of the animation range
  80514. * @param from The starting frame of the animation
  80515. * @param to The ending frame of the animation
  80516. */
  80517. constructor(
  80518. /**The name of the animation range**/
  80519. name: string,
  80520. /**The starting frame of the animation */
  80521. from: number,
  80522. /**The ending frame of the animation*/
  80523. to: number);
  80524. /**
  80525. * Makes a copy of the animation range
  80526. * @returns A copy of the animation range
  80527. */
  80528. clone(): AnimationRange;
  80529. }
  80530. /**
  80531. * Composed of a frame, and an action function
  80532. */
  80533. export class AnimationEvent {
  80534. /** The frame for which the event is triggered **/
  80535. frame: number;
  80536. /** The event to perform when triggered **/
  80537. action: (currentFrame: number) => void;
  80538. /** Specifies if the event should be triggered only once**/
  80539. onlyOnce?: boolean | undefined;
  80540. /**
  80541. * Specifies if the animation event is done
  80542. */
  80543. isDone: boolean;
  80544. /**
  80545. * Initializes the animation event
  80546. * @param frame The frame for which the event is triggered
  80547. * @param action The event to perform when triggered
  80548. * @param onlyOnce Specifies if the event should be triggered only once
  80549. */
  80550. constructor(
  80551. /** The frame for which the event is triggered **/
  80552. frame: number,
  80553. /** The event to perform when triggered **/
  80554. action: (currentFrame: number) => void,
  80555. /** Specifies if the event should be triggered only once**/
  80556. onlyOnce?: boolean | undefined);
  80557. /** @hidden */
  80558. _clone(): AnimationEvent;
  80559. }
  80560. /**
  80561. * A cursor which tracks a point on a path
  80562. */
  80563. export class PathCursor {
  80564. private path;
  80565. /**
  80566. * Stores path cursor callbacks for when an onchange event is triggered
  80567. */
  80568. private _onchange;
  80569. /**
  80570. * The value of the path cursor
  80571. */
  80572. value: number;
  80573. /**
  80574. * The animation array of the path cursor
  80575. */
  80576. animations: Animation[];
  80577. /**
  80578. * Initializes the path cursor
  80579. * @param path The path to track
  80580. */
  80581. constructor(path: Path2);
  80582. /**
  80583. * Gets the cursor point on the path
  80584. * @returns A point on the path cursor at the cursor location
  80585. */
  80586. getPoint(): Vector3;
  80587. /**
  80588. * Moves the cursor ahead by the step amount
  80589. * @param step The amount to move the cursor forward
  80590. * @returns This path cursor
  80591. */
  80592. moveAhead(step?: number): PathCursor;
  80593. /**
  80594. * Moves the cursor behind by the step amount
  80595. * @param step The amount to move the cursor back
  80596. * @returns This path cursor
  80597. */
  80598. moveBack(step?: number): PathCursor;
  80599. /**
  80600. * Moves the cursor by the step amount
  80601. * If the step amount is greater than one, an exception is thrown
  80602. * @param step The amount to move the cursor
  80603. * @returns This path cursor
  80604. */
  80605. move(step: number): PathCursor;
  80606. /**
  80607. * Ensures that the value is limited between zero and one
  80608. * @returns This path cursor
  80609. */
  80610. private ensureLimits;
  80611. /**
  80612. * Runs onchange callbacks on change (used by the animation engine)
  80613. * @returns This path cursor
  80614. */
  80615. private raiseOnChange;
  80616. /**
  80617. * Executes a function on change
  80618. * @param f A path cursor onchange callback
  80619. * @returns This path cursor
  80620. */
  80621. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80622. }
  80623. /**
  80624. * Defines an interface which represents an animation key frame
  80625. */
  80626. export interface IAnimationKey {
  80627. /**
  80628. * Frame of the key frame
  80629. */
  80630. frame: number;
  80631. /**
  80632. * Value at the specifies key frame
  80633. */
  80634. value: any;
  80635. /**
  80636. * The input tangent for the cubic hermite spline
  80637. */
  80638. inTangent?: any;
  80639. /**
  80640. * The output tangent for the cubic hermite spline
  80641. */
  80642. outTangent?: any;
  80643. /**
  80644. * The animation interpolation type
  80645. */
  80646. interpolation?: AnimationKeyInterpolation;
  80647. }
  80648. /**
  80649. * Enum for the animation key frame interpolation type
  80650. */
  80651. export enum AnimationKeyInterpolation {
  80652. /**
  80653. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80654. */
  80655. STEP = 1
  80656. }
  80657. /**
  80658. * Class used to store any kind of animation
  80659. */
  80660. export class Animation {
  80661. /**Name of the animation */
  80662. name: string;
  80663. /**Property to animate */
  80664. targetProperty: string;
  80665. /**The frames per second of the animation */
  80666. framePerSecond: number;
  80667. /**The data type of the animation */
  80668. dataType: number;
  80669. /**The loop mode of the animation */
  80670. loopMode?: number | undefined;
  80671. /**Specifies if blending should be enabled */
  80672. enableBlending?: boolean | undefined;
  80673. /**
  80674. * Use matrix interpolation instead of using direct key value when animating matrices
  80675. */
  80676. static AllowMatricesInterpolation: boolean;
  80677. /**
  80678. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  80679. */
  80680. static AllowMatrixDecomposeForInterpolation: boolean;
  80681. /**
  80682. * Stores the key frames of the animation
  80683. */
  80684. private _keys;
  80685. /**
  80686. * Stores the easing function of the animation
  80687. */
  80688. private _easingFunction;
  80689. /**
  80690. * @hidden Internal use only
  80691. */
  80692. _runtimeAnimations: RuntimeAnimation[];
  80693. /**
  80694. * The set of event that will be linked to this animation
  80695. */
  80696. private _events;
  80697. /**
  80698. * Stores an array of target property paths
  80699. */
  80700. targetPropertyPath: string[];
  80701. /**
  80702. * Stores the blending speed of the animation
  80703. */
  80704. blendingSpeed: number;
  80705. /**
  80706. * Stores the animation ranges for the animation
  80707. */
  80708. private _ranges;
  80709. /**
  80710. * @hidden Internal use
  80711. */
  80712. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  80713. /**
  80714. * Sets up an animation
  80715. * @param property The property to animate
  80716. * @param animationType The animation type to apply
  80717. * @param framePerSecond The frames per second of the animation
  80718. * @param easingFunction The easing function used in the animation
  80719. * @returns The created animation
  80720. */
  80721. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  80722. /**
  80723. * Create and start an animation on a node
  80724. * @param name defines the name of the global animation that will be run on all nodes
  80725. * @param node defines the root node where the animation will take place
  80726. * @param targetProperty defines property to animate
  80727. * @param framePerSecond defines the number of frame per second yo use
  80728. * @param totalFrame defines the number of frames in total
  80729. * @param from defines the initial value
  80730. * @param to defines the final value
  80731. * @param loopMode defines which loop mode you want to use (off by default)
  80732. * @param easingFunction defines the easing function to use (linear by default)
  80733. * @param onAnimationEnd defines the callback to call when animation end
  80734. * @returns the animatable created for this animation
  80735. */
  80736. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80737. /**
  80738. * Create and start an animation on a node and its descendants
  80739. * @param name defines the name of the global animation that will be run on all nodes
  80740. * @param node defines the root node where the animation will take place
  80741. * @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
  80742. * @param targetProperty defines property to animate
  80743. * @param framePerSecond defines the number of frame per second to use
  80744. * @param totalFrame defines the number of frames in total
  80745. * @param from defines the initial value
  80746. * @param to defines the final value
  80747. * @param loopMode defines which loop mode you want to use (off by default)
  80748. * @param easingFunction defines the easing function to use (linear by default)
  80749. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80750. * @returns the list of animatables created for all nodes
  80751. * @example https://www.babylonjs-playground.com/#MH0VLI
  80752. */
  80753. 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[]>;
  80754. /**
  80755. * Creates a new animation, merges it with the existing animations and starts it
  80756. * @param name Name of the animation
  80757. * @param node Node which contains the scene that begins the animations
  80758. * @param targetProperty Specifies which property to animate
  80759. * @param framePerSecond The frames per second of the animation
  80760. * @param totalFrame The total number of frames
  80761. * @param from The frame at the beginning of the animation
  80762. * @param to The frame at the end of the animation
  80763. * @param loopMode Specifies the loop mode of the animation
  80764. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  80765. * @param onAnimationEnd Callback to run once the animation is complete
  80766. * @returns Nullable animation
  80767. */
  80768. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80769. /**
  80770. * Transition property of an host to the target Value
  80771. * @param property The property to transition
  80772. * @param targetValue The target Value of the property
  80773. * @param host The object where the property to animate belongs
  80774. * @param scene Scene used to run the animation
  80775. * @param frameRate Framerate (in frame/s) to use
  80776. * @param transition The transition type we want to use
  80777. * @param duration The duration of the animation, in milliseconds
  80778. * @param onAnimationEnd Callback trigger at the end of the animation
  80779. * @returns Nullable animation
  80780. */
  80781. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  80782. /**
  80783. * Return the array of runtime animations currently using this animation
  80784. */
  80785. readonly runtimeAnimations: RuntimeAnimation[];
  80786. /**
  80787. * Specifies if any of the runtime animations are currently running
  80788. */
  80789. readonly hasRunningRuntimeAnimations: boolean;
  80790. /**
  80791. * Initializes the animation
  80792. * @param name Name of the animation
  80793. * @param targetProperty Property to animate
  80794. * @param framePerSecond The frames per second of the animation
  80795. * @param dataType The data type of the animation
  80796. * @param loopMode The loop mode of the animation
  80797. * @param enableBlending Specifies if blending should be enabled
  80798. */
  80799. constructor(
  80800. /**Name of the animation */
  80801. name: string,
  80802. /**Property to animate */
  80803. targetProperty: string,
  80804. /**The frames per second of the animation */
  80805. framePerSecond: number,
  80806. /**The data type of the animation */
  80807. dataType: number,
  80808. /**The loop mode of the animation */
  80809. loopMode?: number | undefined,
  80810. /**Specifies if blending should be enabled */
  80811. enableBlending?: boolean | undefined);
  80812. /**
  80813. * Converts the animation to a string
  80814. * @param fullDetails support for multiple levels of logging within scene loading
  80815. * @returns String form of the animation
  80816. */
  80817. toString(fullDetails?: boolean): string;
  80818. /**
  80819. * Add an event to this animation
  80820. * @param event Event to add
  80821. */
  80822. addEvent(event: AnimationEvent): void;
  80823. /**
  80824. * Remove all events found at the given frame
  80825. * @param frame The frame to remove events from
  80826. */
  80827. removeEvents(frame: number): void;
  80828. /**
  80829. * Retrieves all the events from the animation
  80830. * @returns Events from the animation
  80831. */
  80832. getEvents(): AnimationEvent[];
  80833. /**
  80834. * Creates an animation range
  80835. * @param name Name of the animation range
  80836. * @param from Starting frame of the animation range
  80837. * @param to Ending frame of the animation
  80838. */
  80839. createRange(name: string, from: number, to: number): void;
  80840. /**
  80841. * Deletes an animation range by name
  80842. * @param name Name of the animation range to delete
  80843. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  80844. */
  80845. deleteRange(name: string, deleteFrames?: boolean): void;
  80846. /**
  80847. * Gets the animation range by name, or null if not defined
  80848. * @param name Name of the animation range
  80849. * @returns Nullable animation range
  80850. */
  80851. getRange(name: string): Nullable<AnimationRange>;
  80852. /**
  80853. * Gets the key frames from the animation
  80854. * @returns The key frames of the animation
  80855. */
  80856. getKeys(): Array<IAnimationKey>;
  80857. /**
  80858. * Gets the highest frame rate of the animation
  80859. * @returns Highest frame rate of the animation
  80860. */
  80861. getHighestFrame(): number;
  80862. /**
  80863. * Gets the easing function of the animation
  80864. * @returns Easing function of the animation
  80865. */
  80866. getEasingFunction(): IEasingFunction;
  80867. /**
  80868. * Sets the easing function of the animation
  80869. * @param easingFunction A custom mathematical formula for animation
  80870. */
  80871. setEasingFunction(easingFunction: EasingFunction): void;
  80872. /**
  80873. * Interpolates a scalar linearly
  80874. * @param startValue Start value of the animation curve
  80875. * @param endValue End value of the animation curve
  80876. * @param gradient Scalar amount to interpolate
  80877. * @returns Interpolated scalar value
  80878. */
  80879. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  80880. /**
  80881. * Interpolates a scalar cubically
  80882. * @param startValue Start value of the animation curve
  80883. * @param outTangent End tangent of the animation
  80884. * @param endValue End value of the animation curve
  80885. * @param inTangent Start tangent of the animation curve
  80886. * @param gradient Scalar amount to interpolate
  80887. * @returns Interpolated scalar value
  80888. */
  80889. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  80890. /**
  80891. * Interpolates a quaternion using a spherical linear interpolation
  80892. * @param startValue Start value of the animation curve
  80893. * @param endValue End value of the animation curve
  80894. * @param gradient Scalar amount to interpolate
  80895. * @returns Interpolated quaternion value
  80896. */
  80897. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  80898. /**
  80899. * Interpolates a quaternion cubically
  80900. * @param startValue Start value of the animation curve
  80901. * @param outTangent End tangent of the animation curve
  80902. * @param endValue End value of the animation curve
  80903. * @param inTangent Start tangent of the animation curve
  80904. * @param gradient Scalar amount to interpolate
  80905. * @returns Interpolated quaternion value
  80906. */
  80907. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  80908. /**
  80909. * Interpolates a Vector3 linearl
  80910. * @param startValue Start value of the animation curve
  80911. * @param endValue End value of the animation curve
  80912. * @param gradient Scalar amount to interpolate
  80913. * @returns Interpolated scalar value
  80914. */
  80915. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  80916. /**
  80917. * Interpolates a Vector3 cubically
  80918. * @param startValue Start value of the animation curve
  80919. * @param outTangent End tangent of the animation
  80920. * @param endValue End value of the animation curve
  80921. * @param inTangent Start tangent of the animation curve
  80922. * @param gradient Scalar amount to interpolate
  80923. * @returns InterpolatedVector3 value
  80924. */
  80925. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  80926. /**
  80927. * Interpolates a Vector2 linearly
  80928. * @param startValue Start value of the animation curve
  80929. * @param endValue End value of the animation curve
  80930. * @param gradient Scalar amount to interpolate
  80931. * @returns Interpolated Vector2 value
  80932. */
  80933. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  80934. /**
  80935. * Interpolates a Vector2 cubically
  80936. * @param startValue Start value of the animation curve
  80937. * @param outTangent End tangent of the animation
  80938. * @param endValue End value of the animation curve
  80939. * @param inTangent Start tangent of the animation curve
  80940. * @param gradient Scalar amount to interpolate
  80941. * @returns Interpolated Vector2 value
  80942. */
  80943. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  80944. /**
  80945. * Interpolates a size linearly
  80946. * @param startValue Start value of the animation curve
  80947. * @param endValue End value of the animation curve
  80948. * @param gradient Scalar amount to interpolate
  80949. * @returns Interpolated Size value
  80950. */
  80951. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  80952. /**
  80953. * Interpolates a Color3 linearly
  80954. * @param startValue Start value of the animation curve
  80955. * @param endValue End value of the animation curve
  80956. * @param gradient Scalar amount to interpolate
  80957. * @returns Interpolated Color3 value
  80958. */
  80959. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  80960. /**
  80961. * @hidden Internal use only
  80962. */
  80963. _getKeyValue(value: any): any;
  80964. /**
  80965. * @hidden Internal use only
  80966. */
  80967. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  80968. /**
  80969. * Defines the function to use to interpolate matrices
  80970. * @param startValue defines the start matrix
  80971. * @param endValue defines the end matrix
  80972. * @param gradient defines the gradient between both matrices
  80973. * @param result defines an optional target matrix where to store the interpolation
  80974. * @returns the interpolated matrix
  80975. */
  80976. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  80977. /**
  80978. * Makes a copy of the animation
  80979. * @returns Cloned animation
  80980. */
  80981. clone(): Animation;
  80982. /**
  80983. * Sets the key frames of the animation
  80984. * @param values The animation key frames to set
  80985. */
  80986. setKeys(values: Array<IAnimationKey>): void;
  80987. /**
  80988. * Serializes the animation to an object
  80989. * @returns Serialized object
  80990. */
  80991. serialize(): any;
  80992. /**
  80993. * Float animation type
  80994. */
  80995. private static _ANIMATIONTYPE_FLOAT;
  80996. /**
  80997. * Vector3 animation type
  80998. */
  80999. private static _ANIMATIONTYPE_VECTOR3;
  81000. /**
  81001. * Quaternion animation type
  81002. */
  81003. private static _ANIMATIONTYPE_QUATERNION;
  81004. /**
  81005. * Matrix animation type
  81006. */
  81007. private static _ANIMATIONTYPE_MATRIX;
  81008. /**
  81009. * Color3 animation type
  81010. */
  81011. private static _ANIMATIONTYPE_COLOR3;
  81012. /**
  81013. * Vector2 animation type
  81014. */
  81015. private static _ANIMATIONTYPE_VECTOR2;
  81016. /**
  81017. * Size animation type
  81018. */
  81019. private static _ANIMATIONTYPE_SIZE;
  81020. /**
  81021. * Relative Loop Mode
  81022. */
  81023. private static _ANIMATIONLOOPMODE_RELATIVE;
  81024. /**
  81025. * Cycle Loop Mode
  81026. */
  81027. private static _ANIMATIONLOOPMODE_CYCLE;
  81028. /**
  81029. * Constant Loop Mode
  81030. */
  81031. private static _ANIMATIONLOOPMODE_CONSTANT;
  81032. /**
  81033. * Get the float animation type
  81034. */
  81035. static readonly ANIMATIONTYPE_FLOAT: number;
  81036. /**
  81037. * Get the Vector3 animation type
  81038. */
  81039. static readonly ANIMATIONTYPE_VECTOR3: number;
  81040. /**
  81041. * Get the Vector2 animation type
  81042. */
  81043. static readonly ANIMATIONTYPE_VECTOR2: number;
  81044. /**
  81045. * Get the Size animation type
  81046. */
  81047. static readonly ANIMATIONTYPE_SIZE: number;
  81048. /**
  81049. * Get the Quaternion animation type
  81050. */
  81051. static readonly ANIMATIONTYPE_QUATERNION: number;
  81052. /**
  81053. * Get the Matrix animation type
  81054. */
  81055. static readonly ANIMATIONTYPE_MATRIX: number;
  81056. /**
  81057. * Get the Color3 animation type
  81058. */
  81059. static readonly ANIMATIONTYPE_COLOR3: number;
  81060. /**
  81061. * Get the Relative Loop Mode
  81062. */
  81063. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81064. /**
  81065. * Get the Cycle Loop Mode
  81066. */
  81067. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81068. /**
  81069. * Get the Constant Loop Mode
  81070. */
  81071. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81072. /** @hidden */
  81073. static _UniversalLerp(left: any, right: any, amount: number): any;
  81074. /**
  81075. * Parses an animation object and creates an animation
  81076. * @param parsedAnimation Parsed animation object
  81077. * @returns Animation object
  81078. */
  81079. static Parse(parsedAnimation: any): Animation;
  81080. /**
  81081. * Appends the serialized animations from the source animations
  81082. * @param source Source containing the animations
  81083. * @param destination Target to store the animations
  81084. */
  81085. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81086. }
  81087. }
  81088. declare module BABYLON {
  81089. /**
  81090. * Base class of all the textures in babylon.
  81091. * It groups all the common properties the materials, post process, lights... might need
  81092. * in order to make a correct use of the texture.
  81093. */
  81094. export class BaseTexture implements IAnimatable {
  81095. /**
  81096. * Default anisotropic filtering level for the application.
  81097. * It is set to 4 as a good tradeoff between perf and quality.
  81098. */
  81099. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81100. /**
  81101. * Gets or sets the unique id of the texture
  81102. */
  81103. uniqueId: number;
  81104. /**
  81105. * Define the name of the texture.
  81106. */
  81107. name: string;
  81108. /**
  81109. * Gets or sets an object used to store user defined information.
  81110. */
  81111. metadata: any;
  81112. /**
  81113. * For internal use only. Please do not use.
  81114. */
  81115. reservedDataStore: any;
  81116. private _hasAlpha;
  81117. /**
  81118. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81119. */
  81120. hasAlpha: boolean;
  81121. /**
  81122. * Defines if the alpha value should be determined via the rgb values.
  81123. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81124. */
  81125. getAlphaFromRGB: boolean;
  81126. /**
  81127. * Intensity or strength of the texture.
  81128. * It is commonly used by materials to fine tune the intensity of the texture
  81129. */
  81130. level: number;
  81131. /**
  81132. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81133. * This is part of the texture as textures usually maps to one uv set.
  81134. */
  81135. coordinatesIndex: number;
  81136. private _coordinatesMode;
  81137. /**
  81138. * How a texture is mapped.
  81139. *
  81140. * | Value | Type | Description |
  81141. * | ----- | ----------------------------------- | ----------- |
  81142. * | 0 | EXPLICIT_MODE | |
  81143. * | 1 | SPHERICAL_MODE | |
  81144. * | 2 | PLANAR_MODE | |
  81145. * | 3 | CUBIC_MODE | |
  81146. * | 4 | PROJECTION_MODE | |
  81147. * | 5 | SKYBOX_MODE | |
  81148. * | 6 | INVCUBIC_MODE | |
  81149. * | 7 | EQUIRECTANGULAR_MODE | |
  81150. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81151. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81152. */
  81153. coordinatesMode: number;
  81154. /**
  81155. * | Value | Type | Description |
  81156. * | ----- | ------------------ | ----------- |
  81157. * | 0 | CLAMP_ADDRESSMODE | |
  81158. * | 1 | WRAP_ADDRESSMODE | |
  81159. * | 2 | MIRROR_ADDRESSMODE | |
  81160. */
  81161. wrapU: number;
  81162. /**
  81163. * | Value | Type | Description |
  81164. * | ----- | ------------------ | ----------- |
  81165. * | 0 | CLAMP_ADDRESSMODE | |
  81166. * | 1 | WRAP_ADDRESSMODE | |
  81167. * | 2 | MIRROR_ADDRESSMODE | |
  81168. */
  81169. wrapV: number;
  81170. /**
  81171. * | Value | Type | Description |
  81172. * | ----- | ------------------ | ----------- |
  81173. * | 0 | CLAMP_ADDRESSMODE | |
  81174. * | 1 | WRAP_ADDRESSMODE | |
  81175. * | 2 | MIRROR_ADDRESSMODE | |
  81176. */
  81177. wrapR: number;
  81178. /**
  81179. * With compliant hardware and browser (supporting anisotropic filtering)
  81180. * this defines the level of anisotropic filtering in the texture.
  81181. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81182. */
  81183. anisotropicFilteringLevel: number;
  81184. /**
  81185. * Define if the texture is a cube texture or if false a 2d texture.
  81186. */
  81187. isCube: boolean;
  81188. /**
  81189. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81190. */
  81191. is3D: boolean;
  81192. /**
  81193. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81194. * HDR texture are usually stored in linear space.
  81195. * This only impacts the PBR and Background materials
  81196. */
  81197. gammaSpace: boolean;
  81198. /**
  81199. * Gets whether or not the texture contains RGBD data.
  81200. */
  81201. readonly isRGBD: boolean;
  81202. /**
  81203. * Is Z inverted in the texture (useful in a cube texture).
  81204. */
  81205. invertZ: boolean;
  81206. /**
  81207. * Are mip maps generated for this texture or not.
  81208. */
  81209. readonly noMipmap: boolean;
  81210. /**
  81211. * @hidden
  81212. */
  81213. lodLevelInAlpha: boolean;
  81214. /**
  81215. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81216. */
  81217. lodGenerationOffset: number;
  81218. /**
  81219. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81220. */
  81221. lodGenerationScale: number;
  81222. /**
  81223. * Define if the texture is a render target.
  81224. */
  81225. isRenderTarget: boolean;
  81226. /**
  81227. * Define the unique id of the texture in the scene.
  81228. */
  81229. readonly uid: string;
  81230. /**
  81231. * Return a string representation of the texture.
  81232. * @returns the texture as a string
  81233. */
  81234. toString(): string;
  81235. /**
  81236. * Get the class name of the texture.
  81237. * @returns "BaseTexture"
  81238. */
  81239. getClassName(): string;
  81240. /**
  81241. * Define the list of animation attached to the texture.
  81242. */
  81243. animations: Animation[];
  81244. /**
  81245. * An event triggered when the texture is disposed.
  81246. */
  81247. onDisposeObservable: Observable<BaseTexture>;
  81248. private _onDisposeObserver;
  81249. /**
  81250. * Callback triggered when the texture has been disposed.
  81251. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81252. */
  81253. onDispose: () => void;
  81254. /**
  81255. * Define the current state of the loading sequence when in delayed load mode.
  81256. */
  81257. delayLoadState: number;
  81258. private _scene;
  81259. /** @hidden */
  81260. _texture: Nullable<InternalTexture>;
  81261. private _uid;
  81262. /**
  81263. * Define if the texture is preventinga material to render or not.
  81264. * If not and the texture is not ready, the engine will use a default black texture instead.
  81265. */
  81266. readonly isBlocking: boolean;
  81267. /**
  81268. * Instantiates a new BaseTexture.
  81269. * Base class of all the textures in babylon.
  81270. * It groups all the common properties the materials, post process, lights... might need
  81271. * in order to make a correct use of the texture.
  81272. * @param scene Define the scene the texture blongs to
  81273. */
  81274. constructor(scene: Nullable<Scene>);
  81275. /**
  81276. * Get the scene the texture belongs to.
  81277. * @returns the scene or null if undefined
  81278. */
  81279. getScene(): Nullable<Scene>;
  81280. /**
  81281. * Get the texture transform matrix used to offset tile the texture for istance.
  81282. * @returns the transformation matrix
  81283. */
  81284. getTextureMatrix(): Matrix;
  81285. /**
  81286. * Get the texture reflection matrix used to rotate/transform the reflection.
  81287. * @returns the reflection matrix
  81288. */
  81289. getReflectionTextureMatrix(): Matrix;
  81290. /**
  81291. * Get the underlying lower level texture from Babylon.
  81292. * @returns the insternal texture
  81293. */
  81294. getInternalTexture(): Nullable<InternalTexture>;
  81295. /**
  81296. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81297. * @returns true if ready or not blocking
  81298. */
  81299. isReadyOrNotBlocking(): boolean;
  81300. /**
  81301. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81302. * @returns true if fully ready
  81303. */
  81304. isReady(): boolean;
  81305. private _cachedSize;
  81306. /**
  81307. * Get the size of the texture.
  81308. * @returns the texture size.
  81309. */
  81310. getSize(): ISize;
  81311. /**
  81312. * Get the base size of the texture.
  81313. * It can be different from the size if the texture has been resized for POT for instance
  81314. * @returns the base size
  81315. */
  81316. getBaseSize(): ISize;
  81317. /**
  81318. * Update the sampling mode of the texture.
  81319. * Default is Trilinear mode.
  81320. *
  81321. * | Value | Type | Description |
  81322. * | ----- | ------------------ | ----------- |
  81323. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81324. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81325. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81326. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81327. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81328. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81329. * | 7 | NEAREST_LINEAR | |
  81330. * | 8 | NEAREST_NEAREST | |
  81331. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81332. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81333. * | 11 | LINEAR_LINEAR | |
  81334. * | 12 | LINEAR_NEAREST | |
  81335. *
  81336. * > _mag_: magnification filter (close to the viewer)
  81337. * > _min_: minification filter (far from the viewer)
  81338. * > _mip_: filter used between mip map levels
  81339. *@param samplingMode Define the new sampling mode of the texture
  81340. */
  81341. updateSamplingMode(samplingMode: number): void;
  81342. /**
  81343. * Scales the texture if is `canRescale()`
  81344. * @param ratio the resize factor we want to use to rescale
  81345. */
  81346. scale(ratio: number): void;
  81347. /**
  81348. * Get if the texture can rescale.
  81349. */
  81350. readonly canRescale: boolean;
  81351. /** @hidden */
  81352. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81353. /** @hidden */
  81354. _rebuild(): void;
  81355. /**
  81356. * Triggers the load sequence in delayed load mode.
  81357. */
  81358. delayLoad(): void;
  81359. /**
  81360. * Clones the texture.
  81361. * @returns the cloned texture
  81362. */
  81363. clone(): Nullable<BaseTexture>;
  81364. /**
  81365. * Get the texture underlying type (INT, FLOAT...)
  81366. */
  81367. readonly textureType: number;
  81368. /**
  81369. * Get the texture underlying format (RGB, RGBA...)
  81370. */
  81371. readonly textureFormat: number;
  81372. /**
  81373. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81374. * This will returns an RGBA array buffer containing either in values (0-255) or
  81375. * float values (0-1) depending of the underlying buffer type.
  81376. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81377. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81378. * @param buffer defines a user defined buffer to fill with data (can be null)
  81379. * @returns The Array buffer containing the pixels data.
  81380. */
  81381. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81382. /**
  81383. * Release and destroy the underlying lower level texture aka internalTexture.
  81384. */
  81385. releaseInternalTexture(): void;
  81386. /**
  81387. * Get the polynomial representation of the texture data.
  81388. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81389. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81390. */
  81391. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81392. /** @hidden */
  81393. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81394. /** @hidden */
  81395. readonly _lodTextureMid: Nullable<BaseTexture>;
  81396. /** @hidden */
  81397. readonly _lodTextureLow: Nullable<BaseTexture>;
  81398. /**
  81399. * Dispose the texture and release its associated resources.
  81400. */
  81401. dispose(): void;
  81402. /**
  81403. * Serialize the texture into a JSON representation that can be parsed later on.
  81404. * @returns the JSON representation of the texture
  81405. */
  81406. serialize(): any;
  81407. /**
  81408. * Helper function to be called back once a list of texture contains only ready textures.
  81409. * @param textures Define the list of textures to wait for
  81410. * @param callback Define the callback triggered once the entire list will be ready
  81411. */
  81412. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81413. }
  81414. }
  81415. declare module BABYLON {
  81416. /**
  81417. * Uniform buffer objects.
  81418. *
  81419. * Handles blocks of uniform on the GPU.
  81420. *
  81421. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81422. *
  81423. * For more information, please refer to :
  81424. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81425. */
  81426. export class UniformBuffer {
  81427. private _engine;
  81428. private _buffer;
  81429. private _data;
  81430. private _bufferData;
  81431. private _dynamic?;
  81432. private _uniformLocations;
  81433. private _uniformSizes;
  81434. private _uniformLocationPointer;
  81435. private _needSync;
  81436. private _noUBO;
  81437. private _currentEffect;
  81438. private static _MAX_UNIFORM_SIZE;
  81439. private static _tempBuffer;
  81440. /**
  81441. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81442. * This is dynamic to allow compat with webgl 1 and 2.
  81443. * You will need to pass the name of the uniform as well as the value.
  81444. */
  81445. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81446. /**
  81447. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81448. * This is dynamic to allow compat with webgl 1 and 2.
  81449. * You will need to pass the name of the uniform as well as the value.
  81450. */
  81451. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81452. /**
  81453. * Lambda to Update a single float in a uniform buffer.
  81454. * This is dynamic to allow compat with webgl 1 and 2.
  81455. * You will need to pass the name of the uniform as well as the value.
  81456. */
  81457. updateFloat: (name: string, x: number) => void;
  81458. /**
  81459. * Lambda to Update a vec2 of float in a uniform buffer.
  81460. * This is dynamic to allow compat with webgl 1 and 2.
  81461. * You will need to pass the name of the uniform as well as the value.
  81462. */
  81463. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81464. /**
  81465. * Lambda to Update a vec3 of float in a uniform buffer.
  81466. * This is dynamic to allow compat with webgl 1 and 2.
  81467. * You will need to pass the name of the uniform as well as the value.
  81468. */
  81469. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81470. /**
  81471. * Lambda to Update a vec4 of float in a uniform buffer.
  81472. * This is dynamic to allow compat with webgl 1 and 2.
  81473. * You will need to pass the name of the uniform as well as the value.
  81474. */
  81475. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81476. /**
  81477. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81478. * This is dynamic to allow compat with webgl 1 and 2.
  81479. * You will need to pass the name of the uniform as well as the value.
  81480. */
  81481. updateMatrix: (name: string, mat: Matrix) => void;
  81482. /**
  81483. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81484. * This is dynamic to allow compat with webgl 1 and 2.
  81485. * You will need to pass the name of the uniform as well as the value.
  81486. */
  81487. updateVector3: (name: string, vector: Vector3) => void;
  81488. /**
  81489. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81490. * This is dynamic to allow compat with webgl 1 and 2.
  81491. * You will need to pass the name of the uniform as well as the value.
  81492. */
  81493. updateVector4: (name: string, vector: Vector4) => void;
  81494. /**
  81495. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81496. * This is dynamic to allow compat with webgl 1 and 2.
  81497. * You will need to pass the name of the uniform as well as the value.
  81498. */
  81499. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81500. /**
  81501. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81502. * This is dynamic to allow compat with webgl 1 and 2.
  81503. * You will need to pass the name of the uniform as well as the value.
  81504. */
  81505. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81506. /**
  81507. * Instantiates a new Uniform buffer objects.
  81508. *
  81509. * Handles blocks of uniform on the GPU.
  81510. *
  81511. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81512. *
  81513. * For more information, please refer to :
  81514. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81515. * @param engine Define the engine the buffer is associated with
  81516. * @param data Define the data contained in the buffer
  81517. * @param dynamic Define if the buffer is updatable
  81518. */
  81519. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81520. /**
  81521. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81522. * or just falling back on setUniformXXX calls.
  81523. */
  81524. readonly useUbo: boolean;
  81525. /**
  81526. * Indicates if the WebGL underlying uniform buffer is in sync
  81527. * with the javascript cache data.
  81528. */
  81529. readonly isSync: boolean;
  81530. /**
  81531. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81532. * Also, a dynamic UniformBuffer will disable cache verification and always
  81533. * update the underlying WebGL uniform buffer to the GPU.
  81534. * @returns if Dynamic, otherwise false
  81535. */
  81536. isDynamic(): boolean;
  81537. /**
  81538. * The data cache on JS side.
  81539. * @returns the underlying data as a float array
  81540. */
  81541. getData(): Float32Array;
  81542. /**
  81543. * The underlying WebGL Uniform buffer.
  81544. * @returns the webgl buffer
  81545. */
  81546. getBuffer(): Nullable<WebGLBuffer>;
  81547. /**
  81548. * std140 layout specifies how to align data within an UBO structure.
  81549. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81550. * for specs.
  81551. */
  81552. private _fillAlignment;
  81553. /**
  81554. * Adds an uniform in the buffer.
  81555. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81556. * for the layout to be correct !
  81557. * @param name Name of the uniform, as used in the uniform block in the shader.
  81558. * @param size Data size, or data directly.
  81559. */
  81560. addUniform(name: string, size: number | number[]): void;
  81561. /**
  81562. * Adds a Matrix 4x4 to the uniform buffer.
  81563. * @param name Name of the uniform, as used in the uniform block in the shader.
  81564. * @param mat A 4x4 matrix.
  81565. */
  81566. addMatrix(name: string, mat: Matrix): void;
  81567. /**
  81568. * Adds a vec2 to the uniform buffer.
  81569. * @param name Name of the uniform, as used in the uniform block in the shader.
  81570. * @param x Define the x component value of the vec2
  81571. * @param y Define the y component value of the vec2
  81572. */
  81573. addFloat2(name: string, x: number, y: number): void;
  81574. /**
  81575. * Adds a vec3 to the uniform buffer.
  81576. * @param name Name of the uniform, as used in the uniform block in the shader.
  81577. * @param x Define the x component value of the vec3
  81578. * @param y Define the y component value of the vec3
  81579. * @param z Define the z component value of the vec3
  81580. */
  81581. addFloat3(name: string, x: number, y: number, z: number): void;
  81582. /**
  81583. * Adds a vec3 to the uniform buffer.
  81584. * @param name Name of the uniform, as used in the uniform block in the shader.
  81585. * @param color Define the vec3 from a Color
  81586. */
  81587. addColor3(name: string, color: Color3): void;
  81588. /**
  81589. * Adds a vec4 to the uniform buffer.
  81590. * @param name Name of the uniform, as used in the uniform block in the shader.
  81591. * @param color Define the rgb components from a Color
  81592. * @param alpha Define the a component of the vec4
  81593. */
  81594. addColor4(name: string, color: Color3, alpha: number): void;
  81595. /**
  81596. * Adds a vec3 to the uniform buffer.
  81597. * @param name Name of the uniform, as used in the uniform block in the shader.
  81598. * @param vector Define the vec3 components from a Vector
  81599. */
  81600. addVector3(name: string, vector: Vector3): void;
  81601. /**
  81602. * Adds a Matrix 3x3 to the uniform buffer.
  81603. * @param name Name of the uniform, as used in the uniform block in the shader.
  81604. */
  81605. addMatrix3x3(name: string): void;
  81606. /**
  81607. * Adds a Matrix 2x2 to the uniform buffer.
  81608. * @param name Name of the uniform, as used in the uniform block in the shader.
  81609. */
  81610. addMatrix2x2(name: string): void;
  81611. /**
  81612. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81613. */
  81614. create(): void;
  81615. /** @hidden */
  81616. _rebuild(): void;
  81617. /**
  81618. * Updates the WebGL Uniform Buffer on the GPU.
  81619. * If the `dynamic` flag is set to true, no cache comparison is done.
  81620. * Otherwise, the buffer will be updated only if the cache differs.
  81621. */
  81622. update(): void;
  81623. /**
  81624. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81625. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81626. * @param data Define the flattened data
  81627. * @param size Define the size of the data.
  81628. */
  81629. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81630. private _updateMatrix3x3ForUniform;
  81631. private _updateMatrix3x3ForEffect;
  81632. private _updateMatrix2x2ForEffect;
  81633. private _updateMatrix2x2ForUniform;
  81634. private _updateFloatForEffect;
  81635. private _updateFloatForUniform;
  81636. private _updateFloat2ForEffect;
  81637. private _updateFloat2ForUniform;
  81638. private _updateFloat3ForEffect;
  81639. private _updateFloat3ForUniform;
  81640. private _updateFloat4ForEffect;
  81641. private _updateFloat4ForUniform;
  81642. private _updateMatrixForEffect;
  81643. private _updateMatrixForUniform;
  81644. private _updateVector3ForEffect;
  81645. private _updateVector3ForUniform;
  81646. private _updateVector4ForEffect;
  81647. private _updateVector4ForUniform;
  81648. private _updateColor3ForEffect;
  81649. private _updateColor3ForUniform;
  81650. private _updateColor4ForEffect;
  81651. private _updateColor4ForUniform;
  81652. /**
  81653. * Sets a sampler uniform on the effect.
  81654. * @param name Define the name of the sampler.
  81655. * @param texture Define the texture to set in the sampler
  81656. */
  81657. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81658. /**
  81659. * Directly updates the value of the uniform in the cache AND on the GPU.
  81660. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81661. * @param data Define the flattened data
  81662. */
  81663. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81664. /**
  81665. * Binds this uniform buffer to an effect.
  81666. * @param effect Define the effect to bind the buffer to
  81667. * @param name Name of the uniform block in the shader.
  81668. */
  81669. bindToEffect(effect: Effect, name: string): void;
  81670. /**
  81671. * Disposes the uniform buffer.
  81672. */
  81673. dispose(): void;
  81674. }
  81675. }
  81676. declare module BABYLON {
  81677. /**
  81678. * This represents the required contract to create a new type of texture loader.
  81679. */
  81680. export interface IInternalTextureLoader {
  81681. /**
  81682. * Defines wether the loader supports cascade loading the different faces.
  81683. */
  81684. supportCascades: boolean;
  81685. /**
  81686. * This returns if the loader support the current file information.
  81687. * @param extension defines the file extension of the file being loaded
  81688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81689. * @param fallback defines the fallback internal texture if any
  81690. * @param isBase64 defines whether the texture is encoded as a base64
  81691. * @param isBuffer defines whether the texture data are stored as a buffer
  81692. * @returns true if the loader can load the specified file
  81693. */
  81694. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  81695. /**
  81696. * Transform the url before loading if required.
  81697. * @param rootUrl the url of the texture
  81698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81699. * @returns the transformed texture
  81700. */
  81701. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  81702. /**
  81703. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  81704. * @param rootUrl the url of the texture
  81705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81706. * @returns the fallback texture
  81707. */
  81708. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  81709. /**
  81710. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  81711. * @param data contains the texture data
  81712. * @param texture defines the BabylonJS internal texture
  81713. * @param createPolynomials will be true if polynomials have been requested
  81714. * @param onLoad defines the callback to trigger once the texture is ready
  81715. * @param onError defines the callback to trigger in case of error
  81716. */
  81717. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81718. /**
  81719. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  81720. * @param data contains the texture data
  81721. * @param texture defines the BabylonJS internal texture
  81722. * @param callback defines the method to call once ready to upload
  81723. */
  81724. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81725. }
  81726. }
  81727. declare module BABYLON {
  81728. /**
  81729. * Creation options of the multi render target texture.
  81730. */
  81731. export interface IMultiRenderTargetOptions {
  81732. /**
  81733. * Define if the texture needs to create mip maps after render.
  81734. */
  81735. generateMipMaps?: boolean;
  81736. /**
  81737. * Define the types of all the draw buffers we want to create
  81738. */
  81739. types?: number[];
  81740. /**
  81741. * Define the sampling modes of all the draw buffers we want to create
  81742. */
  81743. samplingModes?: number[];
  81744. /**
  81745. * Define if a depth buffer is required
  81746. */
  81747. generateDepthBuffer?: boolean;
  81748. /**
  81749. * Define if a stencil buffer is required
  81750. */
  81751. generateStencilBuffer?: boolean;
  81752. /**
  81753. * Define if a depth texture is required instead of a depth buffer
  81754. */
  81755. generateDepthTexture?: boolean;
  81756. /**
  81757. * Define the number of desired draw buffers
  81758. */
  81759. textureCount?: number;
  81760. /**
  81761. * Define if aspect ratio should be adapted to the texture or stay the scene one
  81762. */
  81763. doNotChangeAspectRatio?: boolean;
  81764. /**
  81765. * Define the default type of the buffers we are creating
  81766. */
  81767. defaultType?: number;
  81768. }
  81769. /**
  81770. * A multi render target, like a render target provides the ability to render to a texture.
  81771. * Unlike the render target, it can render to several draw buffers in one draw.
  81772. * This is specially interesting in deferred rendering or for any effects requiring more than
  81773. * just one color from a single pass.
  81774. */
  81775. export class MultiRenderTarget extends RenderTargetTexture {
  81776. private _internalTextures;
  81777. private _textures;
  81778. private _multiRenderTargetOptions;
  81779. /**
  81780. * Get if draw buffers are currently supported by the used hardware and browser.
  81781. */
  81782. readonly isSupported: boolean;
  81783. /**
  81784. * Get the list of textures generated by the multi render target.
  81785. */
  81786. readonly textures: Texture[];
  81787. /**
  81788. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  81789. */
  81790. readonly depthTexture: Texture;
  81791. /**
  81792. * Set the wrapping mode on U of all the textures we are rendering to.
  81793. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81794. */
  81795. wrapU: number;
  81796. /**
  81797. * Set the wrapping mode on V of all the textures we are rendering to.
  81798. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81799. */
  81800. wrapV: number;
  81801. /**
  81802. * Instantiate a new multi render target texture.
  81803. * A multi render target, like a render target provides the ability to render to a texture.
  81804. * Unlike the render target, it can render to several draw buffers in one draw.
  81805. * This is specially interesting in deferred rendering or for any effects requiring more than
  81806. * just one color from a single pass.
  81807. * @param name Define the name of the texture
  81808. * @param size Define the size of the buffers to render to
  81809. * @param count Define the number of target we are rendering into
  81810. * @param scene Define the scene the texture belongs to
  81811. * @param options Define the options used to create the multi render target
  81812. */
  81813. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  81814. /** @hidden */
  81815. _rebuild(): void;
  81816. private _createInternalTextures;
  81817. private _createTextures;
  81818. /**
  81819. * Define the number of samples used if MSAA is enabled.
  81820. */
  81821. samples: number;
  81822. /**
  81823. * Resize all the textures in the multi render target.
  81824. * Be carrefull as it will recreate all the data in the new texture.
  81825. * @param size Define the new size
  81826. */
  81827. resize(size: any): void;
  81828. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  81829. /**
  81830. * Dispose the render targets and their associated resources
  81831. */
  81832. dispose(): void;
  81833. /**
  81834. * Release all the underlying texture used as draw buffers.
  81835. */
  81836. releaseInternalTextures(): void;
  81837. }
  81838. }
  81839. declare module BABYLON {
  81840. /**
  81841. * Class used to work with sound analyzer using fast fourier transform (FFT)
  81842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  81843. */
  81844. export class Analyser {
  81845. /**
  81846. * Gets or sets the smoothing
  81847. * @ignorenaming
  81848. */
  81849. SMOOTHING: number;
  81850. /**
  81851. * Gets or sets the FFT table size
  81852. * @ignorenaming
  81853. */
  81854. FFT_SIZE: number;
  81855. /**
  81856. * Gets or sets the bar graph amplitude
  81857. * @ignorenaming
  81858. */
  81859. BARGRAPHAMPLITUDE: number;
  81860. /**
  81861. * Gets or sets the position of the debug canvas
  81862. * @ignorenaming
  81863. */
  81864. DEBUGCANVASPOS: {
  81865. x: number;
  81866. y: number;
  81867. };
  81868. /**
  81869. * Gets or sets the debug canvas size
  81870. * @ignorenaming
  81871. */
  81872. DEBUGCANVASSIZE: {
  81873. width: number;
  81874. height: number;
  81875. };
  81876. private _byteFreqs;
  81877. private _byteTime;
  81878. private _floatFreqs;
  81879. private _webAudioAnalyser;
  81880. private _debugCanvas;
  81881. private _debugCanvasContext;
  81882. private _scene;
  81883. private _registerFunc;
  81884. private _audioEngine;
  81885. /**
  81886. * Creates a new analyser
  81887. * @param scene defines hosting scene
  81888. */
  81889. constructor(scene: Scene);
  81890. /**
  81891. * Get the number of data values you will have to play with for the visualization
  81892. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  81893. * @returns a number
  81894. */
  81895. getFrequencyBinCount(): number;
  81896. /**
  81897. * Gets the current frequency data as a byte array
  81898. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  81899. * @returns a Uint8Array
  81900. */
  81901. getByteFrequencyData(): Uint8Array;
  81902. /**
  81903. * Gets the current waveform as a byte array
  81904. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  81905. * @returns a Uint8Array
  81906. */
  81907. getByteTimeDomainData(): Uint8Array;
  81908. /**
  81909. * Gets the current frequency data as a float array
  81910. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  81911. * @returns a Float32Array
  81912. */
  81913. getFloatFrequencyData(): Float32Array;
  81914. /**
  81915. * Renders the debug canvas
  81916. */
  81917. drawDebugCanvas(): void;
  81918. /**
  81919. * Stops rendering the debug canvas and removes it
  81920. */
  81921. stopDebugCanvas(): void;
  81922. /**
  81923. * Connects two audio nodes
  81924. * @param inputAudioNode defines first node to connect
  81925. * @param outputAudioNode defines second node to connect
  81926. */
  81927. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  81928. /**
  81929. * Releases all associated resources
  81930. */
  81931. dispose(): void;
  81932. }
  81933. }
  81934. declare module BABYLON {
  81935. /**
  81936. * This represents an audio engine and it is responsible
  81937. * to play, synchronize and analyse sounds throughout the application.
  81938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  81939. */
  81940. export interface IAudioEngine extends IDisposable {
  81941. /**
  81942. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  81943. */
  81944. readonly canUseWebAudio: boolean;
  81945. /**
  81946. * Gets the current AudioContext if available.
  81947. */
  81948. readonly audioContext: Nullable<AudioContext>;
  81949. /**
  81950. * The master gain node defines the global audio volume of your audio engine.
  81951. */
  81952. readonly masterGain: GainNode;
  81953. /**
  81954. * Gets whether or not mp3 are supported by your browser.
  81955. */
  81956. readonly isMP3supported: boolean;
  81957. /**
  81958. * Gets whether or not ogg are supported by your browser.
  81959. */
  81960. readonly isOGGsupported: boolean;
  81961. /**
  81962. * Defines if Babylon should emit a warning if WebAudio is not supported.
  81963. * @ignoreNaming
  81964. */
  81965. WarnedWebAudioUnsupported: boolean;
  81966. /**
  81967. * Defines if the audio engine relies on a custom unlocked button.
  81968. * In this case, the embedded button will not be displayed.
  81969. */
  81970. useCustomUnlockedButton: boolean;
  81971. /**
  81972. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  81973. */
  81974. readonly unlocked: boolean;
  81975. /**
  81976. * Event raised when audio has been unlocked on the browser.
  81977. */
  81978. onAudioUnlockedObservable: Observable<AudioEngine>;
  81979. /**
  81980. * Event raised when audio has been locked on the browser.
  81981. */
  81982. onAudioLockedObservable: Observable<AudioEngine>;
  81983. /**
  81984. * Flags the audio engine in Locked state.
  81985. * This happens due to new browser policies preventing audio to autoplay.
  81986. */
  81987. lock(): void;
  81988. /**
  81989. * Unlocks the audio engine once a user action has been done on the dom.
  81990. * This is helpful to resume play once browser policies have been satisfied.
  81991. */
  81992. unlock(): void;
  81993. }
  81994. /**
  81995. * This represents the default audio engine used in babylon.
  81996. * It is responsible to play, synchronize and analyse sounds throughout the application.
  81997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  81998. */
  81999. export class AudioEngine implements IAudioEngine {
  82000. private _audioContext;
  82001. private _audioContextInitialized;
  82002. private _muteButton;
  82003. private _hostElement;
  82004. /**
  82005. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82006. */
  82007. canUseWebAudio: boolean;
  82008. /**
  82009. * The master gain node defines the global audio volume of your audio engine.
  82010. */
  82011. masterGain: GainNode;
  82012. /**
  82013. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82014. * @ignoreNaming
  82015. */
  82016. WarnedWebAudioUnsupported: boolean;
  82017. /**
  82018. * Gets whether or not mp3 are supported by your browser.
  82019. */
  82020. isMP3supported: boolean;
  82021. /**
  82022. * Gets whether or not ogg are supported by your browser.
  82023. */
  82024. isOGGsupported: boolean;
  82025. /**
  82026. * Gets whether audio has been unlocked on the device.
  82027. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82028. * a user interaction has happened.
  82029. */
  82030. unlocked: boolean;
  82031. /**
  82032. * Defines if the audio engine relies on a custom unlocked button.
  82033. * In this case, the embedded button will not be displayed.
  82034. */
  82035. useCustomUnlockedButton: boolean;
  82036. /**
  82037. * Event raised when audio has been unlocked on the browser.
  82038. */
  82039. onAudioUnlockedObservable: Observable<AudioEngine>;
  82040. /**
  82041. * Event raised when audio has been locked on the browser.
  82042. */
  82043. onAudioLockedObservable: Observable<AudioEngine>;
  82044. /**
  82045. * Gets the current AudioContext if available.
  82046. */
  82047. readonly audioContext: Nullable<AudioContext>;
  82048. private _connectedAnalyser;
  82049. /**
  82050. * Instantiates a new audio engine.
  82051. *
  82052. * There should be only one per page as some browsers restrict the number
  82053. * of audio contexts you can create.
  82054. * @param hostElement defines the host element where to display the mute icon if necessary
  82055. */
  82056. constructor(hostElement?: Nullable<HTMLElement>);
  82057. /**
  82058. * Flags the audio engine in Locked state.
  82059. * This happens due to new browser policies preventing audio to autoplay.
  82060. */
  82061. lock(): void;
  82062. /**
  82063. * Unlocks the audio engine once a user action has been done on the dom.
  82064. * This is helpful to resume play once browser policies have been satisfied.
  82065. */
  82066. unlock(): void;
  82067. private _resumeAudioContext;
  82068. private _initializeAudioContext;
  82069. private _tryToRun;
  82070. private _triggerRunningState;
  82071. private _triggerSuspendedState;
  82072. private _displayMuteButton;
  82073. private _moveButtonToTopLeft;
  82074. private _onResize;
  82075. private _hideMuteButton;
  82076. /**
  82077. * Destroy and release the resources associated with the audio ccontext.
  82078. */
  82079. dispose(): void;
  82080. /**
  82081. * Gets the global volume sets on the master gain.
  82082. * @returns the global volume if set or -1 otherwise
  82083. */
  82084. getGlobalVolume(): number;
  82085. /**
  82086. * Sets the global volume of your experience (sets on the master gain).
  82087. * @param newVolume Defines the new global volume of the application
  82088. */
  82089. setGlobalVolume(newVolume: number): void;
  82090. /**
  82091. * Connect the audio engine to an audio analyser allowing some amazing
  82092. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82094. * @param analyser The analyser to connect to the engine
  82095. */
  82096. connectToAnalyser(analyser: Analyser): void;
  82097. }
  82098. }
  82099. declare module BABYLON {
  82100. /**
  82101. * Interface used to present a loading screen while loading a scene
  82102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82103. */
  82104. export interface ILoadingScreen {
  82105. /**
  82106. * Function called to display the loading screen
  82107. */
  82108. displayLoadingUI: () => void;
  82109. /**
  82110. * Function called to hide the loading screen
  82111. */
  82112. hideLoadingUI: () => void;
  82113. /**
  82114. * Gets or sets the color to use for the background
  82115. */
  82116. loadingUIBackgroundColor: string;
  82117. /**
  82118. * Gets or sets the text to display while loading
  82119. */
  82120. loadingUIText: string;
  82121. }
  82122. /**
  82123. * Class used for the default loading screen
  82124. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82125. */
  82126. export class DefaultLoadingScreen implements ILoadingScreen {
  82127. private _renderingCanvas;
  82128. private _loadingText;
  82129. private _loadingDivBackgroundColor;
  82130. private _loadingDiv;
  82131. private _loadingTextDiv;
  82132. /**
  82133. * Creates a new default loading screen
  82134. * @param _renderingCanvas defines the canvas used to render the scene
  82135. * @param _loadingText defines the default text to display
  82136. * @param _loadingDivBackgroundColor defines the default background color
  82137. */
  82138. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82139. /**
  82140. * Function called to display the loading screen
  82141. */
  82142. displayLoadingUI(): void;
  82143. /**
  82144. * Function called to hide the loading screen
  82145. */
  82146. hideLoadingUI(): void;
  82147. /**
  82148. * Gets or sets the text to display while loading
  82149. */
  82150. loadingUIText: string;
  82151. /**
  82152. * Gets or sets the color to use for the background
  82153. */
  82154. loadingUIBackgroundColor: string;
  82155. private _resizeLoadingUI;
  82156. }
  82157. }
  82158. declare module BABYLON {
  82159. /**
  82160. * Settings for finer control over video usage
  82161. */
  82162. export interface VideoTextureSettings {
  82163. /**
  82164. * Applies `autoplay` to video, if specified
  82165. */
  82166. autoPlay?: boolean;
  82167. /**
  82168. * Applies `loop` to video, if specified
  82169. */
  82170. loop?: boolean;
  82171. /**
  82172. * Automatically updates internal texture from video at every frame in the render loop
  82173. */
  82174. autoUpdateTexture: boolean;
  82175. /**
  82176. * Image src displayed during the video loading or until the user interacts with the video.
  82177. */
  82178. poster?: string;
  82179. }
  82180. /**
  82181. * If you want to display a video in your scene, this is the special texture for that.
  82182. * This special texture works similar to other textures, with the exception of a few parameters.
  82183. * @see https://doc.babylonjs.com/how_to/video_texture
  82184. */
  82185. export class VideoTexture extends Texture {
  82186. /**
  82187. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82188. */
  82189. readonly autoUpdateTexture: boolean;
  82190. /**
  82191. * The video instance used by the texture internally
  82192. */
  82193. readonly video: HTMLVideoElement;
  82194. private _onUserActionRequestedObservable;
  82195. /**
  82196. * Event triggerd when a dom action is required by the user to play the video.
  82197. * This happens due to recent changes in browser policies preventing video to auto start.
  82198. */
  82199. readonly onUserActionRequestedObservable: Observable<Texture>;
  82200. private _generateMipMaps;
  82201. private _engine;
  82202. private _stillImageCaptured;
  82203. private _displayingPosterTexture;
  82204. private _settings;
  82205. private _createInternalTextureOnEvent;
  82206. /**
  82207. * Creates a video texture.
  82208. * If you want to display a video in your scene, this is the special texture for that.
  82209. * This special texture works similar to other textures, with the exception of a few parameters.
  82210. * @see https://doc.babylonjs.com/how_to/video_texture
  82211. * @param name optional name, will detect from video source, if not defined
  82212. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82213. * @param scene is obviously the current scene.
  82214. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82215. * @param invertY is false by default but can be used to invert video on Y axis
  82216. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82217. * @param settings allows finer control over video usage
  82218. */
  82219. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82220. private _getName;
  82221. private _getVideo;
  82222. private _createInternalTexture;
  82223. private reset;
  82224. /**
  82225. * @hidden Internal method to initiate `update`.
  82226. */
  82227. _rebuild(): void;
  82228. /**
  82229. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82230. */
  82231. update(): void;
  82232. /**
  82233. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82234. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82235. */
  82236. updateTexture(isVisible: boolean): void;
  82237. protected _updateInternalTexture: () => void;
  82238. /**
  82239. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82240. * @param url New url.
  82241. */
  82242. updateURL(url: string): void;
  82243. /**
  82244. * Dispose the texture and release its associated resources.
  82245. */
  82246. dispose(): void;
  82247. /**
  82248. * Creates a video texture straight from your WebCam video feed.
  82249. * @param scene Define the scene the texture should be created in
  82250. * @param onReady Define a callback to triggered once the texture will be ready
  82251. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82252. */
  82253. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82254. minWidth: number;
  82255. maxWidth: number;
  82256. minHeight: number;
  82257. maxHeight: number;
  82258. deviceId: string;
  82259. }): void;
  82260. }
  82261. }
  82262. declare module BABYLON {
  82263. /**
  82264. * Interface for attribute information associated with buffer instanciation
  82265. */
  82266. export class InstancingAttributeInfo {
  82267. /**
  82268. * Index/offset of the attribute in the vertex shader
  82269. */
  82270. index: number;
  82271. /**
  82272. * size of the attribute, 1, 2, 3 or 4
  82273. */
  82274. attributeSize: number;
  82275. /**
  82276. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82277. * default is FLOAT
  82278. */
  82279. attribyteType: number;
  82280. /**
  82281. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82282. */
  82283. normalized: boolean;
  82284. /**
  82285. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82286. */
  82287. offset: number;
  82288. /**
  82289. * Name of the GLSL attribute, for debugging purpose only
  82290. */
  82291. attributeName: string;
  82292. }
  82293. /**
  82294. * Define options used to create a depth texture
  82295. */
  82296. export class DepthTextureCreationOptions {
  82297. /** Specifies whether or not a stencil should be allocated in the texture */
  82298. generateStencil?: boolean;
  82299. /** Specifies whether or not bilinear filtering is enable on the texture */
  82300. bilinearFiltering?: boolean;
  82301. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82302. comparisonFunction?: number;
  82303. /** Specifies if the created texture is a cube texture */
  82304. isCube?: boolean;
  82305. }
  82306. /**
  82307. * Class used to describe the capabilities of the engine relatively to the current browser
  82308. */
  82309. export class EngineCapabilities {
  82310. /** Maximum textures units per fragment shader */
  82311. maxTexturesImageUnits: number;
  82312. /** Maximum texture units per vertex shader */
  82313. maxVertexTextureImageUnits: number;
  82314. /** Maximum textures units in the entire pipeline */
  82315. maxCombinedTexturesImageUnits: number;
  82316. /** Maximum texture size */
  82317. maxTextureSize: number;
  82318. /** Maximum cube texture size */
  82319. maxCubemapTextureSize: number;
  82320. /** Maximum render texture size */
  82321. maxRenderTextureSize: number;
  82322. /** Maximum number of vertex attributes */
  82323. maxVertexAttribs: number;
  82324. /** Maximum number of varyings */
  82325. maxVaryingVectors: number;
  82326. /** Maximum number of uniforms per vertex shader */
  82327. maxVertexUniformVectors: number;
  82328. /** Maximum number of uniforms per fragment shader */
  82329. maxFragmentUniformVectors: number;
  82330. /** Defines if standard derivates (dx/dy) are supported */
  82331. standardDerivatives: boolean;
  82332. /** Defines if s3tc texture compression is supported */
  82333. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82334. /** Defines if pvrtc texture compression is supported */
  82335. pvrtc: any;
  82336. /** Defines if etc1 texture compression is supported */
  82337. etc1: any;
  82338. /** Defines if etc2 texture compression is supported */
  82339. etc2: any;
  82340. /** Defines if astc texture compression is supported */
  82341. astc: any;
  82342. /** Defines if float textures are supported */
  82343. textureFloat: boolean;
  82344. /** Defines if vertex array objects are supported */
  82345. vertexArrayObject: boolean;
  82346. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82347. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82348. /** Gets the maximum level of anisotropy supported */
  82349. maxAnisotropy: number;
  82350. /** Defines if instancing is supported */
  82351. instancedArrays: boolean;
  82352. /** Defines if 32 bits indices are supported */
  82353. uintIndices: boolean;
  82354. /** Defines if high precision shaders are supported */
  82355. highPrecisionShaderSupported: boolean;
  82356. /** Defines if depth reading in the fragment shader is supported */
  82357. fragmentDepthSupported: boolean;
  82358. /** Defines if float texture linear filtering is supported*/
  82359. textureFloatLinearFiltering: boolean;
  82360. /** Defines if rendering to float textures is supported */
  82361. textureFloatRender: boolean;
  82362. /** Defines if half float textures are supported*/
  82363. textureHalfFloat: boolean;
  82364. /** Defines if half float texture linear filtering is supported*/
  82365. textureHalfFloatLinearFiltering: boolean;
  82366. /** Defines if rendering to half float textures is supported */
  82367. textureHalfFloatRender: boolean;
  82368. /** Defines if textureLOD shader command is supported */
  82369. textureLOD: boolean;
  82370. /** Defines if draw buffers extension is supported */
  82371. drawBuffersExtension: boolean;
  82372. /** Defines if depth textures are supported */
  82373. depthTextureExtension: boolean;
  82374. /** Defines if float color buffer are supported */
  82375. colorBufferFloat: boolean;
  82376. /** Gets disjoint timer query extension (null if not supported) */
  82377. timerQuery: EXT_disjoint_timer_query;
  82378. /** Defines if timestamp can be used with timer query */
  82379. canUseTimestampForTimerQuery: boolean;
  82380. /** Function used to let the system compiles shaders in background */
  82381. parallelShaderCompile: {
  82382. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82383. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82384. COMPLETION_STATUS_KHR: number;
  82385. };
  82386. }
  82387. /** Interface defining initialization parameters for Engine class */
  82388. export interface EngineOptions extends WebGLContextAttributes {
  82389. /**
  82390. * Defines if the engine should no exceed a specified device ratio
  82391. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82392. */
  82393. limitDeviceRatio?: number;
  82394. /**
  82395. * Defines if webvr should be enabled automatically
  82396. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82397. */
  82398. autoEnableWebVR?: boolean;
  82399. /**
  82400. * Defines if webgl2 should be turned off even if supported
  82401. * @see http://doc.babylonjs.com/features/webgl2
  82402. */
  82403. disableWebGL2Support?: boolean;
  82404. /**
  82405. * Defines if webaudio should be initialized as well
  82406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82407. */
  82408. audioEngine?: boolean;
  82409. /**
  82410. * Defines if animations should run using a deterministic lock step
  82411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82412. */
  82413. deterministicLockstep?: boolean;
  82414. /** Defines the maximum steps to use with deterministic lock step mode */
  82415. lockstepMaxSteps?: number;
  82416. /**
  82417. * Defines that engine should ignore context lost events
  82418. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82419. */
  82420. doNotHandleContextLost?: boolean;
  82421. /**
  82422. * Defines that engine should ignore modifying touch action attribute and style
  82423. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82424. */
  82425. doNotHandleTouchAction?: boolean;
  82426. }
  82427. /**
  82428. * Defines the interface used by display changed events
  82429. */
  82430. export interface IDisplayChangedEventArgs {
  82431. /** Gets the vrDisplay object (if any) */
  82432. vrDisplay: Nullable<any>;
  82433. /** Gets a boolean indicating if webVR is supported */
  82434. vrSupported: boolean;
  82435. }
  82436. /**
  82437. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82438. */
  82439. export class Engine {
  82440. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82441. static ExceptionList: ({
  82442. key: string;
  82443. capture: string;
  82444. captureConstraint: number;
  82445. targets: string[];
  82446. } | {
  82447. key: string;
  82448. capture: null;
  82449. captureConstraint: null;
  82450. targets: string[];
  82451. })[];
  82452. /** Gets the list of created engines */
  82453. static readonly Instances: Engine[];
  82454. /**
  82455. * Gets the latest created engine
  82456. */
  82457. static readonly LastCreatedEngine: Nullable<Engine>;
  82458. /**
  82459. * Gets the latest created scene
  82460. */
  82461. static readonly LastCreatedScene: Nullable<Scene>;
  82462. /**
  82463. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82464. * @param flag defines which part of the materials must be marked as dirty
  82465. * @param predicate defines a predicate used to filter which materials should be affected
  82466. */
  82467. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82468. /**
  82469. * Hidden
  82470. */
  82471. static _TextureLoaders: IInternalTextureLoader[];
  82472. /** Defines that alpha blending is disabled */
  82473. static readonly ALPHA_DISABLE: number;
  82474. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82475. static readonly ALPHA_ADD: number;
  82476. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82477. static readonly ALPHA_COMBINE: number;
  82478. /** Defines that alpha blending to DEST - SRC * DEST */
  82479. static readonly ALPHA_SUBTRACT: number;
  82480. /** Defines that alpha blending to SRC * DEST */
  82481. static readonly ALPHA_MULTIPLY: number;
  82482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  82483. static readonly ALPHA_MAXIMIZED: number;
  82484. /** Defines that alpha blending to SRC + DEST */
  82485. static readonly ALPHA_ONEONE: number;
  82486. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  82487. static readonly ALPHA_PREMULTIPLIED: number;
  82488. /**
  82489. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  82490. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82491. */
  82492. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82493. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  82494. static readonly ALPHA_INTERPOLATE: number;
  82495. /**
  82496. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  82497. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82498. */
  82499. static readonly ALPHA_SCREENMODE: number;
  82500. /** Defines that the ressource is not delayed*/
  82501. static readonly DELAYLOADSTATE_NONE: number;
  82502. /** Defines that the ressource was successfully delay loaded */
  82503. static readonly DELAYLOADSTATE_LOADED: number;
  82504. /** Defines that the ressource is currently delay loading */
  82505. static readonly DELAYLOADSTATE_LOADING: number;
  82506. /** Defines that the ressource is delayed and has not started loading */
  82507. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82509. static readonly NEVER: number;
  82510. /** 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 */
  82511. static readonly ALWAYS: number;
  82512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82513. static readonly LESS: number;
  82514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82515. static readonly EQUAL: number;
  82516. /** 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 */
  82517. static readonly LEQUAL: number;
  82518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82519. static readonly GREATER: number;
  82520. /** 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 */
  82521. static readonly GEQUAL: number;
  82522. /** 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 */
  82523. static readonly NOTEQUAL: number;
  82524. /** Passed to stencilOperation to specify that stencil value must be kept */
  82525. static readonly KEEP: number;
  82526. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82527. static readonly REPLACE: number;
  82528. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82529. static readonly INCR: number;
  82530. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82531. static readonly DECR: number;
  82532. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82533. static readonly INVERT: number;
  82534. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82535. static readonly INCR_WRAP: number;
  82536. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82537. static readonly DECR_WRAP: number;
  82538. /** Texture is not repeating outside of 0..1 UVs */
  82539. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82540. /** Texture is repeating outside of 0..1 UVs */
  82541. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82542. /** Texture is repeating and mirrored */
  82543. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82544. /** ALPHA */
  82545. static readonly TEXTUREFORMAT_ALPHA: number;
  82546. /** LUMINANCE */
  82547. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82548. /** LUMINANCE_ALPHA */
  82549. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82550. /** RGB */
  82551. static readonly TEXTUREFORMAT_RGB: number;
  82552. /** RGBA */
  82553. static readonly TEXTUREFORMAT_RGBA: number;
  82554. /** RED */
  82555. static readonly TEXTUREFORMAT_RED: number;
  82556. /** RED (2nd reference) */
  82557. static readonly TEXTUREFORMAT_R: number;
  82558. /** RG */
  82559. static readonly TEXTUREFORMAT_RG: number;
  82560. /** RED_INTEGER */
  82561. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82562. /** RED_INTEGER (2nd reference) */
  82563. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82564. /** RG_INTEGER */
  82565. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82566. /** RGB_INTEGER */
  82567. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82568. /** RGBA_INTEGER */
  82569. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82570. /** UNSIGNED_BYTE */
  82571. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82572. /** UNSIGNED_BYTE (2nd reference) */
  82573. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82574. /** FLOAT */
  82575. static readonly TEXTURETYPE_FLOAT: number;
  82576. /** HALF_FLOAT */
  82577. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82578. /** BYTE */
  82579. static readonly TEXTURETYPE_BYTE: number;
  82580. /** SHORT */
  82581. static readonly TEXTURETYPE_SHORT: number;
  82582. /** UNSIGNED_SHORT */
  82583. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82584. /** INT */
  82585. static readonly TEXTURETYPE_INT: number;
  82586. /** UNSIGNED_INT */
  82587. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82588. /** UNSIGNED_SHORT_4_4_4_4 */
  82589. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82590. /** UNSIGNED_SHORT_5_5_5_1 */
  82591. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82592. /** UNSIGNED_SHORT_5_6_5 */
  82593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82594. /** UNSIGNED_INT_2_10_10_10_REV */
  82595. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82596. /** UNSIGNED_INT_24_8 */
  82597. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82598. /** UNSIGNED_INT_10F_11F_11F_REV */
  82599. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82600. /** UNSIGNED_INT_5_9_9_9_REV */
  82601. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82602. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82603. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82604. /** nearest is mag = nearest and min = nearest and mip = linear */
  82605. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82606. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82607. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82608. /** Trilinear is mag = linear and min = linear and mip = linear */
  82609. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82610. /** nearest is mag = nearest and min = nearest and mip = linear */
  82611. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82613. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82614. /** Trilinear is mag = linear and min = linear and mip = linear */
  82615. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82616. /** mag = nearest and min = nearest and mip = nearest */
  82617. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82618. /** mag = nearest and min = linear and mip = nearest */
  82619. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82620. /** mag = nearest and min = linear and mip = linear */
  82621. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82622. /** mag = nearest and min = linear and mip = none */
  82623. static readonly TEXTURE_NEAREST_LINEAR: number;
  82624. /** mag = nearest and min = nearest and mip = none */
  82625. static readonly TEXTURE_NEAREST_NEAREST: number;
  82626. /** mag = linear and min = nearest and mip = nearest */
  82627. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82628. /** mag = linear and min = nearest and mip = linear */
  82629. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82630. /** mag = linear and min = linear and mip = none */
  82631. static readonly TEXTURE_LINEAR_LINEAR: number;
  82632. /** mag = linear and min = nearest and mip = none */
  82633. static readonly TEXTURE_LINEAR_NEAREST: number;
  82634. /** Explicit coordinates mode */
  82635. static readonly TEXTURE_EXPLICIT_MODE: number;
  82636. /** Spherical coordinates mode */
  82637. static readonly TEXTURE_SPHERICAL_MODE: number;
  82638. /** Planar coordinates mode */
  82639. static readonly TEXTURE_PLANAR_MODE: number;
  82640. /** Cubic coordinates mode */
  82641. static readonly TEXTURE_CUBIC_MODE: number;
  82642. /** Projection coordinates mode */
  82643. static readonly TEXTURE_PROJECTION_MODE: number;
  82644. /** Skybox coordinates mode */
  82645. static readonly TEXTURE_SKYBOX_MODE: number;
  82646. /** Inverse Cubic coordinates mode */
  82647. static readonly TEXTURE_INVCUBIC_MODE: number;
  82648. /** Equirectangular coordinates mode */
  82649. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82650. /** Equirectangular Fixed coordinates mode */
  82651. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82652. /** Equirectangular Fixed Mirrored coordinates mode */
  82653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82654. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82655. static readonly SCALEMODE_FLOOR: number;
  82656. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82657. static readonly SCALEMODE_NEAREST: number;
  82658. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82659. static readonly SCALEMODE_CEILING: number;
  82660. /**
  82661. * Returns the current version of the framework
  82662. */
  82663. static readonly Version: string;
  82664. /**
  82665. * Returns a string describing the current engine
  82666. */
  82667. readonly description: string;
  82668. /**
  82669. * Gets or sets the epsilon value used by collision engine
  82670. */
  82671. static CollisionsEpsilon: number;
  82672. /**
  82673. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  82674. */
  82675. static ShadersRepository: string;
  82676. /**
  82677. * Method called to create the default loading screen.
  82678. * This can be overriden in your own app.
  82679. * @param canvas The rendering canvas element
  82680. * @returns The loading screen
  82681. */
  82682. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  82683. /**
  82684. * Method called to create the default rescale post process on each engine.
  82685. */
  82686. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  82687. /**
  82688. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  82689. */
  82690. forcePOTTextures: boolean;
  82691. /**
  82692. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  82693. */
  82694. isFullscreen: boolean;
  82695. /**
  82696. * Gets a boolean indicating if the pointer is currently locked
  82697. */
  82698. isPointerLock: boolean;
  82699. /**
  82700. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  82701. */
  82702. cullBackFaces: boolean;
  82703. /**
  82704. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  82705. */
  82706. renderEvenInBackground: boolean;
  82707. /**
  82708. * Gets or sets a boolean indicating that cache can be kept between frames
  82709. */
  82710. preventCacheWipeBetweenFrames: boolean;
  82711. /**
  82712. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  82713. **/
  82714. enableOfflineSupport: boolean;
  82715. /**
  82716. * 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)
  82717. **/
  82718. disableManifestCheck: boolean;
  82719. /**
  82720. * Gets the list of created scenes
  82721. */
  82722. scenes: Scene[];
  82723. /**
  82724. * Event raised when a new scene is created
  82725. */
  82726. onNewSceneAddedObservable: Observable<Scene>;
  82727. /**
  82728. * Gets the list of created postprocesses
  82729. */
  82730. postProcesses: PostProcess[];
  82731. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  82732. validateShaderPrograms: boolean;
  82733. /**
  82734. * Observable event triggered each time the rendering canvas is resized
  82735. */
  82736. onResizeObservable: Observable<Engine>;
  82737. /**
  82738. * Observable event triggered each time the canvas loses focus
  82739. */
  82740. onCanvasBlurObservable: Observable<Engine>;
  82741. /**
  82742. * Observable event triggered each time the canvas gains focus
  82743. */
  82744. onCanvasFocusObservable: Observable<Engine>;
  82745. /**
  82746. * Observable event triggered each time the canvas receives pointerout event
  82747. */
  82748. onCanvasPointerOutObservable: Observable<PointerEvent>;
  82749. /**
  82750. * Observable event triggered before each texture is initialized
  82751. */
  82752. onBeforeTextureInitObservable: Observable<Texture>;
  82753. private _vrDisplay;
  82754. private _vrSupported;
  82755. private _oldSize;
  82756. private _oldHardwareScaleFactor;
  82757. private _vrExclusivePointerMode;
  82758. private _webVRInitPromise;
  82759. /**
  82760. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82761. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82762. */
  82763. readonly isInVRExclusivePointerMode: boolean;
  82764. /**
  82765. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  82766. */
  82767. disableUniformBuffers: boolean;
  82768. /** @hidden */
  82769. _uniformBuffers: UniformBuffer[];
  82770. /**
  82771. * Gets a boolean indicating that the engine supports uniform buffers
  82772. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82773. */
  82774. readonly supportsUniformBuffers: boolean;
  82775. /**
  82776. * Observable raised when the engine begins a new frame
  82777. */
  82778. onBeginFrameObservable: Observable<Engine>;
  82779. /**
  82780. * If set, will be used to request the next animation frame for the render loop
  82781. */
  82782. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  82783. /**
  82784. * Observable raised when the engine ends the current frame
  82785. */
  82786. onEndFrameObservable: Observable<Engine>;
  82787. /**
  82788. * Observable raised when the engine is about to compile a shader
  82789. */
  82790. onBeforeShaderCompilationObservable: Observable<Engine>;
  82791. /**
  82792. * Observable raised when the engine has jsut compiled a shader
  82793. */
  82794. onAfterShaderCompilationObservable: Observable<Engine>;
  82795. /** @hidden */
  82796. _gl: WebGLRenderingContext;
  82797. private _renderingCanvas;
  82798. private _windowIsBackground;
  82799. private _webGLVersion;
  82800. /**
  82801. * Gets a boolean indicating that only power of 2 textures are supported
  82802. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  82803. */
  82804. readonly needPOTTextures: boolean;
  82805. /** @hidden */
  82806. _badOS: boolean;
  82807. /** @hidden */
  82808. _badDesktopOS: boolean;
  82809. /**
  82810. * Gets or sets a value indicating if we want to disable texture binding optimization.
  82811. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  82812. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  82813. */
  82814. disableTextureBindingOptimization: boolean;
  82815. /**
  82816. * Gets the audio engine
  82817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82818. * @ignorenaming
  82819. */
  82820. static audioEngine: IAudioEngine;
  82821. /**
  82822. * Default AudioEngine factory responsible of creating the Audio Engine.
  82823. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  82824. */
  82825. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  82826. /**
  82827. * Default offline support factory responsible of creating a tool used to store data locally.
  82828. * By default, this will create a Database object if the workload has been embedded.
  82829. */
  82830. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  82831. private _onFocus;
  82832. private _onBlur;
  82833. private _onCanvasPointerOut;
  82834. private _onCanvasBlur;
  82835. private _onCanvasFocus;
  82836. private _onFullscreenChange;
  82837. private _onPointerLockChange;
  82838. private _onVRDisplayPointerRestricted;
  82839. private _onVRDisplayPointerUnrestricted;
  82840. private _onVrDisplayConnect;
  82841. private _onVrDisplayDisconnect;
  82842. private _onVrDisplayPresentChange;
  82843. /**
  82844. * Observable signaled when VR display mode changes
  82845. */
  82846. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82847. /**
  82848. * Observable signaled when VR request present is complete
  82849. */
  82850. onVRRequestPresentComplete: Observable<boolean>;
  82851. /**
  82852. * Observable signaled when VR request present starts
  82853. */
  82854. onVRRequestPresentStart: Observable<Engine>;
  82855. private _hardwareScalingLevel;
  82856. /** @hidden */
  82857. protected _caps: EngineCapabilities;
  82858. private _pointerLockRequested;
  82859. private _isStencilEnable;
  82860. private _colorWrite;
  82861. private _loadingScreen;
  82862. /** @hidden */
  82863. _drawCalls: PerfCounter;
  82864. /** @hidden */
  82865. _textureCollisions: PerfCounter;
  82866. private _glVersion;
  82867. private _glRenderer;
  82868. private _glVendor;
  82869. private _videoTextureSupported;
  82870. private _renderingQueueLaunched;
  82871. private _activeRenderLoops;
  82872. private _deterministicLockstep;
  82873. private _lockstepMaxSteps;
  82874. /**
  82875. * Observable signaled when a context lost event is raised
  82876. */
  82877. onContextLostObservable: Observable<Engine>;
  82878. /**
  82879. * Observable signaled when a context restored event is raised
  82880. */
  82881. onContextRestoredObservable: Observable<Engine>;
  82882. private _onContextLost;
  82883. private _onContextRestored;
  82884. private _contextWasLost;
  82885. private _doNotHandleContextLost;
  82886. /**
  82887. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  82888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  82889. */
  82890. doNotHandleContextLost: boolean;
  82891. private _performanceMonitor;
  82892. private _fps;
  82893. private _deltaTime;
  82894. /**
  82895. * Turn this value on if you want to pause FPS computation when in background
  82896. */
  82897. disablePerformanceMonitorInBackground: boolean;
  82898. /**
  82899. * Gets the performance monitor attached to this engine
  82900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  82901. */
  82902. readonly performanceMonitor: PerformanceMonitor;
  82903. /** @hidden */
  82904. protected _depthCullingState: _DepthCullingState;
  82905. /** @hidden */
  82906. protected _stencilState: _StencilState;
  82907. /** @hidden */
  82908. protected _alphaState: _AlphaState;
  82909. /** @hidden */
  82910. protected _alphaMode: number;
  82911. protected _internalTexturesCache: InternalTexture[];
  82912. /** @hidden */
  82913. protected _activeChannel: number;
  82914. private _currentTextureChannel;
  82915. /** @hidden */
  82916. protected _boundTexturesCache: {
  82917. [key: string]: Nullable<InternalTexture>;
  82918. };
  82919. /** @hidden */
  82920. protected _currentEffect: Nullable<Effect>;
  82921. /** @hidden */
  82922. protected _currentProgram: Nullable<WebGLProgram>;
  82923. private _compiledEffects;
  82924. private _vertexAttribArraysEnabled;
  82925. /** @hidden */
  82926. protected _cachedViewport: Nullable<Viewport>;
  82927. private _cachedVertexArrayObject;
  82928. /** @hidden */
  82929. protected _cachedVertexBuffers: any;
  82930. /** @hidden */
  82931. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  82932. /** @hidden */
  82933. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  82934. /** @hidden */
  82935. protected _currentRenderTarget: Nullable<InternalTexture>;
  82936. private _uintIndicesCurrentlySet;
  82937. private _currentBoundBuffer;
  82938. /** @hidden */
  82939. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  82940. private _currentBufferPointers;
  82941. private _currentInstanceLocations;
  82942. private _currentInstanceBuffers;
  82943. private _textureUnits;
  82944. private _firstBoundInternalTextureTracker;
  82945. private _lastBoundInternalTextureTracker;
  82946. private _workingCanvas;
  82947. private _workingContext;
  82948. private _rescalePostProcess;
  82949. private _dummyFramebuffer;
  82950. private _externalData;
  82951. private _bindedRenderFunction;
  82952. private _vaoRecordInProgress;
  82953. private _mustWipeVertexAttributes;
  82954. private _emptyTexture;
  82955. private _emptyCubeTexture;
  82956. private _emptyTexture3D;
  82957. /** @hidden */
  82958. _frameHandler: number;
  82959. private _nextFreeTextureSlots;
  82960. private _maxSimultaneousTextures;
  82961. private _activeRequests;
  82962. private _texturesSupported;
  82963. private _textureFormatInUse;
  82964. /**
  82965. * Gets the list of texture formats supported
  82966. */
  82967. readonly texturesSupported: Array<string>;
  82968. /**
  82969. * Gets the list of texture formats in use
  82970. */
  82971. readonly textureFormatInUse: Nullable<string>;
  82972. /**
  82973. * Gets the current viewport
  82974. */
  82975. readonly currentViewport: Nullable<Viewport>;
  82976. /**
  82977. * Gets the default empty texture
  82978. */
  82979. readonly emptyTexture: InternalTexture;
  82980. /**
  82981. * Gets the default empty 3D texture
  82982. */
  82983. readonly emptyTexture3D: InternalTexture;
  82984. /**
  82985. * Gets the default empty cube texture
  82986. */
  82987. readonly emptyCubeTexture: InternalTexture;
  82988. /**
  82989. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  82990. */
  82991. readonly premultipliedAlpha: boolean;
  82992. /**
  82993. * Creates a new engine
  82994. * @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
  82995. * @param antialias defines enable antialiasing (default: false)
  82996. * @param options defines further options to be sent to the getContext() function
  82997. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  82998. */
  82999. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83000. private _disableTouchAction;
  83001. private _rebuildInternalTextures;
  83002. private _rebuildEffects;
  83003. /**
  83004. * Gets a boolean indicating if all created effects are ready
  83005. * @returns true if all effects are ready
  83006. */
  83007. areAllEffectsReady(): boolean;
  83008. private _rebuildBuffers;
  83009. private _initGLContext;
  83010. /**
  83011. * Gets version of the current webGL context
  83012. */
  83013. readonly webGLVersion: number;
  83014. /**
  83015. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83016. */
  83017. readonly isStencilEnable: boolean;
  83018. private _prepareWorkingCanvas;
  83019. /**
  83020. * Reset the texture cache to empty state
  83021. */
  83022. resetTextureCache(): void;
  83023. /**
  83024. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83026. * @returns true if engine is in deterministic lock step mode
  83027. */
  83028. isDeterministicLockStep(): boolean;
  83029. /**
  83030. * Gets the max steps when engine is running in deterministic lock step
  83031. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83032. * @returns the max steps
  83033. */
  83034. getLockstepMaxSteps(): number;
  83035. /**
  83036. * Gets an object containing information about the current webGL context
  83037. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83038. */
  83039. getGlInfo(): {
  83040. vendor: string;
  83041. renderer: string;
  83042. version: string;
  83043. };
  83044. /**
  83045. * Gets current aspect ratio
  83046. * @param camera defines the camera to use to get the aspect ratio
  83047. * @param useScreen defines if screen size must be used (or the current render target if any)
  83048. * @returns a number defining the aspect ratio
  83049. */
  83050. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83051. /**
  83052. * Gets current screen aspect ratio
  83053. * @returns a number defining the aspect ratio
  83054. */
  83055. getScreenAspectRatio(): number;
  83056. /**
  83057. * Gets the current render width
  83058. * @param useScreen defines if screen size must be used (or the current render target if any)
  83059. * @returns a number defining the current render width
  83060. */
  83061. getRenderWidth(useScreen?: boolean): number;
  83062. /**
  83063. * Gets the current render height
  83064. * @param useScreen defines if screen size must be used (or the current render target if any)
  83065. * @returns a number defining the current render height
  83066. */
  83067. getRenderHeight(useScreen?: boolean): number;
  83068. /**
  83069. * Gets the HTML canvas attached with the current webGL context
  83070. * @returns a HTML canvas
  83071. */
  83072. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83073. /**
  83074. * Gets the client rect of the HTML canvas attached with the current webGL context
  83075. * @returns a client rectanglee
  83076. */
  83077. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83078. /**
  83079. * Defines the hardware scaling level.
  83080. * By default the hardware scaling level is computed from the window device ratio.
  83081. * 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.
  83082. * @param level defines the level to use
  83083. */
  83084. setHardwareScalingLevel(level: number): void;
  83085. /**
  83086. * Gets the current hardware scaling level.
  83087. * By default the hardware scaling level is computed from the window device ratio.
  83088. * 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.
  83089. * @returns a number indicating the current hardware scaling level
  83090. */
  83091. getHardwareScalingLevel(): number;
  83092. /**
  83093. * Gets the list of loaded textures
  83094. * @returns an array containing all loaded textures
  83095. */
  83096. getLoadedTexturesCache(): InternalTexture[];
  83097. /**
  83098. * Gets the object containing all engine capabilities
  83099. * @returns the EngineCapabilities object
  83100. */
  83101. getCaps(): EngineCapabilities;
  83102. /**
  83103. * Gets the current depth function
  83104. * @returns a number defining the depth function
  83105. */
  83106. getDepthFunction(): Nullable<number>;
  83107. /**
  83108. * Sets the current depth function
  83109. * @param depthFunc defines the function to use
  83110. */
  83111. setDepthFunction(depthFunc: number): void;
  83112. /**
  83113. * Sets the current depth function to GREATER
  83114. */
  83115. setDepthFunctionToGreater(): void;
  83116. /**
  83117. * Sets the current depth function to GEQUAL
  83118. */
  83119. setDepthFunctionToGreaterOrEqual(): void;
  83120. /**
  83121. * Sets the current depth function to LESS
  83122. */
  83123. setDepthFunctionToLess(): void;
  83124. /**
  83125. * Sets the current depth function to LEQUAL
  83126. */
  83127. setDepthFunctionToLessOrEqual(): void;
  83128. /**
  83129. * Gets a boolean indicating if stencil buffer is enabled
  83130. * @returns the current stencil buffer state
  83131. */
  83132. getStencilBuffer(): boolean;
  83133. /**
  83134. * Enable or disable the stencil buffer
  83135. * @param enable defines if the stencil buffer must be enabled or disabled
  83136. */
  83137. setStencilBuffer(enable: boolean): void;
  83138. /**
  83139. * Gets the current stencil mask
  83140. * @returns a number defining the new stencil mask to use
  83141. */
  83142. getStencilMask(): number;
  83143. /**
  83144. * Sets the current stencil mask
  83145. * @param mask defines the new stencil mask to use
  83146. */
  83147. setStencilMask(mask: number): void;
  83148. /**
  83149. * Gets the current stencil function
  83150. * @returns a number defining the stencil function to use
  83151. */
  83152. getStencilFunction(): number;
  83153. /**
  83154. * Gets the current stencil reference value
  83155. * @returns a number defining the stencil reference value to use
  83156. */
  83157. getStencilFunctionReference(): number;
  83158. /**
  83159. * Gets the current stencil mask
  83160. * @returns a number defining the stencil mask to use
  83161. */
  83162. getStencilFunctionMask(): number;
  83163. /**
  83164. * Sets the current stencil function
  83165. * @param stencilFunc defines the new stencil function to use
  83166. */
  83167. setStencilFunction(stencilFunc: number): void;
  83168. /**
  83169. * Sets the current stencil reference
  83170. * @param reference defines the new stencil reference to use
  83171. */
  83172. setStencilFunctionReference(reference: number): void;
  83173. /**
  83174. * Sets the current stencil mask
  83175. * @param mask defines the new stencil mask to use
  83176. */
  83177. setStencilFunctionMask(mask: number): void;
  83178. /**
  83179. * Gets the current stencil operation when stencil fails
  83180. * @returns a number defining stencil operation to use when stencil fails
  83181. */
  83182. getStencilOperationFail(): number;
  83183. /**
  83184. * Gets the current stencil operation when depth fails
  83185. * @returns a number defining stencil operation to use when depth fails
  83186. */
  83187. getStencilOperationDepthFail(): number;
  83188. /**
  83189. * Gets the current stencil operation when stencil passes
  83190. * @returns a number defining stencil operation to use when stencil passes
  83191. */
  83192. getStencilOperationPass(): number;
  83193. /**
  83194. * Sets the stencil operation to use when stencil fails
  83195. * @param operation defines the stencil operation to use when stencil fails
  83196. */
  83197. setStencilOperationFail(operation: number): void;
  83198. /**
  83199. * Sets the stencil operation to use when depth fails
  83200. * @param operation defines the stencil operation to use when depth fails
  83201. */
  83202. setStencilOperationDepthFail(operation: number): void;
  83203. /**
  83204. * Sets the stencil operation to use when stencil passes
  83205. * @param operation defines the stencil operation to use when stencil passes
  83206. */
  83207. setStencilOperationPass(operation: number): void;
  83208. /**
  83209. * Sets a boolean indicating if the dithering state is enabled or disabled
  83210. * @param value defines the dithering state
  83211. */
  83212. setDitheringState(value: boolean): void;
  83213. /**
  83214. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83215. * @param value defines the rasterizer state
  83216. */
  83217. setRasterizerState(value: boolean): void;
  83218. /**
  83219. * stop executing a render loop function and remove it from the execution array
  83220. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83221. */
  83222. stopRenderLoop(renderFunction?: () => void): void;
  83223. /** @hidden */
  83224. _renderLoop(): void;
  83225. /**
  83226. * Register and execute a render loop. The engine can have more than one render function
  83227. * @param renderFunction defines the function to continuously execute
  83228. */
  83229. runRenderLoop(renderFunction: () => void): void;
  83230. /**
  83231. * Toggle full screen mode
  83232. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83233. */
  83234. switchFullscreen(requestPointerLock: boolean): void;
  83235. /**
  83236. * Clear the current render buffer or the current render target (if any is set up)
  83237. * @param color defines the color to use
  83238. * @param backBuffer defines if the back buffer must be cleared
  83239. * @param depth defines if the depth buffer must be cleared
  83240. * @param stencil defines if the stencil buffer must be cleared
  83241. */
  83242. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83243. /**
  83244. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83245. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83246. * @param y defines the y-coordinate of the corner of the clear rectangle
  83247. * @param width defines the width of the clear rectangle
  83248. * @param height defines the height of the clear rectangle
  83249. * @param clearColor defines the clear color
  83250. */
  83251. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83252. /**
  83253. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83254. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83255. * @param y defines the y-coordinate of the corner of the clear rectangle
  83256. * @param width defines the width of the clear rectangle
  83257. * @param height defines the height of the clear rectangle
  83258. */
  83259. enableScissor(x: number, y: number, width: number, height: number): void;
  83260. /**
  83261. * Disable previously set scissor test rectangle
  83262. */
  83263. disableScissor(): void;
  83264. private _viewportCached;
  83265. /** @hidden */
  83266. _viewport(x: number, y: number, width: number, height: number): void;
  83267. /**
  83268. * Set the WebGL's viewport
  83269. * @param viewport defines the viewport element to be used
  83270. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83271. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83272. */
  83273. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83274. /**
  83275. * Directly set the WebGL Viewport
  83276. * @param x defines the x coordinate of the viewport (in screen space)
  83277. * @param y defines the y coordinate of the viewport (in screen space)
  83278. * @param width defines the width of the viewport (in screen space)
  83279. * @param height defines the height of the viewport (in screen space)
  83280. * @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
  83281. */
  83282. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83283. /**
  83284. * Begin a new frame
  83285. */
  83286. beginFrame(): void;
  83287. /**
  83288. * Enf the current frame
  83289. */
  83290. endFrame(): void;
  83291. /**
  83292. * Resize the view according to the canvas' size
  83293. */
  83294. resize(): void;
  83295. /**
  83296. * Force a specific size of the canvas
  83297. * @param width defines the new canvas' width
  83298. * @param height defines the new canvas' height
  83299. */
  83300. setSize(width: number, height: number): void;
  83301. /**
  83302. * Gets a boolean indicating if a webVR device was detected
  83303. * @returns true if a webVR device was detected
  83304. */
  83305. isVRDevicePresent(): boolean;
  83306. /**
  83307. * Gets the current webVR device
  83308. * @returns the current webVR device (or null)
  83309. */
  83310. getVRDevice(): any;
  83311. /**
  83312. * Initializes a webVR display and starts listening to display change events
  83313. * The onVRDisplayChangedObservable will be notified upon these changes
  83314. * @returns The onVRDisplayChangedObservable
  83315. */
  83316. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83317. /**
  83318. * Initializes a webVR display and starts listening to display change events
  83319. * The onVRDisplayChangedObservable will be notified upon these changes
  83320. * @returns A promise containing a VRDisplay and if vr is supported
  83321. */
  83322. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83323. /**
  83324. * Call this function to switch to webVR mode
  83325. * Will do nothing if webVR is not supported or if there is no webVR device
  83326. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83327. */
  83328. enableVR(): void;
  83329. /**
  83330. * Call this function to leave webVR mode
  83331. * Will do nothing if webVR is not supported or if there is no webVR device
  83332. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83333. */
  83334. disableVR(): void;
  83335. private _onVRFullScreenTriggered;
  83336. private _getVRDisplaysAsync;
  83337. /**
  83338. * Binds the frame buffer to the specified texture.
  83339. * @param texture The texture to render to or null for the default canvas
  83340. * @param faceIndex The face of the texture to render to in case of cube texture
  83341. * @param requiredWidth The width of the target to render to
  83342. * @param requiredHeight The height of the target to render to
  83343. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83344. * @param depthStencilTexture The depth stencil texture to use to render
  83345. * @param lodLevel defines le lod level to bind to the frame buffer
  83346. */
  83347. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83348. private bindUnboundFramebuffer;
  83349. /**
  83350. * Unbind the current render target texture from the webGL context
  83351. * @param texture defines the render target texture to unbind
  83352. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83353. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83354. */
  83355. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83356. /**
  83357. * Unbind a list of render target textures from the webGL context
  83358. * This is used only when drawBuffer extension or webGL2 are active
  83359. * @param textures defines the render target textures to unbind
  83360. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83361. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83362. */
  83363. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83364. /**
  83365. * Force the mipmap generation for the given render target texture
  83366. * @param texture defines the render target texture to use
  83367. */
  83368. generateMipMapsForCubemap(texture: InternalTexture): void;
  83369. /**
  83370. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83371. */
  83372. flushFramebuffer(): void;
  83373. /**
  83374. * Unbind the current render target and bind the default framebuffer
  83375. */
  83376. restoreDefaultFramebuffer(): void;
  83377. /**
  83378. * Create an uniform buffer
  83379. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83380. * @param elements defines the content of the uniform buffer
  83381. * @returns the webGL uniform buffer
  83382. */
  83383. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83384. /**
  83385. * Create a dynamic uniform buffer
  83386. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83387. * @param elements defines the content of the uniform buffer
  83388. * @returns the webGL uniform buffer
  83389. */
  83390. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83391. /**
  83392. * Update an existing uniform buffer
  83393. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83394. * @param uniformBuffer defines the target uniform buffer
  83395. * @param elements defines the content to update
  83396. * @param offset defines the offset in the uniform buffer where update should start
  83397. * @param count defines the size of the data to update
  83398. */
  83399. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83400. private _resetVertexBufferBinding;
  83401. /**
  83402. * Creates a vertex buffer
  83403. * @param data the data for the vertex buffer
  83404. * @returns the new WebGL static buffer
  83405. */
  83406. createVertexBuffer(data: DataArray): WebGLBuffer;
  83407. /**
  83408. * Creates a dynamic vertex buffer
  83409. * @param data the data for the dynamic vertex buffer
  83410. * @returns the new WebGL dynamic buffer
  83411. */
  83412. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83413. /**
  83414. * Update a dynamic index buffer
  83415. * @param indexBuffer defines the target index buffer
  83416. * @param indices defines the data to update
  83417. * @param offset defines the offset in the target index buffer where update should start
  83418. */
  83419. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83420. /**
  83421. * Updates a dynamic vertex buffer.
  83422. * @param vertexBuffer the vertex buffer to update
  83423. * @param data the data used to update the vertex buffer
  83424. * @param byteOffset the byte offset of the data
  83425. * @param byteLength the byte length of the data
  83426. */
  83427. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83428. private _resetIndexBufferBinding;
  83429. /**
  83430. * Creates a new index buffer
  83431. * @param indices defines the content of the index buffer
  83432. * @param updatable defines if the index buffer must be updatable
  83433. * @returns a new webGL buffer
  83434. */
  83435. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83436. /**
  83437. * Bind a webGL buffer to the webGL context
  83438. * @param buffer defines the buffer to bind
  83439. */
  83440. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83441. /**
  83442. * Bind an uniform buffer to the current webGL context
  83443. * @param buffer defines the buffer to bind
  83444. */
  83445. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83446. /**
  83447. * Bind a buffer to the current webGL context at a given location
  83448. * @param buffer defines the buffer to bind
  83449. * @param location defines the index where to bind the buffer
  83450. */
  83451. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83452. /**
  83453. * Bind a specific block at a given index in a specific shader program
  83454. * @param shaderProgram defines the shader program
  83455. * @param blockName defines the block name
  83456. * @param index defines the index where to bind the block
  83457. */
  83458. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83459. private bindIndexBuffer;
  83460. private bindBuffer;
  83461. /**
  83462. * update the bound buffer with the given data
  83463. * @param data defines the data to update
  83464. */
  83465. updateArrayBuffer(data: Float32Array): void;
  83466. private _vertexAttribPointer;
  83467. private _bindIndexBufferWithCache;
  83468. private _bindVertexBuffersAttributes;
  83469. /**
  83470. * Records a vertex array object
  83471. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83472. * @param vertexBuffers defines the list of vertex buffers to store
  83473. * @param indexBuffer defines the index buffer to store
  83474. * @param effect defines the effect to store
  83475. * @returns the new vertex array object
  83476. */
  83477. recordVertexArrayObject(vertexBuffers: {
  83478. [key: string]: VertexBuffer;
  83479. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  83480. /**
  83481. * Bind a specific vertex array object
  83482. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83483. * @param vertexArrayObject defines the vertex array object to bind
  83484. * @param indexBuffer defines the index buffer to bind
  83485. */
  83486. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  83487. /**
  83488. * Bind webGl buffers directly to the webGL context
  83489. * @param vertexBuffer defines the vertex buffer to bind
  83490. * @param indexBuffer defines the index buffer to bind
  83491. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  83492. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  83493. * @param effect defines the effect associated with the vertex buffer
  83494. */
  83495. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  83496. private _unbindVertexArrayObject;
  83497. /**
  83498. * Bind a list of vertex buffers to the webGL context
  83499. * @param vertexBuffers defines the list of vertex buffers to bind
  83500. * @param indexBuffer defines the index buffer to bind
  83501. * @param effect defines the effect associated with the vertex buffers
  83502. */
  83503. bindBuffers(vertexBuffers: {
  83504. [key: string]: Nullable<VertexBuffer>;
  83505. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  83506. /**
  83507. * Unbind all instance attributes
  83508. */
  83509. unbindInstanceAttributes(): void;
  83510. /**
  83511. * Release and free the memory of a vertex array object
  83512. * @param vao defines the vertex array object to delete
  83513. */
  83514. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  83515. /** @hidden */
  83516. _releaseBuffer(buffer: WebGLBuffer): boolean;
  83517. /**
  83518. * Creates a webGL buffer to use with instanciation
  83519. * @param capacity defines the size of the buffer
  83520. * @returns the webGL buffer
  83521. */
  83522. createInstancesBuffer(capacity: number): WebGLBuffer;
  83523. /**
  83524. * Delete a webGL buffer used with instanciation
  83525. * @param buffer defines the webGL buffer to delete
  83526. */
  83527. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  83528. /**
  83529. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  83530. * @param instancesBuffer defines the webGL buffer to update and bind
  83531. * @param data defines the data to store in the buffer
  83532. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  83533. */
  83534. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  83535. /**
  83536. * Apply all cached states (depth, culling, stencil and alpha)
  83537. */
  83538. applyStates(): void;
  83539. /**
  83540. * Send a draw order
  83541. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83542. * @param indexStart defines the starting index
  83543. * @param indexCount defines the number of index to draw
  83544. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83545. */
  83546. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  83547. /**
  83548. * Draw a list of points
  83549. * @param verticesStart defines the index of first vertex to draw
  83550. * @param verticesCount defines the count of vertices to draw
  83551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83552. */
  83553. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83554. /**
  83555. * Draw a list of unindexed primitives
  83556. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83557. * @param verticesStart defines the index of first vertex to draw
  83558. * @param verticesCount defines the count of vertices to draw
  83559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83560. */
  83561. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83562. /**
  83563. * Draw a list of indexed primitives
  83564. * @param fillMode defines the primitive to use
  83565. * @param indexStart defines the starting index
  83566. * @param indexCount defines the number of index to draw
  83567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83568. */
  83569. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  83570. /**
  83571. * Draw a list of unindexed primitives
  83572. * @param fillMode defines the primitive to use
  83573. * @param verticesStart defines the index of first vertex to draw
  83574. * @param verticesCount defines the count of vertices to draw
  83575. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83576. */
  83577. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83578. private _drawMode;
  83579. /** @hidden */
  83580. _releaseEffect(effect: Effect): void;
  83581. /** @hidden */
  83582. _deleteProgram(program: WebGLProgram): void;
  83583. /**
  83584. * Create a new effect (used to store vertex/fragment shaders)
  83585. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  83586. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  83587. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  83588. * @param samplers defines an array of string used to represent textures
  83589. * @param defines defines the string containing the defines to use to compile the shaders
  83590. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  83591. * @param onCompiled defines a function to call when the effect creation is successful
  83592. * @param onError defines a function to call when the effect creation has failed
  83593. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  83594. * @returns the new Effect
  83595. */
  83596. 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;
  83597. private _compileShader;
  83598. private _compileRawShader;
  83599. /**
  83600. * Directly creates a webGL program
  83601. * @param vertexCode defines the vertex shader code to use
  83602. * @param fragmentCode defines the fragment shader code to use
  83603. * @param context defines the webGL context to use (if not set, the current one will be used)
  83604. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83605. * @returns the new webGL program
  83606. */
  83607. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83608. /**
  83609. * Creates a webGL program
  83610. * @param vertexCode defines the vertex shader code to use
  83611. * @param fragmentCode defines the fragment shader code to use
  83612. * @param defines defines the string containing the defines to use to compile the shaders
  83613. * @param context defines the webGL context to use (if not set, the current one will be used)
  83614. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83615. * @returns the new webGL program
  83616. */
  83617. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83618. private _createShaderProgram;
  83619. private _finalizeProgram;
  83620. /** @hidden */
  83621. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  83622. /** @hidden */
  83623. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  83624. /**
  83625. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  83626. * @param shaderProgram defines the webGL program to use
  83627. * @param uniformsNames defines the list of uniform names
  83628. * @returns an array of webGL uniform locations
  83629. */
  83630. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  83631. /**
  83632. * Gets the lsit of active attributes for a given webGL program
  83633. * @param shaderProgram defines the webGL program to use
  83634. * @param attributesNames defines the list of attribute names to get
  83635. * @returns an array of indices indicating the offset of each attribute
  83636. */
  83637. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  83638. /**
  83639. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  83640. * @param effect defines the effect to activate
  83641. */
  83642. enableEffect(effect: Nullable<Effect>): void;
  83643. /**
  83644. * Set the value of an uniform to an array of int32
  83645. * @param uniform defines the webGL uniform location where to store the value
  83646. * @param array defines the array of int32 to store
  83647. */
  83648. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83649. /**
  83650. * Set the value of an uniform to an array of int32 (stored as vec2)
  83651. * @param uniform defines the webGL uniform location where to store the value
  83652. * @param array defines the array of int32 to store
  83653. */
  83654. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83655. /**
  83656. * Set the value of an uniform to an array of int32 (stored as vec3)
  83657. * @param uniform defines the webGL uniform location where to store the value
  83658. * @param array defines the array of int32 to store
  83659. */
  83660. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83661. /**
  83662. * Set the value of an uniform to an array of int32 (stored as vec4)
  83663. * @param uniform defines the webGL uniform location where to store the value
  83664. * @param array defines the array of int32 to store
  83665. */
  83666. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83667. /**
  83668. * Set the value of an uniform to an array of float32
  83669. * @param uniform defines the webGL uniform location where to store the value
  83670. * @param array defines the array of float32 to store
  83671. */
  83672. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83673. /**
  83674. * Set the value of an uniform to an array of float32 (stored as vec2)
  83675. * @param uniform defines the webGL uniform location where to store the value
  83676. * @param array defines the array of float32 to store
  83677. */
  83678. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83679. /**
  83680. * Set the value of an uniform to an array of float32 (stored as vec3)
  83681. * @param uniform defines the webGL uniform location where to store the value
  83682. * @param array defines the array of float32 to store
  83683. */
  83684. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83685. /**
  83686. * Set the value of an uniform to an array of float32 (stored as vec4)
  83687. * @param uniform defines the webGL uniform location where to store the value
  83688. * @param array defines the array of float32 to store
  83689. */
  83690. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83691. /**
  83692. * Set the value of an uniform to an array of number
  83693. * @param uniform defines the webGL uniform location where to store the value
  83694. * @param array defines the array of number to store
  83695. */
  83696. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83697. /**
  83698. * Set the value of an uniform to an array of number (stored as vec2)
  83699. * @param uniform defines the webGL uniform location where to store the value
  83700. * @param array defines the array of number to store
  83701. */
  83702. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83703. /**
  83704. * Set the value of an uniform to an array of number (stored as vec3)
  83705. * @param uniform defines the webGL uniform location where to store the value
  83706. * @param array defines the array of number to store
  83707. */
  83708. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83709. /**
  83710. * Set the value of an uniform to an array of number (stored as vec4)
  83711. * @param uniform defines the webGL uniform location where to store the value
  83712. * @param array defines the array of number to store
  83713. */
  83714. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83715. /**
  83716. * Set the value of an uniform to an array of float32 (stored as matrices)
  83717. * @param uniform defines the webGL uniform location where to store the value
  83718. * @param matrices defines the array of float32 to store
  83719. */
  83720. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  83721. /**
  83722. * Set the value of an uniform to a matrix
  83723. * @param uniform defines the webGL uniform location where to store the value
  83724. * @param matrix defines the matrix to store
  83725. */
  83726. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  83727. /**
  83728. * Set the value of an uniform to a matrix (3x3)
  83729. * @param uniform defines the webGL uniform location where to store the value
  83730. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  83731. */
  83732. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83733. /**
  83734. * Set the value of an uniform to a matrix (2x2)
  83735. * @param uniform defines the webGL uniform location where to store the value
  83736. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  83737. */
  83738. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83739. /**
  83740. * Set the value of an uniform to a number (int)
  83741. * @param uniform defines the webGL uniform location where to store the value
  83742. * @param value defines the int number to store
  83743. */
  83744. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83745. /**
  83746. * Set the value of an uniform to a number (float)
  83747. * @param uniform defines the webGL uniform location where to store the value
  83748. * @param value defines the float number to store
  83749. */
  83750. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83751. /**
  83752. * Set the value of an uniform to a vec2
  83753. * @param uniform defines the webGL uniform location where to store the value
  83754. * @param x defines the 1st component of the value
  83755. * @param y defines the 2nd component of the value
  83756. */
  83757. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  83758. /**
  83759. * Set the value of an uniform to a vec3
  83760. * @param uniform defines the webGL uniform location where to store the value
  83761. * @param x defines the 1st component of the value
  83762. * @param y defines the 2nd component of the value
  83763. * @param z defines the 3rd component of the value
  83764. */
  83765. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  83766. /**
  83767. * Set the value of an uniform to a boolean
  83768. * @param uniform defines the webGL uniform location where to store the value
  83769. * @param bool defines the boolean to store
  83770. */
  83771. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  83772. /**
  83773. * Set the value of an uniform to a vec4
  83774. * @param uniform defines the webGL uniform location where to store the value
  83775. * @param x defines the 1st component of the value
  83776. * @param y defines the 2nd component of the value
  83777. * @param z defines the 3rd component of the value
  83778. * @param w defines the 4th component of the value
  83779. */
  83780. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  83781. /**
  83782. * Set the value of an uniform to a Color3
  83783. * @param uniform defines the webGL uniform location where to store the value
  83784. * @param color3 defines the color to store
  83785. */
  83786. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  83787. /**
  83788. * Set the value of an uniform to a Color3 and an alpha value
  83789. * @param uniform defines the webGL uniform location where to store the value
  83790. * @param color3 defines the color to store
  83791. * @param alpha defines the alpha component to store
  83792. */
  83793. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  83794. /**
  83795. * Sets a Color4 on a uniform variable
  83796. * @param uniform defines the uniform location
  83797. * @param color4 defines the value to be set
  83798. */
  83799. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  83800. /**
  83801. * Set various states to the webGL context
  83802. * @param culling defines backface culling state
  83803. * @param zOffset defines the value to apply to zOffset (0 by default)
  83804. * @param force defines if states must be applied even if cache is up to date
  83805. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  83806. */
  83807. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  83808. /**
  83809. * Set the z offset to apply to current rendering
  83810. * @param value defines the offset to apply
  83811. */
  83812. setZOffset(value: number): void;
  83813. /**
  83814. * Gets the current value of the zOffset
  83815. * @returns the current zOffset state
  83816. */
  83817. getZOffset(): number;
  83818. /**
  83819. * Enable or disable depth buffering
  83820. * @param enable defines the state to set
  83821. */
  83822. setDepthBuffer(enable: boolean): void;
  83823. /**
  83824. * Gets a boolean indicating if depth writing is enabled
  83825. * @returns the current depth writing state
  83826. */
  83827. getDepthWrite(): boolean;
  83828. /**
  83829. * Enable or disable depth writing
  83830. * @param enable defines the state to set
  83831. */
  83832. setDepthWrite(enable: boolean): void;
  83833. /**
  83834. * Enable or disable color writing
  83835. * @param enable defines the state to set
  83836. */
  83837. setColorWrite(enable: boolean): void;
  83838. /**
  83839. * Gets a boolean indicating if color writing is enabled
  83840. * @returns the current color writing state
  83841. */
  83842. getColorWrite(): boolean;
  83843. /**
  83844. * Sets alpha constants used by some alpha blending modes
  83845. * @param r defines the red component
  83846. * @param g defines the green component
  83847. * @param b defines the blue component
  83848. * @param a defines the alpha component
  83849. */
  83850. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  83851. /**
  83852. * Sets the current alpha mode
  83853. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  83854. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  83855. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  83856. */
  83857. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  83858. /**
  83859. * Gets the current alpha mode
  83860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  83861. * @returns the current alpha mode
  83862. */
  83863. getAlphaMode(): number;
  83864. /**
  83865. * Clears the list of texture accessible through engine.
  83866. * This can help preventing texture load conflict due to name collision.
  83867. */
  83868. clearInternalTexturesCache(): void;
  83869. /**
  83870. * Force the entire cache to be cleared
  83871. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  83872. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  83873. */
  83874. wipeCaches(bruteForce?: boolean): void;
  83875. /**
  83876. * Set the compressed texture format to use, based on the formats you have, and the formats
  83877. * supported by the hardware / browser.
  83878. *
  83879. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  83880. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  83881. * to API arguments needed to compressed textures. This puts the burden on the container
  83882. * generator to house the arcane code for determining these for current & future formats.
  83883. *
  83884. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  83885. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  83886. *
  83887. * Note: The result of this call is not taken into account when a texture is base64.
  83888. *
  83889. * @param formatsAvailable defines the list of those format families you have created
  83890. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  83891. *
  83892. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  83893. * @returns The extension selected.
  83894. */
  83895. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  83896. private _getSamplingParameters;
  83897. private _partialLoadImg;
  83898. private _cascadeLoadImgs;
  83899. /** @hidden */
  83900. _createTexture(): WebGLTexture;
  83901. /**
  83902. * Usually called from Texture.ts.
  83903. * Passed information to create a WebGLTexture
  83904. * @param urlArg defines a value which contains one of the following:
  83905. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  83906. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  83907. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  83908. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  83909. * @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)
  83910. * @param scene needed for loading to the correct scene
  83911. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  83912. * @param onLoad optional callback to be called upon successful completion
  83913. * @param onError optional callback to be called upon failure
  83914. * @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
  83915. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  83916. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  83917. * @param forcedExtension defines the extension to use to pick the right loader
  83918. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  83919. * @returns a InternalTexture for assignment back into BABYLON.Texture
  83920. */
  83921. 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;
  83922. private _rescaleTexture;
  83923. /**
  83924. * Update a raw texture
  83925. * @param texture defines the texture to update
  83926. * @param data defines the data to store in the texture
  83927. * @param format defines the format of the data
  83928. * @param invertY defines if data must be stored with Y axis inverted
  83929. * @param compression defines the compression used (null by default)
  83930. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83931. */
  83932. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  83933. /**
  83934. * Creates a raw texture
  83935. * @param data defines the data to store in the texture
  83936. * @param width defines the width of the texture
  83937. * @param height defines the height of the texture
  83938. * @param format defines the format of the data
  83939. * @param generateMipMaps defines if the engine should generate the mip levels
  83940. * @param invertY defines if data must be stored with Y axis inverted
  83941. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83942. * @param compression defines the compression used (null by default)
  83943. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83944. * @returns the raw texture inside an InternalTexture
  83945. */
  83946. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  83947. private _unpackFlipYCached;
  83948. /**
  83949. * In case you are sharing the context with other applications, it might
  83950. * be interested to not cache the unpack flip y state to ensure a consistent
  83951. * value would be set.
  83952. */
  83953. enableUnpackFlipYCached: boolean;
  83954. /** @hidden */
  83955. _unpackFlipY(value: boolean): void;
  83956. /** @hidden */
  83957. _getUnpackAlignement(): number;
  83958. /**
  83959. * Creates a dynamic texture
  83960. * @param width defines the width of the texture
  83961. * @param height defines the height of the texture
  83962. * @param generateMipMaps defines if the engine should generate the mip levels
  83963. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83964. * @returns the dynamic texture inside an InternalTexture
  83965. */
  83966. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83967. /**
  83968. * Update the sampling mode of a given texture
  83969. * @param samplingMode defines the required sampling mode
  83970. * @param texture defines the texture to update
  83971. */
  83972. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  83973. /**
  83974. * Update the content of a dynamic texture
  83975. * @param texture defines the texture to update
  83976. * @param canvas defines the canvas containing the source
  83977. * @param invertY defines if data must be stored with Y axis inverted
  83978. * @param premulAlpha defines if alpha is stored as premultiplied
  83979. * @param format defines the format of the data
  83980. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83981. */
  83982. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83983. /**
  83984. * Update a video texture
  83985. * @param texture defines the texture to update
  83986. * @param video defines the video element to use
  83987. * @param invertY defines if data must be stored with Y axis inverted
  83988. */
  83989. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  83990. /**
  83991. * Updates a depth texture Comparison Mode and Function.
  83992. * If the comparison Function is equal to 0, the mode will be set to none.
  83993. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  83994. * @param texture The texture to set the comparison function for
  83995. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  83996. */
  83997. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  83998. private _setupDepthStencilTexture;
  83999. /**
  84000. * Creates a depth stencil texture.
  84001. * This is only available in WebGL 2 or with the depth texture extension available.
  84002. * @param size The size of face edge in the texture.
  84003. * @param options The options defining the texture.
  84004. * @returns The texture
  84005. */
  84006. createDepthStencilTexture(size: number | {
  84007. width: number;
  84008. height: number;
  84009. }, options: DepthTextureCreationOptions): InternalTexture;
  84010. /**
  84011. * Creates a depth stencil texture.
  84012. * This is only available in WebGL 2 or with the depth texture extension available.
  84013. * @param size The size of face edge in the texture.
  84014. * @param options The options defining the texture.
  84015. * @returns The texture
  84016. */
  84017. private _createDepthStencilTexture;
  84018. /**
  84019. * Creates a depth stencil cube texture.
  84020. * This is only available in WebGL 2.
  84021. * @param size The size of face edge in the cube texture.
  84022. * @param options The options defining the cube texture.
  84023. * @returns The cube texture
  84024. */
  84025. private _createDepthStencilCubeTexture;
  84026. /**
  84027. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84028. * @param renderTarget The render target to set the frame buffer for
  84029. */
  84030. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84031. /**
  84032. * Creates a new render target texture
  84033. * @param size defines the size of the texture
  84034. * @param options defines the options used to create the texture
  84035. * @returns a new render target texture stored in an InternalTexture
  84036. */
  84037. createRenderTargetTexture(size: number | {
  84038. width: number;
  84039. height: number;
  84040. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84041. /**
  84042. * Create a multi render target texture
  84043. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84044. * @param size defines the size of the texture
  84045. * @param options defines the creation options
  84046. * @returns the cube texture as an InternalTexture
  84047. */
  84048. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84049. private _setupFramebufferDepthAttachments;
  84050. /**
  84051. * Updates the sample count of a render target texture
  84052. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84053. * @param texture defines the texture to update
  84054. * @param samples defines the sample count to set
  84055. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84056. */
  84057. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84058. /**
  84059. * Update the sample count for a given multiple render target texture
  84060. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84061. * @param textures defines the textures to update
  84062. * @param samples defines the sample count to set
  84063. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84064. */
  84065. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84066. /** @hidden */
  84067. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84068. /** @hidden */
  84069. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84070. /** @hidden */
  84071. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84072. /** @hidden */
  84073. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84074. /**
  84075. * Creates a new render target cube texture
  84076. * @param size defines the size of the texture
  84077. * @param options defines the options used to create the texture
  84078. * @returns a new render target cube texture stored in an InternalTexture
  84079. */
  84080. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84081. /**
  84082. * Creates a cube texture
  84083. * @param rootUrl defines the url where the files to load is located
  84084. * @param scene defines the current scene
  84085. * @param files defines the list of files to load (1 per face)
  84086. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84087. * @param onLoad defines an optional callback raised when the texture is loaded
  84088. * @param onError defines an optional callback raised if there is an issue to load the texture
  84089. * @param format defines the format of the data
  84090. * @param forcedExtension defines the extension to use to pick the right loader
  84091. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84092. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84093. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84094. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84095. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84096. * @returns the cube texture as an InternalTexture
  84097. */
  84098. 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;
  84099. /**
  84100. * @hidden
  84101. */
  84102. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84103. /**
  84104. * Update a raw cube texture
  84105. * @param texture defines the texture to udpdate
  84106. * @param data defines the data to store
  84107. * @param format defines the data format
  84108. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84109. * @param invertY defines if data must be stored with Y axis inverted
  84110. * @param compression defines the compression used (null by default)
  84111. * @param level defines which level of the texture to update
  84112. */
  84113. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84114. /**
  84115. * Creates a new raw cube texture
  84116. * @param data defines the array of data to use to create each face
  84117. * @param size defines the size of the textures
  84118. * @param format defines the format of the data
  84119. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84120. * @param generateMipMaps defines if the engine should generate the mip levels
  84121. * @param invertY defines if data must be stored with Y axis inverted
  84122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84123. * @param compression defines the compression used (null by default)
  84124. * @returns the cube texture as an InternalTexture
  84125. */
  84126. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84127. /**
  84128. * Creates a new raw cube texture from a specified url
  84129. * @param url defines the url where the data is located
  84130. * @param scene defines the current scene
  84131. * @param size defines the size of the textures
  84132. * @param format defines the format of the data
  84133. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84134. * @param noMipmap defines if the engine should avoid generating the mip levels
  84135. * @param callback defines a callback used to extract texture data from loaded data
  84136. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84137. * @param onLoad defines a callback called when texture is loaded
  84138. * @param onError defines a callback called if there is an error
  84139. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84140. * @param invertY defines if data must be stored with Y axis inverted
  84141. * @returns the cube texture as an InternalTexture
  84142. */
  84143. 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;
  84144. /**
  84145. * Update a raw 3D texture
  84146. * @param texture defines the texture to update
  84147. * @param data defines the data to store
  84148. * @param format defines the data format
  84149. * @param invertY defines if data must be stored with Y axis inverted
  84150. * @param compression defines the used compression (can be null)
  84151. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84152. */
  84153. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84154. /**
  84155. * Creates a new raw 3D texture
  84156. * @param data defines the data used to create the texture
  84157. * @param width defines the width of the texture
  84158. * @param height defines the height of the texture
  84159. * @param depth defines the depth of the texture
  84160. * @param format defines the format of the texture
  84161. * @param generateMipMaps defines if the engine must generate mip levels
  84162. * @param invertY defines if data must be stored with Y axis inverted
  84163. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84164. * @param compression defines the compressed used (can be null)
  84165. * @param textureType defines the compressed used (can be null)
  84166. * @returns a new raw 3D texture (stored in an InternalTexture)
  84167. */
  84168. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84169. private _prepareWebGLTextureContinuation;
  84170. private _prepareWebGLTexture;
  84171. private _convertRGBtoRGBATextureData;
  84172. /** @hidden */
  84173. _releaseFramebufferObjects(texture: InternalTexture): void;
  84174. /** @hidden */
  84175. _releaseTexture(texture: InternalTexture): void;
  84176. private setProgram;
  84177. private _boundUniforms;
  84178. /**
  84179. * Binds an effect to the webGL context
  84180. * @param effect defines the effect to bind
  84181. */
  84182. bindSamplers(effect: Effect): void;
  84183. private _moveBoundTextureOnTop;
  84184. private _getCorrectTextureChannel;
  84185. private _linkTrackers;
  84186. private _removeDesignatedSlot;
  84187. private _activateCurrentTexture;
  84188. /** @hidden */
  84189. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84190. /** @hidden */
  84191. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84192. /**
  84193. * Sets a texture to the webGL context from a postprocess
  84194. * @param channel defines the channel to use
  84195. * @param postProcess defines the source postprocess
  84196. */
  84197. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84198. /**
  84199. * Binds the output of the passed in post process to the texture channel specified
  84200. * @param channel The channel the texture should be bound to
  84201. * @param postProcess The post process which's output should be bound
  84202. */
  84203. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84204. /**
  84205. * Unbind all textures from the webGL context
  84206. */
  84207. unbindAllTextures(): void;
  84208. /**
  84209. * Sets a texture to the according uniform.
  84210. * @param channel The texture channel
  84211. * @param uniform The uniform to set
  84212. * @param texture The texture to apply
  84213. */
  84214. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84215. /**
  84216. * Sets a depth stencil texture from a render target to the according uniform.
  84217. * @param channel The texture channel
  84218. * @param uniform The uniform to set
  84219. * @param texture The render target texture containing the depth stencil texture to apply
  84220. */
  84221. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84222. private _bindSamplerUniformToChannel;
  84223. private _getTextureWrapMode;
  84224. private _setTexture;
  84225. /**
  84226. * Sets an array of texture to the webGL context
  84227. * @param channel defines the channel where the texture array must be set
  84228. * @param uniform defines the associated uniform location
  84229. * @param textures defines the array of textures to bind
  84230. */
  84231. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84232. /** @hidden */
  84233. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84234. private _setTextureParameterFloat;
  84235. private _setTextureParameterInteger;
  84236. /**
  84237. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84238. * @param x defines the x coordinate of the rectangle where pixels must be read
  84239. * @param y defines the y coordinate of the rectangle where pixels must be read
  84240. * @param width defines the width of the rectangle where pixels must be read
  84241. * @param height defines the height of the rectangle where pixels must be read
  84242. * @returns a Uint8Array containing RGBA colors
  84243. */
  84244. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84245. /**
  84246. * Add an externaly attached data from its key.
  84247. * This method call will fail and return false, if such key already exists.
  84248. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84249. * @param key the unique key that identifies the data
  84250. * @param data the data object to associate to the key for this Engine instance
  84251. * @return true if no such key were already present and the data was added successfully, false otherwise
  84252. */
  84253. addExternalData<T>(key: string, data: T): boolean;
  84254. /**
  84255. * Get an externaly attached data from its key
  84256. * @param key the unique key that identifies the data
  84257. * @return the associated data, if present (can be null), or undefined if not present
  84258. */
  84259. getExternalData<T>(key: string): T;
  84260. /**
  84261. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84262. * @param key the unique key that identifies the data
  84263. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84264. * @return the associated data, can be null if the factory returned null.
  84265. */
  84266. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84267. /**
  84268. * Remove an externaly attached data from the Engine instance
  84269. * @param key the unique key that identifies the data
  84270. * @return true if the data was successfully removed, false if it doesn't exist
  84271. */
  84272. removeExternalData(key: string): boolean;
  84273. /**
  84274. * Unbind all vertex attributes from the webGL context
  84275. */
  84276. unbindAllAttributes(): void;
  84277. /**
  84278. * 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
  84279. */
  84280. releaseEffects(): void;
  84281. /**
  84282. * Dispose and release all associated resources
  84283. */
  84284. dispose(): void;
  84285. /**
  84286. * Display the loading screen
  84287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84288. */
  84289. displayLoadingUI(): void;
  84290. /**
  84291. * Hide the loading screen
  84292. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84293. */
  84294. hideLoadingUI(): void;
  84295. /**
  84296. * Gets the current loading screen object
  84297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84298. */
  84299. /**
  84300. * Sets the current loading screen object
  84301. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84302. */
  84303. loadingScreen: ILoadingScreen;
  84304. /**
  84305. * Sets the current loading screen text
  84306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84307. */
  84308. loadingUIText: string;
  84309. /**
  84310. * Sets the current loading screen background color
  84311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84312. */
  84313. loadingUIBackgroundColor: string;
  84314. /**
  84315. * Attach a new callback raised when context lost event is fired
  84316. * @param callback defines the callback to call
  84317. */
  84318. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84319. /**
  84320. * Attach a new callback raised when context restored event is fired
  84321. * @param callback defines the callback to call
  84322. */
  84323. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84324. /**
  84325. * Gets the source code of the vertex shader associated with a specific webGL program
  84326. * @param program defines the program to use
  84327. * @returns a string containing the source code of the vertex shader associated with the program
  84328. */
  84329. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84330. /**
  84331. * Gets the source code of the fragment shader associated with a specific webGL program
  84332. * @param program defines the program to use
  84333. * @returns a string containing the source code of the fragment shader associated with the program
  84334. */
  84335. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84336. /**
  84337. * Get the current error code of the webGL context
  84338. * @returns the error code
  84339. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84340. */
  84341. getError(): number;
  84342. /**
  84343. * Gets the current framerate
  84344. * @returns a number representing the framerate
  84345. */
  84346. getFps(): number;
  84347. /**
  84348. * Gets the time spent between current and previous frame
  84349. * @returns a number representing the delta time in ms
  84350. */
  84351. getDeltaTime(): number;
  84352. private _measureFps;
  84353. /** @hidden */
  84354. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84355. private _canRenderToFloatFramebuffer;
  84356. private _canRenderToHalfFloatFramebuffer;
  84357. private _canRenderToFramebuffer;
  84358. /** @hidden */
  84359. _getWebGLTextureType(type: number): number;
  84360. private _getInternalFormat;
  84361. /** @hidden */
  84362. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84363. /** @hidden */
  84364. _getRGBAMultiSampleBufferFormat(type: number): number;
  84365. /** @hidden */
  84366. _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;
  84367. /** @hidden */
  84368. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84369. private _partialLoadFile;
  84370. private _cascadeLoadFiles;
  84371. /**
  84372. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84373. * @returns true if the engine can be created
  84374. * @ignorenaming
  84375. */
  84376. static isSupported(): boolean;
  84377. }
  84378. }
  84379. declare module BABYLON {
  84380. /**
  84381. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84382. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84383. */
  84384. export class EffectFallbacks {
  84385. private _defines;
  84386. private _currentRank;
  84387. private _maxRank;
  84388. private _mesh;
  84389. /**
  84390. * Removes the fallback from the bound mesh.
  84391. */
  84392. unBindMesh(): void;
  84393. /**
  84394. * Adds a fallback on the specified property.
  84395. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84396. * @param define The name of the define in the shader
  84397. */
  84398. addFallback(rank: number, define: string): void;
  84399. /**
  84400. * Sets the mesh to use CPU skinning when needing to fallback.
  84401. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84402. * @param mesh The mesh to use the fallbacks.
  84403. */
  84404. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84405. /**
  84406. * Checks to see if more fallbacks are still availible.
  84407. */
  84408. readonly isMoreFallbacks: boolean;
  84409. /**
  84410. * Removes the defines that shoould be removed when falling back.
  84411. * @param currentDefines defines the current define statements for the shader.
  84412. * @param effect defines the current effect we try to compile
  84413. * @returns The resulting defines with defines of the current rank removed.
  84414. */
  84415. reduce(currentDefines: string, effect: Effect): string;
  84416. }
  84417. /**
  84418. * Options to be used when creating an effect.
  84419. */
  84420. export class EffectCreationOptions {
  84421. /**
  84422. * Atrributes that will be used in the shader.
  84423. */
  84424. attributes: string[];
  84425. /**
  84426. * Uniform varible names that will be set in the shader.
  84427. */
  84428. uniformsNames: string[];
  84429. /**
  84430. * Uniform buffer varible names that will be set in the shader.
  84431. */
  84432. uniformBuffersNames: string[];
  84433. /**
  84434. * Sampler texture variable names that will be set in the shader.
  84435. */
  84436. samplers: string[];
  84437. /**
  84438. * Define statements that will be set in the shader.
  84439. */
  84440. defines: any;
  84441. /**
  84442. * Possible fallbacks for this effect to improve performance when needed.
  84443. */
  84444. fallbacks: Nullable<EffectFallbacks>;
  84445. /**
  84446. * Callback that will be called when the shader is compiled.
  84447. */
  84448. onCompiled: Nullable<(effect: Effect) => void>;
  84449. /**
  84450. * Callback that will be called if an error occurs during shader compilation.
  84451. */
  84452. onError: Nullable<(effect: Effect, errors: string) => void>;
  84453. /**
  84454. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84455. */
  84456. indexParameters: any;
  84457. /**
  84458. * Max number of lights that can be used in the shader.
  84459. */
  84460. maxSimultaneousLights: number;
  84461. /**
  84462. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84463. */
  84464. transformFeedbackVaryings: Nullable<string[]>;
  84465. }
  84466. /**
  84467. * Effect containing vertex and fragment shader that can be executed on an object.
  84468. */
  84469. export class Effect {
  84470. /**
  84471. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84472. */
  84473. static ShadersRepository: string;
  84474. /**
  84475. * Name of the effect.
  84476. */
  84477. name: any;
  84478. /**
  84479. * String container all the define statements that should be set on the shader.
  84480. */
  84481. defines: string;
  84482. /**
  84483. * Callback that will be called when the shader is compiled.
  84484. */
  84485. onCompiled: Nullable<(effect: Effect) => void>;
  84486. /**
  84487. * Callback that will be called if an error occurs during shader compilation.
  84488. */
  84489. onError: Nullable<(effect: Effect, errors: string) => void>;
  84490. /**
  84491. * Callback that will be called when effect is bound.
  84492. */
  84493. onBind: Nullable<(effect: Effect) => void>;
  84494. /**
  84495. * Unique ID of the effect.
  84496. */
  84497. uniqueId: number;
  84498. /**
  84499. * Observable that will be called when the shader is compiled.
  84500. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  84501. */
  84502. onCompileObservable: Observable<Effect>;
  84503. /**
  84504. * Observable that will be called if an error occurs during shader compilation.
  84505. */
  84506. onErrorObservable: Observable<Effect>;
  84507. /** @hidden */
  84508. _onBindObservable: Nullable<Observable<Effect>>;
  84509. /**
  84510. * Observable that will be called when effect is bound.
  84511. */
  84512. readonly onBindObservable: Observable<Effect>;
  84513. /** @hidden */
  84514. _bonesComputationForcedToCPU: boolean;
  84515. private static _uniqueIdSeed;
  84516. private _engine;
  84517. private _uniformBuffersNames;
  84518. private _uniformsNames;
  84519. private _samplers;
  84520. private _isReady;
  84521. private _compilationError;
  84522. private _attributesNames;
  84523. private _attributes;
  84524. private _uniforms;
  84525. /**
  84526. * Key for the effect.
  84527. * @hidden
  84528. */
  84529. _key: string;
  84530. private _indexParameters;
  84531. private _fallbacks;
  84532. private _vertexSourceCode;
  84533. private _fragmentSourceCode;
  84534. private _vertexSourceCodeOverride;
  84535. private _fragmentSourceCodeOverride;
  84536. private _transformFeedbackVaryings;
  84537. /**
  84538. * Compiled shader to webGL program.
  84539. * @hidden
  84540. */
  84541. _program: WebGLProgram;
  84542. private _valueCache;
  84543. private static _baseCache;
  84544. /**
  84545. * Instantiates an effect.
  84546. * An effect can be used to create/manage/execute vertex and fragment shaders.
  84547. * @param baseName Name of the effect.
  84548. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  84549. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  84550. * @param samplers List of sampler variables that will be passed to the shader.
  84551. * @param engine Engine to be used to render the effect
  84552. * @param defines Define statements to be added to the shader.
  84553. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  84554. * @param onCompiled Callback that will be called when the shader is compiled.
  84555. * @param onError Callback that will be called if an error occurs during shader compilation.
  84556. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84557. */
  84558. 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);
  84559. /**
  84560. * Unique key for this effect
  84561. */
  84562. readonly key: string;
  84563. /**
  84564. * If the effect has been compiled and prepared.
  84565. * @returns if the effect is compiled and prepared.
  84566. */
  84567. isReady(): boolean;
  84568. /**
  84569. * The engine the effect was initialized with.
  84570. * @returns the engine.
  84571. */
  84572. getEngine(): Engine;
  84573. /**
  84574. * The compiled webGL program for the effect
  84575. * @returns the webGL program.
  84576. */
  84577. getProgram(): WebGLProgram;
  84578. /**
  84579. * The set of names of attribute variables for the shader.
  84580. * @returns An array of attribute names.
  84581. */
  84582. getAttributesNames(): string[];
  84583. /**
  84584. * Returns the attribute at the given index.
  84585. * @param index The index of the attribute.
  84586. * @returns The location of the attribute.
  84587. */
  84588. getAttributeLocation(index: number): number;
  84589. /**
  84590. * Returns the attribute based on the name of the variable.
  84591. * @param name of the attribute to look up.
  84592. * @returns the attribute location.
  84593. */
  84594. getAttributeLocationByName(name: string): number;
  84595. /**
  84596. * The number of attributes.
  84597. * @returns the numnber of attributes.
  84598. */
  84599. getAttributesCount(): number;
  84600. /**
  84601. * Gets the index of a uniform variable.
  84602. * @param uniformName of the uniform to look up.
  84603. * @returns the index.
  84604. */
  84605. getUniformIndex(uniformName: string): number;
  84606. /**
  84607. * Returns the attribute based on the name of the variable.
  84608. * @param uniformName of the uniform to look up.
  84609. * @returns the location of the uniform.
  84610. */
  84611. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  84612. /**
  84613. * Returns an array of sampler variable names
  84614. * @returns The array of sampler variable neames.
  84615. */
  84616. getSamplers(): string[];
  84617. /**
  84618. * The error from the last compilation.
  84619. * @returns the error string.
  84620. */
  84621. getCompilationError(): string;
  84622. /**
  84623. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  84624. * @param func The callback to be used.
  84625. */
  84626. executeWhenCompiled(func: (effect: Effect) => void): void;
  84627. private _checkIsReady;
  84628. /** @hidden */
  84629. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  84630. /** @hidden */
  84631. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  84632. /** @hidden */
  84633. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  84634. private _processShaderConversion;
  84635. private _processIncludes;
  84636. private _processPrecision;
  84637. /**
  84638. * Recompiles the webGL program
  84639. * @param vertexSourceCode The source code for the vertex shader.
  84640. * @param fragmentSourceCode The source code for the fragment shader.
  84641. * @param onCompiled Callback called when completed.
  84642. * @param onError Callback called on error.
  84643. * @hidden
  84644. */
  84645. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  84646. /**
  84647. * Gets the uniform locations of the the specified variable names
  84648. * @param names THe names of the variables to lookup.
  84649. * @returns Array of locations in the same order as variable names.
  84650. */
  84651. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  84652. /**
  84653. * Prepares the effect
  84654. * @hidden
  84655. */
  84656. _prepareEffect(): void;
  84657. /**
  84658. * Checks if the effect is supported. (Must be called after compilation)
  84659. */
  84660. readonly isSupported: boolean;
  84661. /**
  84662. * Binds a texture to the engine to be used as output of the shader.
  84663. * @param channel Name of the output variable.
  84664. * @param texture Texture to bind.
  84665. * @hidden
  84666. */
  84667. _bindTexture(channel: string, texture: InternalTexture): void;
  84668. /**
  84669. * Sets a texture on the engine to be used in the shader.
  84670. * @param channel Name of the sampler variable.
  84671. * @param texture Texture to set.
  84672. */
  84673. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  84674. /**
  84675. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  84676. * @param channel Name of the sampler variable.
  84677. * @param texture Texture to set.
  84678. */
  84679. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  84680. /**
  84681. * Sets an array of textures on the engine to be used in the shader.
  84682. * @param channel Name of the variable.
  84683. * @param textures Textures to set.
  84684. */
  84685. setTextureArray(channel: string, textures: BaseTexture[]): void;
  84686. /**
  84687. * 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)
  84688. * @param channel Name of the sampler variable.
  84689. * @param postProcess Post process to get the input texture from.
  84690. */
  84691. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  84692. /**
  84693. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  84694. * 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)
  84695. * @param channel Name of the sampler variable.
  84696. * @param postProcess Post process to get the output texture from.
  84697. */
  84698. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  84699. /** @hidden */
  84700. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  84701. /** @hidden */
  84702. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  84703. /** @hidden */
  84704. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  84705. /** @hidden */
  84706. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  84707. /**
  84708. * Binds a buffer to a uniform.
  84709. * @param buffer Buffer to bind.
  84710. * @param name Name of the uniform variable to bind to.
  84711. */
  84712. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  84713. /**
  84714. * Binds block to a uniform.
  84715. * @param blockName Name of the block to bind.
  84716. * @param index Index to bind.
  84717. */
  84718. bindUniformBlock(blockName: string, index: number): void;
  84719. /**
  84720. * Sets an interger value on a uniform variable.
  84721. * @param uniformName Name of the variable.
  84722. * @param value Value to be set.
  84723. * @returns this effect.
  84724. */
  84725. setInt(uniformName: string, value: number): Effect;
  84726. /**
  84727. * Sets an int array on a uniform variable.
  84728. * @param uniformName Name of the variable.
  84729. * @param array array to be set.
  84730. * @returns this effect.
  84731. */
  84732. setIntArray(uniformName: string, array: Int32Array): Effect;
  84733. /**
  84734. * 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)
  84735. * @param uniformName Name of the variable.
  84736. * @param array array to be set.
  84737. * @returns this effect.
  84738. */
  84739. setIntArray2(uniformName: string, array: Int32Array): Effect;
  84740. /**
  84741. * 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)
  84742. * @param uniformName Name of the variable.
  84743. * @param array array to be set.
  84744. * @returns this effect.
  84745. */
  84746. setIntArray3(uniformName: string, array: Int32Array): Effect;
  84747. /**
  84748. * 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)
  84749. * @param uniformName Name of the variable.
  84750. * @param array array to be set.
  84751. * @returns this effect.
  84752. */
  84753. setIntArray4(uniformName: string, array: Int32Array): Effect;
  84754. /**
  84755. * Sets an float array on a uniform variable.
  84756. * @param uniformName Name of the variable.
  84757. * @param array array to be set.
  84758. * @returns this effect.
  84759. */
  84760. setFloatArray(uniformName: string, array: Float32Array): Effect;
  84761. /**
  84762. * 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)
  84763. * @param uniformName Name of the variable.
  84764. * @param array array to be set.
  84765. * @returns this effect.
  84766. */
  84767. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  84768. /**
  84769. * 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)
  84770. * @param uniformName Name of the variable.
  84771. * @param array array to be set.
  84772. * @returns this effect.
  84773. */
  84774. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  84775. /**
  84776. * 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)
  84777. * @param uniformName Name of the variable.
  84778. * @param array array to be set.
  84779. * @returns this effect.
  84780. */
  84781. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  84782. /**
  84783. * Sets an array on a uniform variable.
  84784. * @param uniformName Name of the variable.
  84785. * @param array array to be set.
  84786. * @returns this effect.
  84787. */
  84788. setArray(uniformName: string, array: number[]): Effect;
  84789. /**
  84790. * 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)
  84791. * @param uniformName Name of the variable.
  84792. * @param array array to be set.
  84793. * @returns this effect.
  84794. */
  84795. setArray2(uniformName: string, array: number[]): Effect;
  84796. /**
  84797. * 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)
  84798. * @param uniformName Name of the variable.
  84799. * @param array array to be set.
  84800. * @returns this effect.
  84801. */
  84802. setArray3(uniformName: string, array: number[]): Effect;
  84803. /**
  84804. * 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)
  84805. * @param uniformName Name of the variable.
  84806. * @param array array to be set.
  84807. * @returns this effect.
  84808. */
  84809. setArray4(uniformName: string, array: number[]): Effect;
  84810. /**
  84811. * Sets matrices on a uniform variable.
  84812. * @param uniformName Name of the variable.
  84813. * @param matrices matrices to be set.
  84814. * @returns this effect.
  84815. */
  84816. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  84817. /**
  84818. * Sets matrix on a uniform variable.
  84819. * @param uniformName Name of the variable.
  84820. * @param matrix matrix to be set.
  84821. * @returns this effect.
  84822. */
  84823. setMatrix(uniformName: string, matrix: Matrix): Effect;
  84824. /**
  84825. * 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)
  84826. * @param uniformName Name of the variable.
  84827. * @param matrix matrix to be set.
  84828. * @returns this effect.
  84829. */
  84830. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  84831. /**
  84832. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  84833. * @param uniformName Name of the variable.
  84834. * @param matrix matrix to be set.
  84835. * @returns this effect.
  84836. */
  84837. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  84838. /**
  84839. * Sets a float on a uniform variable.
  84840. * @param uniformName Name of the variable.
  84841. * @param value value to be set.
  84842. * @returns this effect.
  84843. */
  84844. setFloat(uniformName: string, value: number): Effect;
  84845. /**
  84846. * Sets a boolean on a uniform variable.
  84847. * @param uniformName Name of the variable.
  84848. * @param bool value to be set.
  84849. * @returns this effect.
  84850. */
  84851. setBool(uniformName: string, bool: boolean): Effect;
  84852. /**
  84853. * Sets a Vector2 on a uniform variable.
  84854. * @param uniformName Name of the variable.
  84855. * @param vector2 vector2 to be set.
  84856. * @returns this effect.
  84857. */
  84858. setVector2(uniformName: string, vector2: Vector2): Effect;
  84859. /**
  84860. * Sets a float2 on a uniform variable.
  84861. * @param uniformName Name of the variable.
  84862. * @param x First float in float2.
  84863. * @param y Second float in float2.
  84864. * @returns this effect.
  84865. */
  84866. setFloat2(uniformName: string, x: number, y: number): Effect;
  84867. /**
  84868. * Sets a Vector3 on a uniform variable.
  84869. * @param uniformName Name of the variable.
  84870. * @param vector3 Value to be set.
  84871. * @returns this effect.
  84872. */
  84873. setVector3(uniformName: string, vector3: Vector3): Effect;
  84874. /**
  84875. * Sets a float3 on a uniform variable.
  84876. * @param uniformName Name of the variable.
  84877. * @param x First float in float3.
  84878. * @param y Second float in float3.
  84879. * @param z Third float in float3.
  84880. * @returns this effect.
  84881. */
  84882. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  84883. /**
  84884. * Sets a Vector4 on a uniform variable.
  84885. * @param uniformName Name of the variable.
  84886. * @param vector4 Value to be set.
  84887. * @returns this effect.
  84888. */
  84889. setVector4(uniformName: string, vector4: Vector4): Effect;
  84890. /**
  84891. * Sets a float4 on a uniform variable.
  84892. * @param uniformName Name of the variable.
  84893. * @param x First float in float4.
  84894. * @param y Second float in float4.
  84895. * @param z Third float in float4.
  84896. * @param w Fourth float in float4.
  84897. * @returns this effect.
  84898. */
  84899. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  84900. /**
  84901. * Sets a Color3 on a uniform variable.
  84902. * @param uniformName Name of the variable.
  84903. * @param color3 Value to be set.
  84904. * @returns this effect.
  84905. */
  84906. setColor3(uniformName: string, color3: Color3): Effect;
  84907. /**
  84908. * Sets a Color4 on a uniform variable.
  84909. * @param uniformName Name of the variable.
  84910. * @param color3 Value to be set.
  84911. * @param alpha Alpha value to be set.
  84912. * @returns this effect.
  84913. */
  84914. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  84915. /**
  84916. * Sets a Color4 on a uniform variable
  84917. * @param uniformName defines the name of the variable
  84918. * @param color4 defines the value to be set
  84919. * @returns this effect.
  84920. */
  84921. setDirectColor4(uniformName: string, color4: Color4): Effect;
  84922. /**
  84923. * This function will add a new shader to the shader store
  84924. * @param name the name of the shader
  84925. * @param pixelShader optional pixel shader content
  84926. * @param vertexShader optional vertex shader content
  84927. */
  84928. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  84929. /**
  84930. * Store of each shader (The can be looked up using effect.key)
  84931. */
  84932. static ShadersStore: {
  84933. [key: string]: string;
  84934. };
  84935. /**
  84936. * Store of each included file for a shader (The can be looked up using effect.key)
  84937. */
  84938. static IncludesShadersStore: {
  84939. [key: string]: string;
  84940. };
  84941. /**
  84942. * Resets the cache of effects.
  84943. */
  84944. static ResetCache(): void;
  84945. }
  84946. }
  84947. declare module BABYLON {
  84948. /**
  84949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  84950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  84951. * 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;
  84952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  84953. */
  84954. export class ColorCurves {
  84955. private _dirty;
  84956. private _tempColor;
  84957. private _globalCurve;
  84958. private _highlightsCurve;
  84959. private _midtonesCurve;
  84960. private _shadowsCurve;
  84961. private _positiveCurve;
  84962. private _negativeCurve;
  84963. private _globalHue;
  84964. private _globalDensity;
  84965. private _globalSaturation;
  84966. private _globalExposure;
  84967. /**
  84968. * Gets the global Hue value.
  84969. * 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).
  84970. */
  84971. /**
  84972. * Sets the global Hue value.
  84973. * 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).
  84974. */
  84975. globalHue: number;
  84976. /**
  84977. * Gets the global Density value.
  84978. * 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.
  84979. * Values less than zero provide a filter of opposite hue.
  84980. */
  84981. /**
  84982. * Sets the global Density value.
  84983. * 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.
  84984. * Values less than zero provide a filter of opposite hue.
  84985. */
  84986. globalDensity: number;
  84987. /**
  84988. * Gets the global Saturation value.
  84989. * 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.
  84990. */
  84991. /**
  84992. * Sets the global Saturation value.
  84993. * 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.
  84994. */
  84995. globalSaturation: number;
  84996. /**
  84997. * Gets the global Exposure value.
  84998. * 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.
  84999. */
  85000. /**
  85001. * Sets the global Exposure value.
  85002. * 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.
  85003. */
  85004. globalExposure: number;
  85005. private _highlightsHue;
  85006. private _highlightsDensity;
  85007. private _highlightsSaturation;
  85008. private _highlightsExposure;
  85009. /**
  85010. * Gets the highlights Hue value.
  85011. * 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).
  85012. */
  85013. /**
  85014. * Sets the highlights Hue value.
  85015. * 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).
  85016. */
  85017. highlightsHue: number;
  85018. /**
  85019. * Gets the highlights Density value.
  85020. * 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.
  85021. * Values less than zero provide a filter of opposite hue.
  85022. */
  85023. /**
  85024. * Sets the highlights Density value.
  85025. * 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.
  85026. * Values less than zero provide a filter of opposite hue.
  85027. */
  85028. highlightsDensity: number;
  85029. /**
  85030. * Gets the highlights Saturation value.
  85031. * 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.
  85032. */
  85033. /**
  85034. * Sets the highlights Saturation value.
  85035. * 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.
  85036. */
  85037. highlightsSaturation: number;
  85038. /**
  85039. * Gets the highlights Exposure value.
  85040. * 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.
  85041. */
  85042. /**
  85043. * Sets the highlights Exposure value.
  85044. * 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.
  85045. */
  85046. highlightsExposure: number;
  85047. private _midtonesHue;
  85048. private _midtonesDensity;
  85049. private _midtonesSaturation;
  85050. private _midtonesExposure;
  85051. /**
  85052. * Gets the midtones Hue value.
  85053. * 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).
  85054. */
  85055. /**
  85056. * Sets the midtones Hue value.
  85057. * 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).
  85058. */
  85059. midtonesHue: number;
  85060. /**
  85061. * Gets the midtones Density value.
  85062. * 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.
  85063. * Values less than zero provide a filter of opposite hue.
  85064. */
  85065. /**
  85066. * Sets the midtones Density value.
  85067. * 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.
  85068. * Values less than zero provide a filter of opposite hue.
  85069. */
  85070. midtonesDensity: number;
  85071. /**
  85072. * Gets the midtones Saturation value.
  85073. * 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.
  85074. */
  85075. /**
  85076. * Sets the midtones Saturation value.
  85077. * 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.
  85078. */
  85079. midtonesSaturation: number;
  85080. /**
  85081. * Gets the midtones Exposure value.
  85082. * 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.
  85083. */
  85084. /**
  85085. * Sets the midtones Exposure value.
  85086. * 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.
  85087. */
  85088. midtonesExposure: number;
  85089. private _shadowsHue;
  85090. private _shadowsDensity;
  85091. private _shadowsSaturation;
  85092. private _shadowsExposure;
  85093. /**
  85094. * Gets the shadows Hue value.
  85095. * 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).
  85096. */
  85097. /**
  85098. * Sets the shadows Hue value.
  85099. * 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).
  85100. */
  85101. shadowsHue: number;
  85102. /**
  85103. * Gets the shadows Density value.
  85104. * 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.
  85105. * Values less than zero provide a filter of opposite hue.
  85106. */
  85107. /**
  85108. * Sets the shadows Density value.
  85109. * 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.
  85110. * Values less than zero provide a filter of opposite hue.
  85111. */
  85112. shadowsDensity: number;
  85113. /**
  85114. * Gets the shadows Saturation value.
  85115. * 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.
  85116. */
  85117. /**
  85118. * Sets the shadows Saturation value.
  85119. * 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.
  85120. */
  85121. shadowsSaturation: number;
  85122. /**
  85123. * Gets the shadows Exposure value.
  85124. * 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.
  85125. */
  85126. /**
  85127. * Sets the shadows Exposure value.
  85128. * 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.
  85129. */
  85130. shadowsExposure: number;
  85131. /**
  85132. * Returns the class name
  85133. * @returns The class name
  85134. */
  85135. getClassName(): string;
  85136. /**
  85137. * Binds the color curves to the shader.
  85138. * @param colorCurves The color curve to bind
  85139. * @param effect The effect to bind to
  85140. * @param positiveUniform The positive uniform shader parameter
  85141. * @param neutralUniform The neutral uniform shader parameter
  85142. * @param negativeUniform The negative uniform shader parameter
  85143. */
  85144. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85145. /**
  85146. * Prepare the list of uniforms associated with the ColorCurves effects.
  85147. * @param uniformsList The list of uniforms used in the effect
  85148. */
  85149. static PrepareUniforms(uniformsList: string[]): void;
  85150. /**
  85151. * Returns color grading data based on a hue, density, saturation and exposure value.
  85152. * @param filterHue The hue of the color filter.
  85153. * @param filterDensity The density of the color filter.
  85154. * @param saturation The saturation.
  85155. * @param exposure The exposure.
  85156. * @param result The result data container.
  85157. */
  85158. private getColorGradingDataToRef;
  85159. /**
  85160. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85161. * @param value The input slider value in range [-100,100].
  85162. * @returns Adjusted value.
  85163. */
  85164. private static applyColorGradingSliderNonlinear;
  85165. /**
  85166. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85167. * @param hue The hue (H) input.
  85168. * @param saturation The saturation (S) input.
  85169. * @param brightness The brightness (B) input.
  85170. * @result An RGBA color represented as Vector4.
  85171. */
  85172. private static fromHSBToRef;
  85173. /**
  85174. * Returns a value clamped between min and max
  85175. * @param value The value to clamp
  85176. * @param min The minimum of value
  85177. * @param max The maximum of value
  85178. * @returns The clamped value.
  85179. */
  85180. private static clamp;
  85181. /**
  85182. * Clones the current color curve instance.
  85183. * @return The cloned curves
  85184. */
  85185. clone(): ColorCurves;
  85186. /**
  85187. * Serializes the current color curve instance to a json representation.
  85188. * @return a JSON representation
  85189. */
  85190. serialize(): any;
  85191. /**
  85192. * Parses the color curve from a json representation.
  85193. * @param source the JSON source to parse
  85194. * @return The parsed curves
  85195. */
  85196. static Parse(source: any): ColorCurves;
  85197. }
  85198. }
  85199. declare module BABYLON {
  85200. /**
  85201. * Interface to follow in your material defines to integrate easily the
  85202. * Image proccessing functions.
  85203. * @hidden
  85204. */
  85205. export interface IImageProcessingConfigurationDefines {
  85206. IMAGEPROCESSING: boolean;
  85207. VIGNETTE: boolean;
  85208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85209. VIGNETTEBLENDMODEOPAQUE: boolean;
  85210. TONEMAPPING: boolean;
  85211. TONEMAPPING_ACES: boolean;
  85212. CONTRAST: boolean;
  85213. EXPOSURE: boolean;
  85214. COLORCURVES: boolean;
  85215. COLORGRADING: boolean;
  85216. COLORGRADING3D: boolean;
  85217. SAMPLER3DGREENDEPTH: boolean;
  85218. SAMPLER3DBGRMAP: boolean;
  85219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85220. }
  85221. /**
  85222. * @hidden
  85223. */
  85224. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85225. IMAGEPROCESSING: boolean;
  85226. VIGNETTE: boolean;
  85227. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85228. VIGNETTEBLENDMODEOPAQUE: boolean;
  85229. TONEMAPPING: boolean;
  85230. TONEMAPPING_ACES: boolean;
  85231. CONTRAST: boolean;
  85232. COLORCURVES: boolean;
  85233. COLORGRADING: boolean;
  85234. COLORGRADING3D: boolean;
  85235. SAMPLER3DGREENDEPTH: boolean;
  85236. SAMPLER3DBGRMAP: boolean;
  85237. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85238. EXPOSURE: boolean;
  85239. constructor();
  85240. }
  85241. /**
  85242. * This groups together the common properties used for image processing either in direct forward pass
  85243. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85244. * or not.
  85245. */
  85246. export class ImageProcessingConfiguration {
  85247. /**
  85248. * Default tone mapping applied in BabylonJS.
  85249. */
  85250. static readonly TONEMAPPING_STANDARD: number;
  85251. /**
  85252. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85253. * to other engines rendering to increase portability.
  85254. */
  85255. static readonly TONEMAPPING_ACES: number;
  85256. /**
  85257. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85258. */
  85259. colorCurves: Nullable<ColorCurves>;
  85260. private _colorCurvesEnabled;
  85261. /**
  85262. * Gets wether the color curves effect is enabled.
  85263. */
  85264. /**
  85265. * Sets wether the color curves effect is enabled.
  85266. */
  85267. colorCurvesEnabled: boolean;
  85268. private _colorGradingTexture;
  85269. /**
  85270. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85271. */
  85272. /**
  85273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85274. */
  85275. colorGradingTexture: Nullable<BaseTexture>;
  85276. private _colorGradingEnabled;
  85277. /**
  85278. * Gets wether the color grading effect is enabled.
  85279. */
  85280. /**
  85281. * Sets wether the color grading effect is enabled.
  85282. */
  85283. colorGradingEnabled: boolean;
  85284. private _colorGradingWithGreenDepth;
  85285. /**
  85286. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85287. */
  85288. /**
  85289. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85290. */
  85291. colorGradingWithGreenDepth: boolean;
  85292. private _colorGradingBGR;
  85293. /**
  85294. * Gets wether the color grading texture contains BGR values.
  85295. */
  85296. /**
  85297. * Sets wether the color grading texture contains BGR values.
  85298. */
  85299. colorGradingBGR: boolean;
  85300. /** @hidden */
  85301. _exposure: number;
  85302. /**
  85303. * Gets the Exposure used in the effect.
  85304. */
  85305. /**
  85306. * Sets the Exposure used in the effect.
  85307. */
  85308. exposure: number;
  85309. private _toneMappingEnabled;
  85310. /**
  85311. * Gets wether the tone mapping effect is enabled.
  85312. */
  85313. /**
  85314. * Sets wether the tone mapping effect is enabled.
  85315. */
  85316. toneMappingEnabled: boolean;
  85317. private _toneMappingType;
  85318. /**
  85319. * Gets the type of tone mapping effect.
  85320. */
  85321. /**
  85322. * Sets the type of tone mapping effect used in BabylonJS.
  85323. */
  85324. toneMappingType: number;
  85325. protected _contrast: number;
  85326. /**
  85327. * Gets the contrast used in the effect.
  85328. */
  85329. /**
  85330. * Sets the contrast used in the effect.
  85331. */
  85332. contrast: number;
  85333. /**
  85334. * Vignette stretch size.
  85335. */
  85336. vignetteStretch: number;
  85337. /**
  85338. * Vignette centre X Offset.
  85339. */
  85340. vignetteCentreX: number;
  85341. /**
  85342. * Vignette centre Y Offset.
  85343. */
  85344. vignetteCentreY: number;
  85345. /**
  85346. * Vignette weight or intensity of the vignette effect.
  85347. */
  85348. vignetteWeight: number;
  85349. /**
  85350. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85351. * if vignetteEnabled is set to true.
  85352. */
  85353. vignetteColor: Color4;
  85354. /**
  85355. * Camera field of view used by the Vignette effect.
  85356. */
  85357. vignetteCameraFov: number;
  85358. private _vignetteBlendMode;
  85359. /**
  85360. * Gets the vignette blend mode allowing different kind of effect.
  85361. */
  85362. /**
  85363. * Sets the vignette blend mode allowing different kind of effect.
  85364. */
  85365. vignetteBlendMode: number;
  85366. private _vignetteEnabled;
  85367. /**
  85368. * Gets wether the vignette effect is enabled.
  85369. */
  85370. /**
  85371. * Sets wether the vignette effect is enabled.
  85372. */
  85373. vignetteEnabled: boolean;
  85374. private _applyByPostProcess;
  85375. /**
  85376. * Gets wether the image processing is applied through a post process or not.
  85377. */
  85378. /**
  85379. * Sets wether the image processing is applied through a post process or not.
  85380. */
  85381. applyByPostProcess: boolean;
  85382. private _isEnabled;
  85383. /**
  85384. * Gets wether the image processing is enabled or not.
  85385. */
  85386. /**
  85387. * Sets wether the image processing is enabled or not.
  85388. */
  85389. isEnabled: boolean;
  85390. /**
  85391. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85392. */
  85393. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85394. /**
  85395. * Method called each time the image processing information changes requires to recompile the effect.
  85396. */
  85397. protected _updateParameters(): void;
  85398. /**
  85399. * Gets the current class name.
  85400. * @return "ImageProcessingConfiguration"
  85401. */
  85402. getClassName(): string;
  85403. /**
  85404. * Prepare the list of uniforms associated with the Image Processing effects.
  85405. * @param uniforms The list of uniforms used in the effect
  85406. * @param defines the list of defines currently in use
  85407. */
  85408. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85409. /**
  85410. * Prepare the list of samplers associated with the Image Processing effects.
  85411. * @param samplersList The list of uniforms used in the effect
  85412. * @param defines the list of defines currently in use
  85413. */
  85414. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85415. /**
  85416. * Prepare the list of defines associated to the shader.
  85417. * @param defines the list of defines to complete
  85418. * @param forPostProcess Define if we are currently in post process mode or not
  85419. */
  85420. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85421. /**
  85422. * Returns true if all the image processing information are ready.
  85423. * @returns True if ready, otherwise, false
  85424. */
  85425. isReady(): boolean;
  85426. /**
  85427. * Binds the image processing to the shader.
  85428. * @param effect The effect to bind to
  85429. * @param aspectRatio Define the current aspect ratio of the effect
  85430. */
  85431. bind(effect: Effect, aspectRatio?: number): void;
  85432. /**
  85433. * Clones the current image processing instance.
  85434. * @return The cloned image processing
  85435. */
  85436. clone(): ImageProcessingConfiguration;
  85437. /**
  85438. * Serializes the current image processing instance to a json representation.
  85439. * @return a JSON representation
  85440. */
  85441. serialize(): any;
  85442. /**
  85443. * Parses the image processing from a json representation.
  85444. * @param source the JSON source to parse
  85445. * @return The parsed image processing
  85446. */
  85447. static Parse(source: any): ImageProcessingConfiguration;
  85448. private static _VIGNETTEMODE_MULTIPLY;
  85449. private static _VIGNETTEMODE_OPAQUE;
  85450. /**
  85451. * Used to apply the vignette as a mix with the pixel color.
  85452. */
  85453. static readonly VIGNETTEMODE_MULTIPLY: number;
  85454. /**
  85455. * Used to apply the vignette as a replacement of the pixel color.
  85456. */
  85457. static readonly VIGNETTEMODE_OPAQUE: number;
  85458. }
  85459. }
  85460. declare module BABYLON {
  85461. /**
  85462. * This represents all the required information to add a fresnel effect on a material:
  85463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85464. */
  85465. export class FresnelParameters {
  85466. private _isEnabled;
  85467. /**
  85468. * Define if the fresnel effect is enable or not.
  85469. */
  85470. isEnabled: boolean;
  85471. /**
  85472. * Define the color used on edges (grazing angle)
  85473. */
  85474. leftColor: Color3;
  85475. /**
  85476. * Define the color used on center
  85477. */
  85478. rightColor: Color3;
  85479. /**
  85480. * Define bias applied to computed fresnel term
  85481. */
  85482. bias: number;
  85483. /**
  85484. * Defined the power exponent applied to fresnel term
  85485. */
  85486. power: number;
  85487. /**
  85488. * Clones the current fresnel and its valuues
  85489. * @returns a clone fresnel configuration
  85490. */
  85491. clone(): FresnelParameters;
  85492. /**
  85493. * Serializes the current fresnel parameters to a JSON representation.
  85494. * @return the JSON serialization
  85495. */
  85496. serialize(): any;
  85497. /**
  85498. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  85499. * @param parsedFresnelParameters Define the JSON representation
  85500. * @returns the parsed parameters
  85501. */
  85502. static Parse(parsedFresnelParameters: any): FresnelParameters;
  85503. }
  85504. }
  85505. declare module BABYLON {
  85506. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  85507. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85508. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85509. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85510. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85511. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85512. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85513. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85514. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85515. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85516. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85517. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85518. /**
  85519. * Decorator used to define property that can be serialized as reference to a camera
  85520. * @param sourceName defines the name of the property to decorate
  85521. */
  85522. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85523. /**
  85524. * Class used to help serialization objects
  85525. */
  85526. export class SerializationHelper {
  85527. /** hidden */
  85528. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  85529. /** hidden */
  85530. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  85531. /** hidden */
  85532. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  85533. /** hidden */
  85534. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  85535. /**
  85536. * Appends the serialized animations from the source animations
  85537. * @param source Source containing the animations
  85538. * @param destination Target to store the animations
  85539. */
  85540. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85541. /**
  85542. * Static function used to serialized a specific entity
  85543. * @param entity defines the entity to serialize
  85544. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  85545. * @returns a JSON compatible object representing the serialization of the entity
  85546. */
  85547. static Serialize<T>(entity: T, serializationObject?: any): any;
  85548. /**
  85549. * Creates a new entity from a serialization data object
  85550. * @param creationFunction defines a function used to instanciated the new entity
  85551. * @param source defines the source serialization data
  85552. * @param scene defines the hosting scene
  85553. * @param rootUrl defines the root url for resources
  85554. * @returns a new entity
  85555. */
  85556. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  85557. /**
  85558. * Clones an object
  85559. * @param creationFunction defines the function used to instanciate the new object
  85560. * @param source defines the source object
  85561. * @returns the cloned object
  85562. */
  85563. static Clone<T>(creationFunction: () => T, source: T): T;
  85564. /**
  85565. * Instanciates a new object based on a source one (some data will be shared between both object)
  85566. * @param creationFunction defines the function used to instanciate the new object
  85567. * @param source defines the source object
  85568. * @returns the new object
  85569. */
  85570. static Instanciate<T>(creationFunction: () => T, source: T): T;
  85571. }
  85572. }
  85573. declare module BABYLON {
  85574. /**
  85575. * This is the base class of all the camera used in the application.
  85576. * @see http://doc.babylonjs.com/features/cameras
  85577. */
  85578. export class Camera extends Node {
  85579. /** @hidden */
  85580. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  85581. /**
  85582. * This is the default projection mode used by the cameras.
  85583. * It helps recreating a feeling of perspective and better appreciate depth.
  85584. * This is the best way to simulate real life cameras.
  85585. */
  85586. static readonly PERSPECTIVE_CAMERA: number;
  85587. /**
  85588. * This helps creating camera with an orthographic mode.
  85589. * 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.
  85590. */
  85591. static readonly ORTHOGRAPHIC_CAMERA: number;
  85592. /**
  85593. * This is the default FOV mode for perspective cameras.
  85594. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  85595. */
  85596. static readonly FOVMODE_VERTICAL_FIXED: number;
  85597. /**
  85598. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  85599. */
  85600. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  85601. /**
  85602. * This specifies ther is no need for a camera rig.
  85603. * Basically only one eye is rendered corresponding to the camera.
  85604. */
  85605. static readonly RIG_MODE_NONE: number;
  85606. /**
  85607. * Simulates a camera Rig with one blue eye and one red eye.
  85608. * This can be use with 3d blue and red glasses.
  85609. */
  85610. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  85611. /**
  85612. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  85613. */
  85614. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  85615. /**
  85616. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  85617. */
  85618. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  85619. /**
  85620. * Defines that both eyes of the camera will be rendered over under each other.
  85621. */
  85622. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  85623. /**
  85624. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  85625. */
  85626. static readonly RIG_MODE_VR: number;
  85627. /**
  85628. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  85629. */
  85630. static readonly RIG_MODE_WEBVR: number;
  85631. /**
  85632. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  85633. */
  85634. static readonly RIG_MODE_CUSTOM: number;
  85635. /**
  85636. * Defines if by default attaching controls should prevent the default javascript event to continue.
  85637. */
  85638. static ForceAttachControlToAlwaysPreventDefault: boolean;
  85639. /**
  85640. * @hidden
  85641. * Might be removed once multiview will be a thing
  85642. */
  85643. static UseAlternateWebVRRendering: boolean;
  85644. /**
  85645. * Define the input manager associated with the camera.
  85646. */
  85647. inputs: CameraInputsManager<Camera>;
  85648. /**
  85649. * Define the current local position of the camera in the scene
  85650. */
  85651. position: Vector3;
  85652. /**
  85653. * The vector the camera should consider as up.
  85654. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  85655. */
  85656. upVector: Vector3;
  85657. /**
  85658. * Define the current limit on the left side for an orthographic camera
  85659. * In scene unit
  85660. */
  85661. orthoLeft: Nullable<number>;
  85662. /**
  85663. * Define the current limit on the right side for an orthographic camera
  85664. * In scene unit
  85665. */
  85666. orthoRight: Nullable<number>;
  85667. /**
  85668. * Define the current limit on the bottom side for an orthographic camera
  85669. * In scene unit
  85670. */
  85671. orthoBottom: Nullable<number>;
  85672. /**
  85673. * Define the current limit on the top side for an orthographic camera
  85674. * In scene unit
  85675. */
  85676. orthoTop: Nullable<number>;
  85677. /**
  85678. * Field Of View is set in Radians. (default is 0.8)
  85679. */
  85680. fov: number;
  85681. /**
  85682. * Define the minimum distance the camera can see from.
  85683. * This is important to note that the depth buffer are not infinite and the closer it starts
  85684. * the more your scene might encounter depth fighting issue.
  85685. */
  85686. minZ: number;
  85687. /**
  85688. * Define the maximum distance the camera can see to.
  85689. * This is important to note that the depth buffer are not infinite and the further it end
  85690. * the more your scene might encounter depth fighting issue.
  85691. */
  85692. maxZ: number;
  85693. /**
  85694. * Define the default inertia of the camera.
  85695. * This helps giving a smooth feeling to the camera movement.
  85696. */
  85697. inertia: number;
  85698. /**
  85699. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  85700. */
  85701. mode: number;
  85702. /**
  85703. * Define wether the camera is intermediate.
  85704. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  85705. */
  85706. isIntermediate: boolean;
  85707. /**
  85708. * Define the viewport of the camera.
  85709. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  85710. */
  85711. viewport: Viewport;
  85712. /**
  85713. * Restricts the camera to viewing objects with the same layerMask.
  85714. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  85715. */
  85716. layerMask: number;
  85717. /**
  85718. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  85719. */
  85720. fovMode: number;
  85721. /**
  85722. * Rig mode of the camera.
  85723. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  85724. * This is normally controlled byt the camera themselves as internal use.
  85725. */
  85726. cameraRigMode: number;
  85727. /**
  85728. * Defines the distance between both "eyes" in case of a RIG
  85729. */
  85730. interaxialDistance: number;
  85731. /**
  85732. * Defines if stereoscopic rendering is done side by side or over under.
  85733. */
  85734. isStereoscopicSideBySide: boolean;
  85735. /**
  85736. * 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
  85737. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  85738. * else in the scene.
  85739. */
  85740. customRenderTargets: RenderTargetTexture[];
  85741. /**
  85742. * When set, the camera will render to this render target instead of the default canvas
  85743. */
  85744. outputRenderTarget: Nullable<RenderTargetTexture>;
  85745. /**
  85746. * Observable triggered when the camera view matrix has changed.
  85747. */
  85748. onViewMatrixChangedObservable: Observable<Camera>;
  85749. /**
  85750. * Observable triggered when the camera Projection matrix has changed.
  85751. */
  85752. onProjectionMatrixChangedObservable: Observable<Camera>;
  85753. /**
  85754. * Observable triggered when the inputs have been processed.
  85755. */
  85756. onAfterCheckInputsObservable: Observable<Camera>;
  85757. /**
  85758. * Observable triggered when reset has been called and applied to the camera.
  85759. */
  85760. onRestoreStateObservable: Observable<Camera>;
  85761. /** @hidden */
  85762. _cameraRigParams: any;
  85763. /** @hidden */
  85764. _rigCameras: Camera[];
  85765. /** @hidden */
  85766. _rigPostProcess: Nullable<PostProcess>;
  85767. protected _webvrViewMatrix: Matrix;
  85768. /** @hidden */
  85769. _skipRendering: boolean;
  85770. /** @hidden */
  85771. _alternateCamera: Camera;
  85772. /** @hidden */
  85773. _projectionMatrix: Matrix;
  85774. /** @hidden */
  85775. _postProcesses: Nullable<PostProcess>[];
  85776. /** @hidden */
  85777. _activeMeshes: SmartArray<AbstractMesh>;
  85778. protected _globalPosition: Vector3;
  85779. /** hidden */
  85780. _computedViewMatrix: Matrix;
  85781. private _doNotComputeProjectionMatrix;
  85782. private _transformMatrix;
  85783. private _frustumPlanes;
  85784. private _refreshFrustumPlanes;
  85785. private _storedFov;
  85786. private _stateStored;
  85787. /**
  85788. * Instantiates a new camera object.
  85789. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  85790. * @see http://doc.babylonjs.com/features/cameras
  85791. * @param name Defines the name of the camera in the scene
  85792. * @param position Defines the position of the camera
  85793. * @param scene Defines the scene the camera belongs too
  85794. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  85795. */
  85796. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85797. /**
  85798. * Store current camera state (fov, position, etc..)
  85799. * @returns the camera
  85800. */
  85801. storeState(): Camera;
  85802. /**
  85803. * Restores the camera state values if it has been stored. You must call storeState() first
  85804. */
  85805. protected _restoreStateValues(): boolean;
  85806. /**
  85807. * Restored camera state. You must call storeState() first.
  85808. * @returns true if restored and false otherwise
  85809. */
  85810. restoreState(): boolean;
  85811. /**
  85812. * Gets the class name of the camera.
  85813. * @returns the class name
  85814. */
  85815. getClassName(): string;
  85816. /** @hidden */
  85817. readonly _isCamera: boolean;
  85818. /**
  85819. * Gets a string representation of the camera useful for debug purpose.
  85820. * @param fullDetails Defines that a more verboe level of logging is required
  85821. * @returns the string representation
  85822. */
  85823. toString(fullDetails?: boolean): string;
  85824. /**
  85825. * Gets the current world space position of the camera.
  85826. */
  85827. readonly globalPosition: Vector3;
  85828. /**
  85829. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  85830. * @returns the active meshe list
  85831. */
  85832. getActiveMeshes(): SmartArray<AbstractMesh>;
  85833. /**
  85834. * Check wether a mesh is part of the current active mesh list of the camera
  85835. * @param mesh Defines the mesh to check
  85836. * @returns true if active, false otherwise
  85837. */
  85838. isActiveMesh(mesh: Mesh): boolean;
  85839. /**
  85840. * Is this camera ready to be used/rendered
  85841. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  85842. * @return true if the camera is ready
  85843. */
  85844. isReady(completeCheck?: boolean): boolean;
  85845. /** @hidden */
  85846. _initCache(): void;
  85847. /** @hidden */
  85848. _updateCache(ignoreParentClass?: boolean): void;
  85849. /** @hidden */
  85850. _isSynchronized(): boolean;
  85851. /** @hidden */
  85852. _isSynchronizedViewMatrix(): boolean;
  85853. /** @hidden */
  85854. _isSynchronizedProjectionMatrix(): boolean;
  85855. /**
  85856. * Attach the input controls to a specific dom element to get the input from.
  85857. * @param element Defines the element the controls should be listened from
  85858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85859. */
  85860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85861. /**
  85862. * Detach the current controls from the specified dom element.
  85863. * @param element Defines the element to stop listening the inputs from
  85864. */
  85865. detachControl(element: HTMLElement): void;
  85866. /**
  85867. * Update the camera state according to the different inputs gathered during the frame.
  85868. */
  85869. update(): void;
  85870. /** @hidden */
  85871. _checkInputs(): void;
  85872. /** @hidden */
  85873. readonly rigCameras: Camera[];
  85874. /**
  85875. * Gets the post process used by the rig cameras
  85876. */
  85877. readonly rigPostProcess: Nullable<PostProcess>;
  85878. /**
  85879. * Internal, gets the first post proces.
  85880. * @returns the first post process to be run on this camera.
  85881. */
  85882. _getFirstPostProcess(): Nullable<PostProcess>;
  85883. private _cascadePostProcessesToRigCams;
  85884. /**
  85885. * Attach a post process to the camera.
  85886. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  85887. * @param postProcess The post process to attach to the camera
  85888. * @param insertAt The position of the post process in case several of them are in use in the scene
  85889. * @returns the position the post process has been inserted at
  85890. */
  85891. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  85892. /**
  85893. * Detach a post process to the camera.
  85894. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  85895. * @param postProcess The post process to detach from the camera
  85896. */
  85897. detachPostProcess(postProcess: PostProcess): void;
  85898. /**
  85899. * Gets the current world matrix of the camera
  85900. */
  85901. getWorldMatrix(): Matrix;
  85902. /** @hidden */
  85903. _getViewMatrix(): Matrix;
  85904. /**
  85905. * Gets the current view matrix of the camera.
  85906. * @param force forces the camera to recompute the matrix without looking at the cached state
  85907. * @returns the view matrix
  85908. */
  85909. getViewMatrix(force?: boolean): Matrix;
  85910. /**
  85911. * Freeze the projection matrix.
  85912. * It will prevent the cache check of the camera projection compute and can speed up perf
  85913. * if no parameter of the camera are meant to change
  85914. * @param projection Defines manually a projection if necessary
  85915. */
  85916. freezeProjectionMatrix(projection?: Matrix): void;
  85917. /**
  85918. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  85919. */
  85920. unfreezeProjectionMatrix(): void;
  85921. /**
  85922. * Gets the current projection matrix of the camera.
  85923. * @param force forces the camera to recompute the matrix without looking at the cached state
  85924. * @returns the projection matrix
  85925. */
  85926. getProjectionMatrix(force?: boolean): Matrix;
  85927. /**
  85928. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  85929. * @returns a Matrix
  85930. */
  85931. getTransformationMatrix(): Matrix;
  85932. private _updateFrustumPlanes;
  85933. /**
  85934. * Checks if a cullable object (mesh...) is in the camera frustum
  85935. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  85936. * @param target The object to check
  85937. * @returns true if the object is in frustum otherwise false
  85938. */
  85939. isInFrustum(target: ICullable): boolean;
  85940. /**
  85941. * Checks if a cullable object (mesh...) is in the camera frustum
  85942. * Unlike isInFrustum this cheks the full bounding box
  85943. * @param target The object to check
  85944. * @returns true if the object is in frustum otherwise false
  85945. */
  85946. isCompletelyInFrustum(target: ICullable): boolean;
  85947. /**
  85948. * Gets a ray in the forward direction from the camera.
  85949. * @param length Defines the length of the ray to create
  85950. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  85951. * @param origin Defines the start point of the ray which defaults to the camera position
  85952. * @returns the forward ray
  85953. */
  85954. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  85955. /**
  85956. * Releases resources associated with this node.
  85957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85959. */
  85960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85961. /**
  85962. * Gets the left camera of a rig setup in case of Rigged Camera
  85963. */
  85964. readonly leftCamera: Nullable<FreeCamera>;
  85965. /**
  85966. * Gets the right camera of a rig setup in case of Rigged Camera
  85967. */
  85968. readonly rightCamera: Nullable<FreeCamera>;
  85969. /**
  85970. * Gets the left camera target of a rig setup in case of Rigged Camera
  85971. * @returns the target position
  85972. */
  85973. getLeftTarget(): Nullable<Vector3>;
  85974. /**
  85975. * Gets the right camera target of a rig setup in case of Rigged Camera
  85976. * @returns the target position
  85977. */
  85978. getRightTarget(): Nullable<Vector3>;
  85979. /**
  85980. * @hidden
  85981. */
  85982. setCameraRigMode(mode: number, rigParams: any): void;
  85983. /** @hidden */
  85984. static _setStereoscopicRigMode(camera: Camera): void;
  85985. /** @hidden */
  85986. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  85987. /** @hidden */
  85988. static _setVRRigMode(camera: Camera, rigParams: any): void;
  85989. /** @hidden */
  85990. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  85991. /** @hidden */
  85992. _getVRProjectionMatrix(): Matrix;
  85993. protected _updateCameraRotationMatrix(): void;
  85994. protected _updateWebVRCameraRotationMatrix(): void;
  85995. /**
  85996. * This function MUST be overwritten by the different WebVR cameras available.
  85997. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  85998. * @hidden
  85999. */
  86000. _getWebVRProjectionMatrix(): Matrix;
  86001. /**
  86002. * This function MUST be overwritten by the different WebVR cameras available.
  86003. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86004. * @hidden
  86005. */
  86006. _getWebVRViewMatrix(): Matrix;
  86007. /** @hidden */
  86008. setCameraRigParameter(name: string, value: any): void;
  86009. /**
  86010. * needs to be overridden by children so sub has required properties to be copied
  86011. * @hidden
  86012. */
  86013. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86014. /**
  86015. * May need to be overridden by children
  86016. * @hidden
  86017. */
  86018. _updateRigCameras(): void;
  86019. /** @hidden */
  86020. _setupInputs(): void;
  86021. /**
  86022. * Serialiaze the camera setup to a json represention
  86023. * @returns the JSON representation
  86024. */
  86025. serialize(): any;
  86026. /**
  86027. * Clones the current camera.
  86028. * @param name The cloned camera name
  86029. * @returns the cloned camera
  86030. */
  86031. clone(name: string): Camera;
  86032. /**
  86033. * Gets the direction of the camera relative to a given local axis.
  86034. * @param localAxis Defines the reference axis to provide a relative direction.
  86035. * @return the direction
  86036. */
  86037. getDirection(localAxis: Vector3): Vector3;
  86038. /**
  86039. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86040. * @param localAxis Defines the reference axis to provide a relative direction.
  86041. * @param result Defines the vector to store the result in
  86042. */
  86043. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86044. /**
  86045. * Gets a camera constructor for a given camera type
  86046. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86047. * @param name The name of the camera the result will be able to instantiate
  86048. * @param scene The scene the result will construct the camera in
  86049. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86050. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86051. * @returns a factory method to construc the camera
  86052. */
  86053. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86054. /**
  86055. * Compute the world matrix of the camera.
  86056. * @returns the camera workd matrix
  86057. */
  86058. computeWorldMatrix(): Matrix;
  86059. /**
  86060. * Parse a JSON and creates the camera from the parsed information
  86061. * @param parsedCamera The JSON to parse
  86062. * @param scene The scene to instantiate the camera in
  86063. * @returns the newly constructed camera
  86064. */
  86065. static Parse(parsedCamera: any, scene: Scene): Camera;
  86066. }
  86067. }
  86068. declare module BABYLON {
  86069. /**
  86070. * Interface for any object that can request an animation frame
  86071. */
  86072. export interface ICustomAnimationFrameRequester {
  86073. /**
  86074. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86075. */
  86076. renderFunction?: Function;
  86077. /**
  86078. * Called to request the next frame to render to
  86079. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86080. */
  86081. requestAnimationFrame: Function;
  86082. /**
  86083. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86084. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86085. */
  86086. requestID?: number;
  86087. }
  86088. /**
  86089. * Interface containing an array of animations
  86090. */
  86091. export interface IAnimatable {
  86092. /**
  86093. * Array of animations
  86094. */
  86095. animations: Array<Animation>;
  86096. }
  86097. /** Interface used by value gradients (color, factor, ...) */
  86098. export interface IValueGradient {
  86099. /**
  86100. * Gets or sets the gradient value (between 0 and 1)
  86101. */
  86102. gradient: number;
  86103. }
  86104. /** Class used to store color4 gradient */
  86105. export class ColorGradient implements IValueGradient {
  86106. /**
  86107. * Gets or sets the gradient value (between 0 and 1)
  86108. */
  86109. gradient: number;
  86110. /**
  86111. * Gets or sets first associated color
  86112. */
  86113. color1: Color4;
  86114. /**
  86115. * Gets or sets second associated color
  86116. */
  86117. color2?: Color4;
  86118. /**
  86119. * Will get a color picked randomly between color1 and color2.
  86120. * If color2 is undefined then color1 will be used
  86121. * @param result defines the target Color4 to store the result in
  86122. */
  86123. getColorToRef(result: Color4): void;
  86124. }
  86125. /** Class used to store color 3 gradient */
  86126. export class Color3Gradient implements IValueGradient {
  86127. /**
  86128. * Gets or sets the gradient value (between 0 and 1)
  86129. */
  86130. gradient: number;
  86131. /**
  86132. * Gets or sets the associated color
  86133. */
  86134. color: Color3;
  86135. }
  86136. /** Class used to store factor gradient */
  86137. export class FactorGradient implements IValueGradient {
  86138. /**
  86139. * Gets or sets the gradient value (between 0 and 1)
  86140. */
  86141. gradient: number;
  86142. /**
  86143. * Gets or sets first associated factor
  86144. */
  86145. factor1: number;
  86146. /**
  86147. * Gets or sets second associated factor
  86148. */
  86149. factor2?: number;
  86150. /**
  86151. * Will get a number picked randomly between factor1 and factor2.
  86152. * If factor2 is undefined then factor1 will be used
  86153. * @returns the picked number
  86154. */
  86155. getFactor(): number;
  86156. }
  86157. /**
  86158. * @ignore
  86159. * Application error to support additional information when loading a file
  86160. */
  86161. export class LoadFileError extends Error {
  86162. /** defines the optional XHR request */
  86163. request?: XMLHttpRequest | undefined;
  86164. private static _setPrototypeOf;
  86165. /**
  86166. * Creates a new LoadFileError
  86167. * @param message defines the message of the error
  86168. * @param request defines the optional XHR request
  86169. */
  86170. constructor(message: string,
  86171. /** defines the optional XHR request */
  86172. request?: XMLHttpRequest | undefined);
  86173. }
  86174. /**
  86175. * Class used to define a retry strategy when error happens while loading assets
  86176. */
  86177. export class RetryStrategy {
  86178. /**
  86179. * Function used to defines an exponential back off strategy
  86180. * @param maxRetries defines the maximum number of retries (3 by default)
  86181. * @param baseInterval defines the interval between retries
  86182. * @returns the strategy function to use
  86183. */
  86184. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86185. }
  86186. /**
  86187. * File request interface
  86188. */
  86189. export interface IFileRequest {
  86190. /**
  86191. * Raised when the request is complete (success or error).
  86192. */
  86193. onCompleteObservable: Observable<IFileRequest>;
  86194. /**
  86195. * Aborts the request for a file.
  86196. */
  86197. abort: () => void;
  86198. }
  86199. /**
  86200. * Class containing a set of static utilities functions
  86201. */
  86202. export class Tools {
  86203. /**
  86204. * Gets or sets the base URL to use to load assets
  86205. */
  86206. static BaseUrl: string;
  86207. /**
  86208. * Enable/Disable Custom HTTP Request Headers globally.
  86209. * default = false
  86210. * @see CustomRequestHeaders
  86211. */
  86212. static UseCustomRequestHeaders: boolean;
  86213. /**
  86214. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86215. * i.e. when loading files, where the server/service expects an Authorization header.
  86216. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86217. */
  86218. static CustomRequestHeaders: {
  86219. [key: string]: string;
  86220. };
  86221. /**
  86222. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86223. */
  86224. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86225. /**
  86226. * Default behaviour for cors in the application.
  86227. * It can be a string if the expected behavior is identical in the entire app.
  86228. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86229. */
  86230. static CorsBehavior: string | ((url: string | string[]) => string);
  86231. /**
  86232. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86233. * @ignorenaming
  86234. */
  86235. static UseFallbackTexture: boolean;
  86236. /**
  86237. * Use this object to register external classes like custom textures or material
  86238. * to allow the laoders to instantiate them
  86239. */
  86240. static RegisteredExternalClasses: {
  86241. [key: string]: Object;
  86242. };
  86243. /**
  86244. * Texture content used if a texture cannot loaded
  86245. * @ignorenaming
  86246. */
  86247. static fallbackTexture: string;
  86248. /**
  86249. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86250. * @param u defines the coordinate on X axis
  86251. * @param v defines the coordinate on Y axis
  86252. * @param width defines the width of the source data
  86253. * @param height defines the height of the source data
  86254. * @param pixels defines the source byte array
  86255. * @param color defines the output color
  86256. */
  86257. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86258. /**
  86259. * Interpolates between a and b via alpha
  86260. * @param a The lower value (returned when alpha = 0)
  86261. * @param b The upper value (returned when alpha = 1)
  86262. * @param alpha The interpolation-factor
  86263. * @return The mixed value
  86264. */
  86265. static Mix(a: number, b: number, alpha: number): number;
  86266. /**
  86267. * Tries to instantiate a new object from a given class name
  86268. * @param className defines the class name to instantiate
  86269. * @returns the new object or null if the system was not able to do the instantiation
  86270. */
  86271. static Instantiate(className: string): any;
  86272. /**
  86273. * Provides a slice function that will work even on IE
  86274. * @param data defines the array to slice
  86275. * @param start defines the start of the data (optional)
  86276. * @param end defines the end of the data (optional)
  86277. * @returns the new sliced array
  86278. */
  86279. static Slice<T>(data: T, start?: number, end?: number): T;
  86280. /**
  86281. * Polyfill for setImmediate
  86282. * @param action defines the action to execute after the current execution block
  86283. */
  86284. static SetImmediate(action: () => void): void;
  86285. /**
  86286. * Function indicating if a number is an exponent of 2
  86287. * @param value defines the value to test
  86288. * @returns true if the value is an exponent of 2
  86289. */
  86290. static IsExponentOfTwo(value: number): boolean;
  86291. private static _tmpFloatArray;
  86292. /**
  86293. * Returns the nearest 32-bit single precision float representation of a Number
  86294. * @param value A Number. If the parameter is of a different type, it will get converted
  86295. * to a number or to NaN if it cannot be converted
  86296. * @returns number
  86297. */
  86298. static FloatRound(value: number): number;
  86299. /**
  86300. * Find the next highest power of two.
  86301. * @param x Number to start search from.
  86302. * @return Next highest power of two.
  86303. */
  86304. static CeilingPOT(x: number): number;
  86305. /**
  86306. * Find the next lowest power of two.
  86307. * @param x Number to start search from.
  86308. * @return Next lowest power of two.
  86309. */
  86310. static FloorPOT(x: number): number;
  86311. /**
  86312. * Find the nearest power of two.
  86313. * @param x Number to start search from.
  86314. * @return Next nearest power of two.
  86315. */
  86316. static NearestPOT(x: number): number;
  86317. /**
  86318. * Get the closest exponent of two
  86319. * @param value defines the value to approximate
  86320. * @param max defines the maximum value to return
  86321. * @param mode defines how to define the closest value
  86322. * @returns closest exponent of two of the given value
  86323. */
  86324. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86325. /**
  86326. * Extracts the filename from a path
  86327. * @param path defines the path to use
  86328. * @returns the filename
  86329. */
  86330. static GetFilename(path: string): string;
  86331. /**
  86332. * Extracts the "folder" part of a path (everything before the filename).
  86333. * @param uri The URI to extract the info from
  86334. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86335. * @returns The "folder" part of the path
  86336. */
  86337. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86338. /**
  86339. * Extracts text content from a DOM element hierarchy
  86340. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86341. */
  86342. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86343. /**
  86344. * Convert an angle in radians to degrees
  86345. * @param angle defines the angle to convert
  86346. * @returns the angle in degrees
  86347. */
  86348. static ToDegrees(angle: number): number;
  86349. /**
  86350. * Convert an angle in degrees to radians
  86351. * @param angle defines the angle to convert
  86352. * @returns the angle in radians
  86353. */
  86354. static ToRadians(angle: number): number;
  86355. /**
  86356. * Encode a buffer to a base64 string
  86357. * @param buffer defines the buffer to encode
  86358. * @returns the encoded string
  86359. */
  86360. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86361. /**
  86362. * Extracts minimum and maximum values from a list of indexed positions
  86363. * @param positions defines the positions to use
  86364. * @param indices defines the indices to the positions
  86365. * @param indexStart defines the start index
  86366. * @param indexCount defines the end index
  86367. * @param bias defines bias value to add to the result
  86368. * @return minimum and maximum values
  86369. */
  86370. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86371. minimum: Vector3;
  86372. maximum: Vector3;
  86373. };
  86374. /**
  86375. * Extracts minimum and maximum values from a list of positions
  86376. * @param positions defines the positions to use
  86377. * @param start defines the start index in the positions array
  86378. * @param count defines the number of positions to handle
  86379. * @param bias defines bias value to add to the result
  86380. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86381. * @return minimum and maximum values
  86382. */
  86383. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86384. minimum: Vector3;
  86385. maximum: Vector3;
  86386. };
  86387. /**
  86388. * Returns an array if obj is not an array
  86389. * @param obj defines the object to evaluate as an array
  86390. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86391. * @returns either obj directly if obj is an array or a new array containing obj
  86392. */
  86393. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86394. /**
  86395. * Gets the pointer prefix to use
  86396. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86397. */
  86398. static GetPointerPrefix(): string;
  86399. /**
  86400. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86401. * @param func - the function to be called
  86402. * @param requester - the object that will request the next frame. Falls back to window.
  86403. * @returns frame number
  86404. */
  86405. static QueueNewFrame(func: () => void, requester?: any): number;
  86406. /**
  86407. * Ask the browser to promote the current element to fullscreen rendering mode
  86408. * @param element defines the DOM element to promote
  86409. */
  86410. static RequestFullscreen(element: HTMLElement): void;
  86411. /**
  86412. * Asks the browser to exit fullscreen mode
  86413. */
  86414. static ExitFullscreen(): void;
  86415. /**
  86416. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86417. * @param url define the url we are trying
  86418. * @param element define the dom element where to configure the cors policy
  86419. */
  86420. static SetCorsBehavior(url: string | string[], element: {
  86421. crossOrigin: string | null;
  86422. }): void;
  86423. /**
  86424. * Removes unwanted characters from an url
  86425. * @param url defines the url to clean
  86426. * @returns the cleaned url
  86427. */
  86428. static CleanUrl(url: string): string;
  86429. /**
  86430. * Gets or sets a function used to pre-process url before using them to load assets
  86431. */
  86432. static PreprocessUrl: (url: string) => string;
  86433. /**
  86434. * Loads an image as an HTMLImageElement.
  86435. * @param input url string, ArrayBuffer, or Blob to load
  86436. * @param onLoad callback called when the image successfully loads
  86437. * @param onError callback called when the image fails to load
  86438. * @param offlineProvider offline provider for caching
  86439. * @returns the HTMLImageElement of the loaded image
  86440. */
  86441. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86442. /**
  86443. * Loads a file
  86444. * @param url url string, ArrayBuffer, or Blob to load
  86445. * @param onSuccess callback called when the file successfully loads
  86446. * @param onProgress callback called while file is loading (if the server supports this mode)
  86447. * @param offlineProvider defines the offline provider for caching
  86448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86449. * @param onError callback called when the file fails to load
  86450. * @returns a file request object
  86451. */
  86452. 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;
  86453. /**
  86454. * Load a script (identified by an url). When the url returns, the
  86455. * content of this file is added into a new script element, attached to the DOM (body element)
  86456. * @param scriptUrl defines the url of the script to laod
  86457. * @param onSuccess defines the callback called when the script is loaded
  86458. * @param onError defines the callback to call if an error occurs
  86459. */
  86460. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86461. /**
  86462. * Loads a file from a blob
  86463. * @param fileToLoad defines the blob to use
  86464. * @param callback defines the callback to call when data is loaded
  86465. * @param progressCallback defines the callback to call during loading process
  86466. * @returns a file request object
  86467. */
  86468. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86469. /**
  86470. * Loads a file
  86471. * @param fileToLoad defines the file to load
  86472. * @param callback defines the callback to call when data is loaded
  86473. * @param progressCallBack defines the callback to call during loading process
  86474. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86475. * @returns a file request object
  86476. */
  86477. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  86478. /**
  86479. * Creates a data url from a given string content
  86480. * @param content defines the content to convert
  86481. * @returns the new data url link
  86482. */
  86483. static FileAsURL(content: string): string;
  86484. /**
  86485. * Format the given number to a specific decimal format
  86486. * @param value defines the number to format
  86487. * @param decimals defines the number of decimals to use
  86488. * @returns the formatted string
  86489. */
  86490. static Format(value: number, decimals?: number): string;
  86491. /**
  86492. * Checks if a given vector is inside a specific range
  86493. * @param v defines the vector to test
  86494. * @param min defines the minimum range
  86495. * @param max defines the maximum range
  86496. */
  86497. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  86498. /**
  86499. * Tries to copy an object by duplicating every property
  86500. * @param source defines the source object
  86501. * @param destination defines the target object
  86502. * @param doNotCopyList defines a list of properties to avoid
  86503. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  86504. */
  86505. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  86506. /**
  86507. * Gets a boolean indicating if the given object has no own property
  86508. * @param obj defines the object to test
  86509. * @returns true if object has no own property
  86510. */
  86511. static IsEmpty(obj: any): boolean;
  86512. /**
  86513. * Function used to register events at window level
  86514. * @param events defines the events to register
  86515. */
  86516. static RegisterTopRootEvents(events: {
  86517. name: string;
  86518. handler: Nullable<(e: FocusEvent) => any>;
  86519. }[]): void;
  86520. /**
  86521. * Function used to unregister events from window level
  86522. * @param events defines the events to unregister
  86523. */
  86524. static UnregisterTopRootEvents(events: {
  86525. name: string;
  86526. handler: Nullable<(e: FocusEvent) => any>;
  86527. }[]): void;
  86528. /**
  86529. * Dumps the current bound framebuffer
  86530. * @param width defines the rendering width
  86531. * @param height defines the rendering height
  86532. * @param engine defines the hosting engine
  86533. * @param successCallback defines the callback triggered once the data are available
  86534. * @param mimeType defines the mime type of the result
  86535. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  86536. */
  86537. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86538. /**
  86539. * Converts the canvas data to blob.
  86540. * This acts as a polyfill for browsers not supporting the to blob function.
  86541. * @param canvas Defines the canvas to extract the data from
  86542. * @param successCallback Defines the callback triggered once the data are available
  86543. * @param mimeType Defines the mime type of the result
  86544. */
  86545. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  86546. /**
  86547. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  86548. * @param successCallback defines the callback triggered once the data are available
  86549. * @param mimeType defines the mime type of the result
  86550. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  86551. */
  86552. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86553. /**
  86554. * Downloads a blob in the browser
  86555. * @param blob defines the blob to download
  86556. * @param fileName defines the name of the downloaded file
  86557. */
  86558. static Download(blob: Blob, fileName: string): void;
  86559. /**
  86560. * Captures a screenshot of the current rendering
  86561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86562. * @param engine defines the rendering engine
  86563. * @param camera defines the source camera
  86564. * @param size This parameter can be set to a single number or to an object with the
  86565. * following (optional) properties: precision, width, height. If a single number is passed,
  86566. * it will be used for both width and height. If an object is passed, the screenshot size
  86567. * will be derived from the parameters. The precision property is a multiplier allowing
  86568. * rendering at a higher or lower resolution
  86569. * @param successCallback defines the callback receives a single parameter which contains the
  86570. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86571. * src parameter of an <img> to display it
  86572. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  86573. * Check your browser for supported MIME types
  86574. */
  86575. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  86576. /**
  86577. * Generates an image screenshot from the specified camera.
  86578. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86579. * @param engine The engine to use for rendering
  86580. * @param camera The camera to use for rendering
  86581. * @param size This parameter can be set to a single number or to an object with the
  86582. * following (optional) properties: precision, width, height. If a single number is passed,
  86583. * it will be used for both width and height. If an object is passed, the screenshot size
  86584. * will be derived from the parameters. The precision property is a multiplier allowing
  86585. * rendering at a higher or lower resolution
  86586. * @param successCallback The callback receives a single parameter which contains the
  86587. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86588. * src parameter of an <img> to display it
  86589. * @param mimeType The MIME type of the screenshot image (default: image/png).
  86590. * Check your browser for supported MIME types
  86591. * @param samples Texture samples (default: 1)
  86592. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  86593. * @param fileName A name for for the downloaded file.
  86594. */
  86595. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  86596. /**
  86597. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86598. * Be aware Math.random() could cause collisions, but:
  86599. * "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"
  86600. * @returns a pseudo random id
  86601. */
  86602. static RandomId(): string;
  86603. /**
  86604. * Test if the given uri is a base64 string
  86605. * @param uri The uri to test
  86606. * @return True if the uri is a base64 string or false otherwise
  86607. */
  86608. static IsBase64(uri: string): boolean;
  86609. /**
  86610. * Decode the given base64 uri.
  86611. * @param uri The uri to decode
  86612. * @return The decoded base64 data.
  86613. */
  86614. static DecodeBase64(uri: string): ArrayBuffer;
  86615. /**
  86616. * No log
  86617. */
  86618. static readonly NoneLogLevel: number;
  86619. /**
  86620. * Only message logs
  86621. */
  86622. static readonly MessageLogLevel: number;
  86623. /**
  86624. * Only warning logs
  86625. */
  86626. static readonly WarningLogLevel: number;
  86627. /**
  86628. * Only error logs
  86629. */
  86630. static readonly ErrorLogLevel: number;
  86631. /**
  86632. * All logs
  86633. */
  86634. static readonly AllLogLevel: number;
  86635. /**
  86636. * Gets a value indicating the number of loading errors
  86637. * @ignorenaming
  86638. */
  86639. static readonly errorsCount: number;
  86640. /**
  86641. * Callback called when a new log is added
  86642. */
  86643. static OnNewCacheEntry: (entry: string) => void;
  86644. /**
  86645. * Log a message to the console
  86646. * @param message defines the message to log
  86647. */
  86648. static Log(message: string): void;
  86649. /**
  86650. * Write a warning message to the console
  86651. * @param message defines the message to log
  86652. */
  86653. static Warn(message: string): void;
  86654. /**
  86655. * Write an error message to the console
  86656. * @param message defines the message to log
  86657. */
  86658. static Error(message: string): void;
  86659. /**
  86660. * Gets current log cache (list of logs)
  86661. */
  86662. static readonly LogCache: string;
  86663. /**
  86664. * Clears the log cache
  86665. */
  86666. static ClearLogCache(): void;
  86667. /**
  86668. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  86669. */
  86670. static LogLevels: number;
  86671. /**
  86672. * Checks if the loaded document was accessed via `file:`-Protocol.
  86673. * @returns boolean
  86674. */
  86675. static IsFileURL(): boolean;
  86676. /**
  86677. * Checks if the window object exists
  86678. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  86679. */
  86680. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  86681. /**
  86682. * No performance log
  86683. */
  86684. static readonly PerformanceNoneLogLevel: number;
  86685. /**
  86686. * Use user marks to log performance
  86687. */
  86688. static readonly PerformanceUserMarkLogLevel: number;
  86689. /**
  86690. * Log performance to the console
  86691. */
  86692. static readonly PerformanceConsoleLogLevel: number;
  86693. private static _performance;
  86694. /**
  86695. * Sets the current performance log level
  86696. */
  86697. static PerformanceLogLevel: number;
  86698. private static _StartPerformanceCounterDisabled;
  86699. private static _EndPerformanceCounterDisabled;
  86700. private static _StartUserMark;
  86701. private static _EndUserMark;
  86702. private static _StartPerformanceConsole;
  86703. private static _EndPerformanceConsole;
  86704. /**
  86705. * Injects the @see CustomRequestHeaders into the given request
  86706. * @param request the request that should be used for injection
  86707. */
  86708. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  86709. /**
  86710. * Starts a performance counter
  86711. */
  86712. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86713. /**
  86714. * Ends a specific performance coutner
  86715. */
  86716. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86717. /**
  86718. * Gets either window.performance.now() if supported or Date.now() else
  86719. */
  86720. static readonly Now: number;
  86721. /**
  86722. * This method will return the name of the class used to create the instance of the given object.
  86723. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  86724. * @param object the object to get the class name from
  86725. * @param isType defines if the object is actually a type
  86726. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  86727. */
  86728. static GetClassName(object: any, isType?: boolean): string;
  86729. /**
  86730. * Gets the first element of an array satisfying a given predicate
  86731. * @param array defines the array to browse
  86732. * @param predicate defines the predicate to use
  86733. * @returns null if not found or the element
  86734. */
  86735. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  86736. /**
  86737. * This method will return the name of the full name of the class, including its owning module (if any).
  86738. * 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).
  86739. * @param object the object to get the class name from
  86740. * @param isType defines if the object is actually a type
  86741. * @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.
  86742. * @ignorenaming
  86743. */
  86744. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  86745. /**
  86746. * Returns a promise that resolves after the given amount of time.
  86747. * @param delay Number of milliseconds to delay
  86748. * @returns Promise that resolves after the given amount of time
  86749. */
  86750. static DelayAsync(delay: number): Promise<void>;
  86751. /**
  86752. * Gets the current gradient from an array of IValueGradient
  86753. * @param ratio defines the current ratio to get
  86754. * @param gradients defines the array of IValueGradient
  86755. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86756. */
  86757. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86758. }
  86759. /**
  86760. * This class is used to track a performance counter which is number based.
  86761. * The user has access to many properties which give statistics of different nature.
  86762. *
  86763. * The implementer can track two kinds of Performance Counter: time and count.
  86764. * 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.
  86765. * 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.
  86766. */
  86767. export class PerfCounter {
  86768. /**
  86769. * Gets or sets a global boolean to turn on and off all the counters
  86770. */
  86771. static Enabled: boolean;
  86772. /**
  86773. * Returns the smallest value ever
  86774. */
  86775. readonly min: number;
  86776. /**
  86777. * Returns the biggest value ever
  86778. */
  86779. readonly max: number;
  86780. /**
  86781. * Returns the average value since the performance counter is running
  86782. */
  86783. readonly average: number;
  86784. /**
  86785. * Returns the average value of the last second the counter was monitored
  86786. */
  86787. readonly lastSecAverage: number;
  86788. /**
  86789. * Returns the current value
  86790. */
  86791. readonly current: number;
  86792. /**
  86793. * Gets the accumulated total
  86794. */
  86795. readonly total: number;
  86796. /**
  86797. * Gets the total value count
  86798. */
  86799. readonly count: number;
  86800. /**
  86801. * Creates a new counter
  86802. */
  86803. constructor();
  86804. /**
  86805. * Call this method to start monitoring a new frame.
  86806. * 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.
  86807. */
  86808. fetchNewFrame(): void;
  86809. /**
  86810. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  86811. * @param newCount the count value to add to the monitored count
  86812. * @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.
  86813. */
  86814. addCount(newCount: number, fetchResult: boolean): void;
  86815. /**
  86816. * Start monitoring this performance counter
  86817. */
  86818. beginMonitoring(): void;
  86819. /**
  86820. * Compute the time lapsed since the previous beginMonitoring() call.
  86821. * @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
  86822. */
  86823. endMonitoring(newFrame?: boolean): void;
  86824. private _fetchResult;
  86825. private _startMonitoringTime;
  86826. private _min;
  86827. private _max;
  86828. private _average;
  86829. private _current;
  86830. private _totalValueCount;
  86831. private _totalAccumulated;
  86832. private _lastSecAverage;
  86833. private _lastSecAccumulated;
  86834. private _lastSecTime;
  86835. private _lastSecValueCount;
  86836. }
  86837. /**
  86838. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  86839. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  86840. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  86841. * @param name The name of the class, case should be preserved
  86842. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  86843. */
  86844. export function className(name: string, module?: string): (target: Object) => void;
  86845. /**
  86846. * An implementation of a loop for asynchronous functions.
  86847. */
  86848. export class AsyncLoop {
  86849. /**
  86850. * Defines the number of iterations for the loop
  86851. */
  86852. iterations: number;
  86853. /**
  86854. * Defines the current index of the loop.
  86855. */
  86856. index: number;
  86857. private _done;
  86858. private _fn;
  86859. private _successCallback;
  86860. /**
  86861. * Constructor.
  86862. * @param iterations the number of iterations.
  86863. * @param func the function to run each iteration
  86864. * @param successCallback the callback that will be called upon succesful execution
  86865. * @param offset starting offset.
  86866. */
  86867. constructor(
  86868. /**
  86869. * Defines the number of iterations for the loop
  86870. */
  86871. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  86872. /**
  86873. * Execute the next iteration. Must be called after the last iteration was finished.
  86874. */
  86875. executeNext(): void;
  86876. /**
  86877. * Break the loop and run the success callback.
  86878. */
  86879. breakLoop(): void;
  86880. /**
  86881. * Create and run an async loop.
  86882. * @param iterations the number of iterations.
  86883. * @param fn the function to run each iteration
  86884. * @param successCallback the callback that will be called upon succesful execution
  86885. * @param offset starting offset.
  86886. * @returns the created async loop object
  86887. */
  86888. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  86889. /**
  86890. * A for-loop that will run a given number of iterations synchronous and the rest async.
  86891. * @param iterations total number of iterations
  86892. * @param syncedIterations number of synchronous iterations in each async iteration.
  86893. * @param fn the function to call each iteration.
  86894. * @param callback a success call back that will be called when iterating stops.
  86895. * @param breakFunction a break condition (optional)
  86896. * @param timeout timeout settings for the setTimeout function. default - 0.
  86897. * @returns the created async loop object
  86898. */
  86899. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  86900. }
  86901. }
  86902. declare module BABYLON {
  86903. /**
  86904. * This class defines the direct association between an animation and a target
  86905. */
  86906. export class TargetedAnimation {
  86907. /**
  86908. * Animation to perform
  86909. */
  86910. animation: Animation;
  86911. /**
  86912. * Target to animate
  86913. */
  86914. target: any;
  86915. }
  86916. /**
  86917. * Use this class to create coordinated animations on multiple targets
  86918. */
  86919. export class AnimationGroup implements IDisposable {
  86920. /** The name of the animation group */
  86921. name: string;
  86922. private _scene;
  86923. private _targetedAnimations;
  86924. private _animatables;
  86925. private _from;
  86926. private _to;
  86927. private _isStarted;
  86928. private _isPaused;
  86929. private _speedRatio;
  86930. /**
  86931. * Gets or sets the unique id of the node
  86932. */
  86933. uniqueId: number;
  86934. /**
  86935. * This observable will notify when one animation have ended
  86936. */
  86937. onAnimationEndObservable: Observable<TargetedAnimation>;
  86938. /**
  86939. * Observer raised when one animation loops
  86940. */
  86941. onAnimationLoopObservable: Observable<TargetedAnimation>;
  86942. /**
  86943. * This observable will notify when all animations have ended.
  86944. */
  86945. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  86946. /**
  86947. * This observable will notify when all animations have paused.
  86948. */
  86949. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  86950. /**
  86951. * This observable will notify when all animations are playing.
  86952. */
  86953. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  86954. /**
  86955. * Gets the first frame
  86956. */
  86957. readonly from: number;
  86958. /**
  86959. * Gets the last frame
  86960. */
  86961. readonly to: number;
  86962. /**
  86963. * Define if the animations are started
  86964. */
  86965. readonly isStarted: boolean;
  86966. /**
  86967. * Gets a value indicating that the current group is playing
  86968. */
  86969. readonly isPlaying: boolean;
  86970. /**
  86971. * Gets or sets the speed ratio to use for all animations
  86972. */
  86973. /**
  86974. * Gets or sets the speed ratio to use for all animations
  86975. */
  86976. speedRatio: number;
  86977. /**
  86978. * Gets the targeted animations for this animation group
  86979. */
  86980. readonly targetedAnimations: Array<TargetedAnimation>;
  86981. /**
  86982. * returning the list of animatables controlled by this animation group.
  86983. */
  86984. readonly animatables: Array<Animatable>;
  86985. /**
  86986. * Instantiates a new Animation Group.
  86987. * This helps managing several animations at once.
  86988. * @see http://doc.babylonjs.com/how_to/group
  86989. * @param name Defines the name of the group
  86990. * @param scene Defines the scene the group belongs to
  86991. */
  86992. constructor(
  86993. /** The name of the animation group */
  86994. name: string, scene?: Nullable<Scene>);
  86995. /**
  86996. * Add an animation (with its target) in the group
  86997. * @param animation defines the animation we want to add
  86998. * @param target defines the target of the animation
  86999. * @returns the TargetedAnimation object
  87000. */
  87001. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87002. /**
  87003. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87004. * It can add constant keys at begin or end
  87005. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87006. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87007. * @returns the animation group
  87008. */
  87009. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87010. /**
  87011. * Start all animations on given targets
  87012. * @param loop defines if animations must loop
  87013. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87014. * @param from defines the from key (optional)
  87015. * @param to defines the to key (optional)
  87016. * @returns the current animation group
  87017. */
  87018. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87019. /**
  87020. * Pause all animations
  87021. * @returns the animation group
  87022. */
  87023. pause(): AnimationGroup;
  87024. /**
  87025. * Play all animations to initial state
  87026. * This function will start() the animations if they were not started or will restart() them if they were paused
  87027. * @param loop defines if animations must loop
  87028. * @returns the animation group
  87029. */
  87030. play(loop?: boolean): AnimationGroup;
  87031. /**
  87032. * Reset all animations to initial state
  87033. * @returns the animation group
  87034. */
  87035. reset(): AnimationGroup;
  87036. /**
  87037. * Restart animations from key 0
  87038. * @returns the animation group
  87039. */
  87040. restart(): AnimationGroup;
  87041. /**
  87042. * Stop all animations
  87043. * @returns the animation group
  87044. */
  87045. stop(): AnimationGroup;
  87046. /**
  87047. * Set animation weight for all animatables
  87048. * @param weight defines the weight to use
  87049. * @return the animationGroup
  87050. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87051. */
  87052. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87053. /**
  87054. * Synchronize and normalize all animatables with a source animatable
  87055. * @param root defines the root animatable to synchronize with
  87056. * @return the animationGroup
  87057. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87058. */
  87059. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87060. /**
  87061. * Goes to a specific frame in this animation group
  87062. * @param frame the frame number to go to
  87063. * @return the animationGroup
  87064. */
  87065. goToFrame(frame: number): AnimationGroup;
  87066. /**
  87067. * Dispose all associated resources
  87068. */
  87069. dispose(): void;
  87070. private _checkAnimationGroupEnded;
  87071. /**
  87072. * Returns a new AnimationGroup object parsed from the source provided.
  87073. * @param parsedAnimationGroup defines the source
  87074. * @param scene defines the scene that will receive the animationGroup
  87075. * @returns a new AnimationGroup
  87076. */
  87077. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87078. /**
  87079. * Returns the string "AnimationGroup"
  87080. * @returns "AnimationGroup"
  87081. */
  87082. getClassName(): string;
  87083. /**
  87084. * Creates a detailled string about the object
  87085. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87086. * @returns a string representing the object
  87087. */
  87088. toString(fullDetails?: boolean): string;
  87089. }
  87090. }
  87091. declare module BABYLON {
  87092. /** @hidden */
  87093. export interface ICollisionCoordinator {
  87094. createCollider(): Collider;
  87095. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87096. init(scene: Scene): void;
  87097. }
  87098. /** @hidden */
  87099. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87100. private _scene;
  87101. private _scaledPosition;
  87102. private _scaledVelocity;
  87103. private _finalPosition;
  87104. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87105. createCollider(): Collider;
  87106. init(scene: Scene): void;
  87107. private _collideWithWorld;
  87108. }
  87109. }
  87110. declare module BABYLON {
  87111. /**
  87112. * Define an interface for all classes that will hold resources
  87113. */
  87114. export interface IDisposable {
  87115. /**
  87116. * Releases all held resources
  87117. */
  87118. dispose(): void;
  87119. }
  87120. /** Interface defining initialization parameters for Scene class */
  87121. export interface SceneOptions {
  87122. /**
  87123. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87124. * It will improve performance when the number of geometries becomes important.
  87125. */
  87126. useGeometryUniqueIdsMap?: boolean;
  87127. /**
  87128. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87129. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87130. */
  87131. useMaterialMeshMap?: boolean;
  87132. /**
  87133. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87134. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87135. */
  87136. useClonedMeshhMap?: boolean;
  87137. }
  87138. /**
  87139. * Represents a scene to be rendered by the engine.
  87140. * @see http://doc.babylonjs.com/features/scene
  87141. */
  87142. export class Scene extends AbstractScene implements IAnimatable {
  87143. private static _uniqueIdCounter;
  87144. /** The fog is deactivated */
  87145. static readonly FOGMODE_NONE: number;
  87146. /** The fog density is following an exponential function */
  87147. static readonly FOGMODE_EXP: number;
  87148. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87149. static readonly FOGMODE_EXP2: number;
  87150. /** The fog density is following a linear function. */
  87151. static readonly FOGMODE_LINEAR: number;
  87152. /**
  87153. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87154. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87155. */
  87156. static MinDeltaTime: number;
  87157. /**
  87158. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87160. */
  87161. static MaxDeltaTime: number;
  87162. /**
  87163. * Factory used to create the default material.
  87164. * @param name The name of the material to create
  87165. * @param scene The scene to create the material for
  87166. * @returns The default material
  87167. */
  87168. static DefaultMaterialFactory(scene: Scene): Material;
  87169. /**
  87170. * Factory used to create the a collision coordinator.
  87171. * @returns The collision coordinator
  87172. */
  87173. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87174. /** @hidden */
  87175. readonly _isScene: boolean;
  87176. /**
  87177. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87178. */
  87179. autoClear: boolean;
  87180. /**
  87181. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87182. */
  87183. autoClearDepthAndStencil: boolean;
  87184. /**
  87185. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87186. */
  87187. clearColor: Color4;
  87188. /**
  87189. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87190. */
  87191. ambientColor: Color3;
  87192. /** @hidden */
  87193. _environmentBRDFTexture: BaseTexture;
  87194. /** @hidden */
  87195. protected _environmentTexture: Nullable<BaseTexture>;
  87196. /**
  87197. * Texture used in all pbr material as the reflection texture.
  87198. * As in the majority of the scene they are the same (exception for multi room and so on),
  87199. * this is easier to reference from here than from all the materials.
  87200. */
  87201. /**
  87202. * Texture used in all pbr material as the reflection texture.
  87203. * As in the majority of the scene they are the same (exception for multi room and so on),
  87204. * this is easier to set here than in all the materials.
  87205. */
  87206. environmentTexture: Nullable<BaseTexture>;
  87207. /** @hidden */
  87208. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87209. /**
  87210. * Default image processing configuration used either in the rendering
  87211. * Forward main pass or through the imageProcessingPostProcess if present.
  87212. * As in the majority of the scene they are the same (exception for multi camera),
  87213. * this is easier to reference from here than from all the materials and post process.
  87214. *
  87215. * No setter as we it is a shared configuration, you can set the values instead.
  87216. */
  87217. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87218. private _forceWireframe;
  87219. /**
  87220. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87221. */
  87222. forceWireframe: boolean;
  87223. private _forcePointsCloud;
  87224. /**
  87225. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87226. */
  87227. forcePointsCloud: boolean;
  87228. /**
  87229. * Gets or sets the active clipplane 1
  87230. */
  87231. clipPlane: Nullable<Plane>;
  87232. /**
  87233. * Gets or sets the active clipplane 2
  87234. */
  87235. clipPlane2: Nullable<Plane>;
  87236. /**
  87237. * Gets or sets the active clipplane 3
  87238. */
  87239. clipPlane3: Nullable<Plane>;
  87240. /**
  87241. * Gets or sets the active clipplane 4
  87242. */
  87243. clipPlane4: Nullable<Plane>;
  87244. /**
  87245. * Gets or sets a boolean indicating if animations are enabled
  87246. */
  87247. animationsEnabled: boolean;
  87248. private _animationPropertiesOverride;
  87249. /**
  87250. * Gets or sets the animation properties override
  87251. */
  87252. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87253. /**
  87254. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87255. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87256. */
  87257. useConstantAnimationDeltaTime: boolean;
  87258. /**
  87259. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87260. * Please note that it requires to run a ray cast through the scene on every frame
  87261. */
  87262. constantlyUpdateMeshUnderPointer: boolean;
  87263. /**
  87264. * Defines the HTML cursor to use when hovering over interactive elements
  87265. */
  87266. hoverCursor: string;
  87267. /**
  87268. * Defines the HTML default cursor to use (empty by default)
  87269. */
  87270. defaultCursor: string;
  87271. /**
  87272. * This is used to call preventDefault() on pointer down
  87273. * in order to block unwanted artifacts like system double clicks
  87274. */
  87275. preventDefaultOnPointerDown: boolean;
  87276. /**
  87277. * This is used to call preventDefault() on pointer up
  87278. * in order to block unwanted artifacts like system double clicks
  87279. */
  87280. preventDefaultOnPointerUp: boolean;
  87281. /**
  87282. * Gets or sets user defined metadata
  87283. */
  87284. metadata: any;
  87285. /**
  87286. * For internal use only. Please do not use.
  87287. */
  87288. reservedDataStore: any;
  87289. /**
  87290. * Gets the name of the plugin used to load this scene (null by default)
  87291. */
  87292. loadingPluginName: string;
  87293. /**
  87294. * Use this array to add regular expressions used to disable offline support for specific urls
  87295. */
  87296. disableOfflineSupportExceptionRules: RegExp[];
  87297. /**
  87298. * An event triggered when the scene is disposed.
  87299. */
  87300. onDisposeObservable: Observable<Scene>;
  87301. private _onDisposeObserver;
  87302. /** Sets a function to be executed when this scene is disposed. */
  87303. onDispose: () => void;
  87304. /**
  87305. * An event triggered before rendering the scene (right after animations and physics)
  87306. */
  87307. onBeforeRenderObservable: Observable<Scene>;
  87308. private _onBeforeRenderObserver;
  87309. /** Sets a function to be executed before rendering this scene */
  87310. beforeRender: Nullable<() => void>;
  87311. /**
  87312. * An event triggered after rendering the scene
  87313. */
  87314. onAfterRenderObservable: Observable<Scene>;
  87315. private _onAfterRenderObserver;
  87316. /** Sets a function to be executed after rendering this scene */
  87317. afterRender: Nullable<() => void>;
  87318. /**
  87319. * An event triggered before animating the scene
  87320. */
  87321. onBeforeAnimationsObservable: Observable<Scene>;
  87322. /**
  87323. * An event triggered after animations processing
  87324. */
  87325. onAfterAnimationsObservable: Observable<Scene>;
  87326. /**
  87327. * An event triggered before draw calls are ready to be sent
  87328. */
  87329. onBeforeDrawPhaseObservable: Observable<Scene>;
  87330. /**
  87331. * An event triggered after draw calls have been sent
  87332. */
  87333. onAfterDrawPhaseObservable: Observable<Scene>;
  87334. /**
  87335. * An event triggered when the scene is ready
  87336. */
  87337. onReadyObservable: Observable<Scene>;
  87338. /**
  87339. * An event triggered before rendering a camera
  87340. */
  87341. onBeforeCameraRenderObservable: Observable<Camera>;
  87342. private _onBeforeCameraRenderObserver;
  87343. /** Sets a function to be executed before rendering a camera*/
  87344. beforeCameraRender: () => void;
  87345. /**
  87346. * An event triggered after rendering a camera
  87347. */
  87348. onAfterCameraRenderObservable: Observable<Camera>;
  87349. private _onAfterCameraRenderObserver;
  87350. /** Sets a function to be executed after rendering a camera*/
  87351. afterCameraRender: () => void;
  87352. /**
  87353. * An event triggered when active meshes evaluation is about to start
  87354. */
  87355. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87356. /**
  87357. * An event triggered when active meshes evaluation is done
  87358. */
  87359. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87360. /**
  87361. * An event triggered when particles rendering is about to start
  87362. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87363. */
  87364. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87365. /**
  87366. * An event triggered when particles rendering is done
  87367. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87368. */
  87369. onAfterParticlesRenderingObservable: Observable<Scene>;
  87370. /**
  87371. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87372. */
  87373. onDataLoadedObservable: Observable<Scene>;
  87374. /**
  87375. * An event triggered when a camera is created
  87376. */
  87377. onNewCameraAddedObservable: Observable<Camera>;
  87378. /**
  87379. * An event triggered when a camera is removed
  87380. */
  87381. onCameraRemovedObservable: Observable<Camera>;
  87382. /**
  87383. * An event triggered when a light is created
  87384. */
  87385. onNewLightAddedObservable: Observable<Light>;
  87386. /**
  87387. * An event triggered when a light is removed
  87388. */
  87389. onLightRemovedObservable: Observable<Light>;
  87390. /**
  87391. * An event triggered when a geometry is created
  87392. */
  87393. onNewGeometryAddedObservable: Observable<Geometry>;
  87394. /**
  87395. * An event triggered when a geometry is removed
  87396. */
  87397. onGeometryRemovedObservable: Observable<Geometry>;
  87398. /**
  87399. * An event triggered when a transform node is created
  87400. */
  87401. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87402. /**
  87403. * An event triggered when a transform node is removed
  87404. */
  87405. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87406. /**
  87407. * An event triggered when a mesh is created
  87408. */
  87409. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87410. /**
  87411. * An event triggered when a mesh is removed
  87412. */
  87413. onMeshRemovedObservable: Observable<AbstractMesh>;
  87414. /**
  87415. * An event triggered when a material is created
  87416. */
  87417. onNewMaterialAddedObservable: Observable<Material>;
  87418. /**
  87419. * An event triggered when a material is removed
  87420. */
  87421. onMaterialRemovedObservable: Observable<Material>;
  87422. /**
  87423. * An event triggered when a texture is created
  87424. */
  87425. onNewTextureAddedObservable: Observable<BaseTexture>;
  87426. /**
  87427. * An event triggered when a texture is removed
  87428. */
  87429. onTextureRemovedObservable: Observable<BaseTexture>;
  87430. /**
  87431. * An event triggered when render targets are about to be rendered
  87432. * Can happen multiple times per frame.
  87433. */
  87434. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87435. /**
  87436. * An event triggered when render targets were rendered.
  87437. * Can happen multiple times per frame.
  87438. */
  87439. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87440. /**
  87441. * An event triggered before calculating deterministic simulation step
  87442. */
  87443. onBeforeStepObservable: Observable<Scene>;
  87444. /**
  87445. * An event triggered after calculating deterministic simulation step
  87446. */
  87447. onAfterStepObservable: Observable<Scene>;
  87448. /**
  87449. * An event triggered when the activeCamera property is updated
  87450. */
  87451. onActiveCameraChanged: Observable<Scene>;
  87452. /**
  87453. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87454. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87455. * 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)
  87456. */
  87457. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87458. /**
  87459. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87460. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87461. * 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)
  87462. */
  87463. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87464. /**
  87465. * This Observable will when a mesh has been imported into the scene.
  87466. */
  87467. onMeshImportedObservable: Observable<AbstractMesh>;
  87468. private _registeredForLateAnimationBindings;
  87469. /**
  87470. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  87471. */
  87472. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  87473. /**
  87474. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  87475. */
  87476. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  87477. /**
  87478. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  87479. */
  87480. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  87481. private _onPointerMove;
  87482. private _onPointerDown;
  87483. private _onPointerUp;
  87484. /** Callback called when a pointer move is detected */
  87485. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87486. /** Callback called when a pointer down is detected */
  87487. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87488. /** Callback called when a pointer up is detected */
  87489. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  87490. /** Callback called when a pointer pick is detected */
  87491. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  87492. /**
  87493. * 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).
  87494. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  87495. */
  87496. onPrePointerObservable: Observable<PointerInfoPre>;
  87497. /**
  87498. * Observable event triggered each time an input event is received from the rendering canvas
  87499. */
  87500. onPointerObservable: Observable<PointerInfo>;
  87501. /**
  87502. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  87503. */
  87504. readonly unTranslatedPointer: Vector2;
  87505. /** The distance in pixel that you have to move to prevent some events */
  87506. static DragMovementThreshold: number;
  87507. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  87508. static LongPressDelay: number;
  87509. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  87510. static DoubleClickDelay: number;
  87511. /** If you need to check double click without raising a single click at first click, enable this flag */
  87512. static ExclusiveDoubleClickMode: boolean;
  87513. private _initClickEvent;
  87514. private _initActionManager;
  87515. private _delayedSimpleClick;
  87516. private _delayedSimpleClickTimeout;
  87517. private _previousDelayedSimpleClickTimeout;
  87518. private _meshPickProceed;
  87519. private _previousButtonPressed;
  87520. private _currentPickResult;
  87521. private _previousPickResult;
  87522. private _totalPointersPressed;
  87523. private _doubleClickOccured;
  87524. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  87525. cameraToUseForPointers: Nullable<Camera>;
  87526. private _pointerX;
  87527. private _pointerY;
  87528. private _unTranslatedPointerX;
  87529. private _unTranslatedPointerY;
  87530. private _startingPointerPosition;
  87531. private _previousStartingPointerPosition;
  87532. private _startingPointerTime;
  87533. private _previousStartingPointerTime;
  87534. private _pointerCaptures;
  87535. private _timeAccumulator;
  87536. private _currentStepId;
  87537. private _currentInternalStep;
  87538. /** @hidden */
  87539. _mirroredCameraPosition: Nullable<Vector3>;
  87540. /**
  87541. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  87542. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  87543. */
  87544. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  87545. /**
  87546. * Observable event triggered each time an keyboard event is received from the hosting window
  87547. */
  87548. onKeyboardObservable: Observable<KeyboardInfo>;
  87549. private _onKeyDown;
  87550. private _onKeyUp;
  87551. private _onCanvasFocusObserver;
  87552. private _onCanvasBlurObserver;
  87553. private _useRightHandedSystem;
  87554. /**
  87555. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  87556. */
  87557. useRightHandedSystem: boolean;
  87558. /**
  87559. * Sets the step Id used by deterministic lock step
  87560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87561. * @param newStepId defines the step Id
  87562. */
  87563. setStepId(newStepId: number): void;
  87564. /**
  87565. * Gets the step Id used by deterministic lock step
  87566. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87567. * @returns the step Id
  87568. */
  87569. getStepId(): number;
  87570. /**
  87571. * Gets the internal step used by deterministic lock step
  87572. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87573. * @returns the internal step
  87574. */
  87575. getInternalStep(): number;
  87576. private _fogEnabled;
  87577. /**
  87578. * Gets or sets a boolean indicating if fog is enabled on this scene
  87579. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87580. * (Default is true)
  87581. */
  87582. fogEnabled: boolean;
  87583. private _fogMode;
  87584. /**
  87585. * Gets or sets the fog mode to use
  87586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87587. * | mode | value |
  87588. * | --- | --- |
  87589. * | FOGMODE_NONE | 0 |
  87590. * | FOGMODE_EXP | 1 |
  87591. * | FOGMODE_EXP2 | 2 |
  87592. * | FOGMODE_LINEAR | 3 |
  87593. */
  87594. fogMode: number;
  87595. /**
  87596. * Gets or sets the fog color to use
  87597. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87598. * (Default is Color3(0.2, 0.2, 0.3))
  87599. */
  87600. fogColor: Color3;
  87601. /**
  87602. * Gets or sets the fog density to use
  87603. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87604. * (Default is 0.1)
  87605. */
  87606. fogDensity: number;
  87607. /**
  87608. * Gets or sets the fog start distance to use
  87609. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87610. * (Default is 0)
  87611. */
  87612. fogStart: number;
  87613. /**
  87614. * Gets or sets the fog end distance to use
  87615. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87616. * (Default is 1000)
  87617. */
  87618. fogEnd: number;
  87619. private _shadowsEnabled;
  87620. /**
  87621. * Gets or sets a boolean indicating if shadows are enabled on this scene
  87622. */
  87623. shadowsEnabled: boolean;
  87624. private _lightsEnabled;
  87625. /**
  87626. * Gets or sets a boolean indicating if lights are enabled on this scene
  87627. */
  87628. lightsEnabled: boolean;
  87629. /** All of the active cameras added to this scene. */
  87630. activeCameras: Camera[];
  87631. private _activeCamera;
  87632. /** Gets or sets the current active camera */
  87633. activeCamera: Nullable<Camera>;
  87634. private _defaultMaterial;
  87635. /** The default material used on meshes when no material is affected */
  87636. /** The default material used on meshes when no material is affected */
  87637. defaultMaterial: Material;
  87638. private _texturesEnabled;
  87639. /**
  87640. * Gets or sets a boolean indicating if textures are enabled on this scene
  87641. */
  87642. texturesEnabled: boolean;
  87643. /**
  87644. * Gets or sets a boolean indicating if particles are enabled on this scene
  87645. */
  87646. particlesEnabled: boolean;
  87647. /**
  87648. * Gets or sets a boolean indicating if sprites are enabled on this scene
  87649. */
  87650. spritesEnabled: boolean;
  87651. private _skeletonsEnabled;
  87652. /**
  87653. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  87654. */
  87655. skeletonsEnabled: boolean;
  87656. /**
  87657. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  87658. */
  87659. lensFlaresEnabled: boolean;
  87660. /**
  87661. * Gets or sets a boolean indicating if collisions are enabled on this scene
  87662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87663. */
  87664. collisionsEnabled: boolean;
  87665. private _collisionCoordinator;
  87666. /** @hidden */
  87667. readonly collisionCoordinator: ICollisionCoordinator;
  87668. /**
  87669. * Defines the gravity applied to this scene (used only for collisions)
  87670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87671. */
  87672. gravity: Vector3;
  87673. /**
  87674. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  87675. */
  87676. postProcessesEnabled: boolean;
  87677. /**
  87678. * The list of postprocesses added to the scene
  87679. */
  87680. postProcesses: PostProcess[];
  87681. /**
  87682. * Gets the current postprocess manager
  87683. */
  87684. postProcessManager: PostProcessManager;
  87685. /**
  87686. * Gets or sets a boolean indicating if render targets are enabled on this scene
  87687. */
  87688. renderTargetsEnabled: boolean;
  87689. /**
  87690. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  87691. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  87692. */
  87693. dumpNextRenderTargets: boolean;
  87694. /**
  87695. * The list of user defined render targets added to the scene
  87696. */
  87697. customRenderTargets: RenderTargetTexture[];
  87698. /**
  87699. * Defines if texture loading must be delayed
  87700. * If true, textures will only be loaded when they need to be rendered
  87701. */
  87702. useDelayedTextureLoading: boolean;
  87703. /**
  87704. * Gets the list of meshes imported to the scene through SceneLoader
  87705. */
  87706. importedMeshesFiles: String[];
  87707. /**
  87708. * Gets or sets a boolean indicating if probes are enabled on this scene
  87709. */
  87710. probesEnabled: boolean;
  87711. /**
  87712. * Gets or sets the current offline provider to use to store scene data
  87713. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87714. */
  87715. offlineProvider: IOfflineProvider;
  87716. /**
  87717. * Gets or sets the action manager associated with the scene
  87718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87719. */
  87720. actionManager: AbstractActionManager;
  87721. private _meshesForIntersections;
  87722. /**
  87723. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  87724. */
  87725. proceduralTexturesEnabled: boolean;
  87726. private _engine;
  87727. private _totalVertices;
  87728. /** @hidden */
  87729. _activeIndices: PerfCounter;
  87730. /** @hidden */
  87731. _activeParticles: PerfCounter;
  87732. /** @hidden */
  87733. _activeBones: PerfCounter;
  87734. private _animationRatio;
  87735. private _animationTimeLast;
  87736. private _animationTime;
  87737. /**
  87738. * Gets or sets a general scale for animation speed
  87739. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  87740. */
  87741. animationTimeScale: number;
  87742. /** @hidden */
  87743. _cachedMaterial: Nullable<Material>;
  87744. /** @hidden */
  87745. _cachedEffect: Nullable<Effect>;
  87746. /** @hidden */
  87747. _cachedVisibility: Nullable<number>;
  87748. private _renderId;
  87749. private _frameId;
  87750. private _executeWhenReadyTimeoutId;
  87751. private _intermediateRendering;
  87752. private _viewUpdateFlag;
  87753. private _projectionUpdateFlag;
  87754. private _alternateViewUpdateFlag;
  87755. private _alternateProjectionUpdateFlag;
  87756. /** @hidden */
  87757. _toBeDisposed: Nullable<IDisposable>[];
  87758. private _activeRequests;
  87759. private _pendingData;
  87760. private _isDisposed;
  87761. /**
  87762. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  87763. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  87764. */
  87765. dispatchAllSubMeshesOfActiveMeshes: boolean;
  87766. private _activeMeshes;
  87767. private _processedMaterials;
  87768. private _renderTargets;
  87769. /** @hidden */
  87770. _activeParticleSystems: SmartArray<IParticleSystem>;
  87771. private _activeSkeletons;
  87772. private _softwareSkinnedMeshes;
  87773. private _renderingManager;
  87774. /** @hidden */
  87775. _activeAnimatables: Animatable[];
  87776. private _transformMatrix;
  87777. private _sceneUbo;
  87778. private _alternateSceneUbo;
  87779. private _pickWithRayInverseMatrix;
  87780. private _viewMatrix;
  87781. private _projectionMatrix;
  87782. private _alternateViewMatrix;
  87783. private _alternateProjectionMatrix;
  87784. private _alternateTransformMatrix;
  87785. private _useAlternateCameraConfiguration;
  87786. private _alternateRendering;
  87787. private _wheelEventName;
  87788. /** @hidden */
  87789. _forcedViewPosition: Nullable<Vector3>;
  87790. /** @hidden */
  87791. readonly _isAlternateRenderingEnabled: boolean;
  87792. private _frustumPlanes;
  87793. /**
  87794. * Gets the list of frustum planes (built from the active camera)
  87795. */
  87796. readonly frustumPlanes: Plane[];
  87797. /**
  87798. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  87799. * This is useful if there are more lights that the maximum simulteanous authorized
  87800. */
  87801. requireLightSorting: boolean;
  87802. /** @hidden */
  87803. readonly useMaterialMeshMap: boolean;
  87804. /** @hidden */
  87805. readonly useClonedMeshhMap: boolean;
  87806. private _pointerOverMesh;
  87807. private _pickedDownMesh;
  87808. private _pickedUpMesh;
  87809. private _externalData;
  87810. private _uid;
  87811. /**
  87812. * @hidden
  87813. * Backing store of defined scene components.
  87814. */
  87815. _components: ISceneComponent[];
  87816. /**
  87817. * @hidden
  87818. * Backing store of defined scene components.
  87819. */
  87820. _serializableComponents: ISceneSerializableComponent[];
  87821. /**
  87822. * List of components to register on the next registration step.
  87823. */
  87824. private _transientComponents;
  87825. /**
  87826. * Registers the transient components if needed.
  87827. */
  87828. private _registerTransientComponents;
  87829. /**
  87830. * @hidden
  87831. * Add a component to the scene.
  87832. * Note that the ccomponent could be registered on th next frame if this is called after
  87833. * the register component stage.
  87834. * @param component Defines the component to add to the scene
  87835. */
  87836. _addComponent(component: ISceneComponent): void;
  87837. /**
  87838. * @hidden
  87839. * Gets a component from the scene.
  87840. * @param name defines the name of the component to retrieve
  87841. * @returns the component or null if not present
  87842. */
  87843. _getComponent(name: string): Nullable<ISceneComponent>;
  87844. /**
  87845. * @hidden
  87846. * Defines the actions happening before camera updates.
  87847. */
  87848. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  87849. /**
  87850. * @hidden
  87851. * Defines the actions happening before clear the canvas.
  87852. */
  87853. _beforeClearStage: Stage<SimpleStageAction>;
  87854. /**
  87855. * @hidden
  87856. * Defines the actions when collecting render targets for the frame.
  87857. */
  87858. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  87859. /**
  87860. * @hidden
  87861. * Defines the actions happening for one camera in the frame.
  87862. */
  87863. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  87864. /**
  87865. * @hidden
  87866. * Defines the actions happening during the per mesh ready checks.
  87867. */
  87868. _isReadyForMeshStage: Stage<MeshStageAction>;
  87869. /**
  87870. * @hidden
  87871. * Defines the actions happening before evaluate active mesh checks.
  87872. */
  87873. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  87874. /**
  87875. * @hidden
  87876. * Defines the actions happening during the evaluate sub mesh checks.
  87877. */
  87878. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  87879. /**
  87880. * @hidden
  87881. * Defines the actions happening during the active mesh stage.
  87882. */
  87883. _activeMeshStage: Stage<ActiveMeshStageAction>;
  87884. /**
  87885. * @hidden
  87886. * Defines the actions happening during the per camera render target step.
  87887. */
  87888. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  87889. /**
  87890. * @hidden
  87891. * Defines the actions happening just before the active camera is drawing.
  87892. */
  87893. _beforeCameraDrawStage: Stage<CameraStageAction>;
  87894. /**
  87895. * @hidden
  87896. * Defines the actions happening just before a render target is drawing.
  87897. */
  87898. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  87899. /**
  87900. * @hidden
  87901. * Defines the actions happening just before a rendering group is drawing.
  87902. */
  87903. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  87904. /**
  87905. * @hidden
  87906. * Defines the actions happening just before a mesh is drawing.
  87907. */
  87908. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  87909. /**
  87910. * @hidden
  87911. * Defines the actions happening just after a mesh has been drawn.
  87912. */
  87913. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  87914. /**
  87915. * @hidden
  87916. * Defines the actions happening just after a rendering group has been drawn.
  87917. */
  87918. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  87919. /**
  87920. * @hidden
  87921. * Defines the actions happening just after the active camera has been drawn.
  87922. */
  87923. _afterCameraDrawStage: Stage<CameraStageAction>;
  87924. /**
  87925. * @hidden
  87926. * Defines the actions happening just after a render target has been drawn.
  87927. */
  87928. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  87929. /**
  87930. * @hidden
  87931. * Defines the actions happening just after rendering all cameras and computing intersections.
  87932. */
  87933. _afterRenderStage: Stage<SimpleStageAction>;
  87934. /**
  87935. * @hidden
  87936. * Defines the actions happening when a pointer move event happens.
  87937. */
  87938. _pointerMoveStage: Stage<PointerMoveStageAction>;
  87939. /**
  87940. * @hidden
  87941. * Defines the actions happening when a pointer down event happens.
  87942. */
  87943. _pointerDownStage: Stage<PointerUpDownStageAction>;
  87944. /**
  87945. * @hidden
  87946. * Defines the actions happening when a pointer up event happens.
  87947. */
  87948. _pointerUpStage: Stage<PointerUpDownStageAction>;
  87949. /**
  87950. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  87951. */
  87952. private geometriesByUniqueId;
  87953. /**
  87954. * Creates a new Scene
  87955. * @param engine defines the engine to use to render this scene
  87956. * @param options defines the scene options
  87957. */
  87958. constructor(engine: Engine, options?: SceneOptions);
  87959. private _defaultMeshCandidates;
  87960. /**
  87961. * @hidden
  87962. */
  87963. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  87964. private _defaultSubMeshCandidates;
  87965. /**
  87966. * @hidden
  87967. */
  87968. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  87969. /**
  87970. * Sets the default candidate providers for the scene.
  87971. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  87972. * and getCollidingSubMeshCandidates to their default function
  87973. */
  87974. setDefaultCandidateProviders(): void;
  87975. /**
  87976. * Gets the mesh that is currently under the pointer
  87977. */
  87978. readonly meshUnderPointer: Nullable<AbstractMesh>;
  87979. /**
  87980. * Gets or sets the current on-screen X position of the pointer
  87981. */
  87982. pointerX: number;
  87983. /**
  87984. * Gets or sets the current on-screen Y position of the pointer
  87985. */
  87986. pointerY: number;
  87987. /**
  87988. * Gets the cached material (ie. the latest rendered one)
  87989. * @returns the cached material
  87990. */
  87991. getCachedMaterial(): Nullable<Material>;
  87992. /**
  87993. * Gets the cached effect (ie. the latest rendered one)
  87994. * @returns the cached effect
  87995. */
  87996. getCachedEffect(): Nullable<Effect>;
  87997. /**
  87998. * Gets the cached visibility state (ie. the latest rendered one)
  87999. * @returns the cached visibility state
  88000. */
  88001. getCachedVisibility(): Nullable<number>;
  88002. /**
  88003. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88004. * @param material defines the current material
  88005. * @param effect defines the current effect
  88006. * @param visibility defines the current visibility state
  88007. * @returns true if one parameter is not cached
  88008. */
  88009. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88010. /**
  88011. * Gets the engine associated with the scene
  88012. * @returns an Engine
  88013. */
  88014. getEngine(): Engine;
  88015. /**
  88016. * Gets the total number of vertices rendered per frame
  88017. * @returns the total number of vertices rendered per frame
  88018. */
  88019. getTotalVertices(): number;
  88020. /**
  88021. * Gets the performance counter for total vertices
  88022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88023. */
  88024. readonly totalVerticesPerfCounter: PerfCounter;
  88025. /**
  88026. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88027. * @returns the total number of active indices rendered per frame
  88028. */
  88029. getActiveIndices(): number;
  88030. /**
  88031. * Gets the performance counter for active indices
  88032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88033. */
  88034. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88035. /**
  88036. * Gets the total number of active particles rendered per frame
  88037. * @returns the total number of active particles rendered per frame
  88038. */
  88039. getActiveParticles(): number;
  88040. /**
  88041. * Gets the performance counter for active particles
  88042. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88043. */
  88044. readonly activeParticlesPerfCounter: PerfCounter;
  88045. /**
  88046. * Gets the total number of active bones rendered per frame
  88047. * @returns the total number of active bones rendered per frame
  88048. */
  88049. getActiveBones(): number;
  88050. /**
  88051. * Gets the performance counter for active bones
  88052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88053. */
  88054. readonly activeBonesPerfCounter: PerfCounter;
  88055. /**
  88056. * Gets the array of active meshes
  88057. * @returns an array of AbstractMesh
  88058. */
  88059. getActiveMeshes(): SmartArray<AbstractMesh>;
  88060. /**
  88061. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88062. * @returns a number
  88063. */
  88064. getAnimationRatio(): number;
  88065. /**
  88066. * Gets an unique Id for the current render phase
  88067. * @returns a number
  88068. */
  88069. getRenderId(): number;
  88070. /**
  88071. * Gets an unique Id for the current frame
  88072. * @returns a number
  88073. */
  88074. getFrameId(): number;
  88075. /** Call this function if you want to manually increment the render Id*/
  88076. incrementRenderId(): void;
  88077. private _updatePointerPosition;
  88078. private _createUbo;
  88079. private _createAlternateUbo;
  88080. private _setRayOnPointerInfo;
  88081. /**
  88082. * Use this method to simulate a pointer move on a mesh
  88083. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88084. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88085. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88086. * @returns the current scene
  88087. */
  88088. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88089. private _processPointerMove;
  88090. private _checkPrePointerObservable;
  88091. /**
  88092. * Use this method to simulate a pointer down on a mesh
  88093. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88094. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88095. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88096. * @returns the current scene
  88097. */
  88098. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88099. private _processPointerDown;
  88100. /**
  88101. * Use this method to simulate a pointer up on a mesh
  88102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88105. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88106. * @returns the current scene
  88107. */
  88108. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88109. private _processPointerUp;
  88110. /**
  88111. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88112. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88113. * @returns true if the pointer was captured
  88114. */
  88115. isPointerCaptured(pointerId?: number): boolean;
  88116. /** @hidden */
  88117. _isPointerSwiping(): boolean;
  88118. /**
  88119. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88120. * @param attachUp defines if you want to attach events to pointerup
  88121. * @param attachDown defines if you want to attach events to pointerdown
  88122. * @param attachMove defines if you want to attach events to pointermove
  88123. */
  88124. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88125. /** Detaches all event handlers*/
  88126. detachControl(): void;
  88127. /**
  88128. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88129. * Delay loaded resources are not taking in account
  88130. * @return true if all required resources are ready
  88131. */
  88132. isReady(): boolean;
  88133. /** Resets all cached information relative to material (including effect and visibility) */
  88134. resetCachedMaterial(): void;
  88135. /**
  88136. * Registers a function to be called before every frame render
  88137. * @param func defines the function to register
  88138. */
  88139. registerBeforeRender(func: () => void): void;
  88140. /**
  88141. * Unregisters a function called before every frame render
  88142. * @param func defines the function to unregister
  88143. */
  88144. unregisterBeforeRender(func: () => void): void;
  88145. /**
  88146. * Registers a function to be called after every frame render
  88147. * @param func defines the function to register
  88148. */
  88149. registerAfterRender(func: () => void): void;
  88150. /**
  88151. * Unregisters a function called after every frame render
  88152. * @param func defines the function to unregister
  88153. */
  88154. unregisterAfterRender(func: () => void): void;
  88155. private _executeOnceBeforeRender;
  88156. /**
  88157. * The provided function will run before render once and will be disposed afterwards.
  88158. * A timeout delay can be provided so that the function will be executed in N ms.
  88159. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88160. * @param func The function to be executed.
  88161. * @param timeout optional delay in ms
  88162. */
  88163. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88164. /** @hidden */
  88165. _addPendingData(data: any): void;
  88166. /** @hidden */
  88167. _removePendingData(data: any): void;
  88168. /**
  88169. * Returns the number of items waiting to be loaded
  88170. * @returns the number of items waiting to be loaded
  88171. */
  88172. getWaitingItemsCount(): number;
  88173. /**
  88174. * Returns a boolean indicating if the scene is still loading data
  88175. */
  88176. readonly isLoading: boolean;
  88177. /**
  88178. * Registers a function to be executed when the scene is ready
  88179. * @param {Function} func - the function to be executed
  88180. */
  88181. executeWhenReady(func: () => void): void;
  88182. /**
  88183. * Returns a promise that resolves when the scene is ready
  88184. * @returns A promise that resolves when the scene is ready
  88185. */
  88186. whenReadyAsync(): Promise<void>;
  88187. /** @hidden */
  88188. _checkIsReady(): void;
  88189. /**
  88190. * Will start the animation sequence of a given target
  88191. * @param target defines the target
  88192. * @param from defines from which frame should animation start
  88193. * @param to defines until which frame should animation run.
  88194. * @param weight defines the weight to apply to the animation (1.0 by default)
  88195. * @param loop defines if the animation loops
  88196. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88197. * @param onAnimationEnd defines the function to be executed when the animation ends
  88198. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88199. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88200. * @param onAnimationLoop defines the callback to call when an animation loops
  88201. * @returns the animatable object created for this animation
  88202. */
  88203. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88204. /**
  88205. * Will start the animation sequence of a given target
  88206. * @param target defines the target
  88207. * @param from defines from which frame should animation start
  88208. * @param to defines until which frame should animation run.
  88209. * @param loop defines if the animation loops
  88210. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88211. * @param onAnimationEnd defines the function to be executed when the animation ends
  88212. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88213. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88214. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88215. * @param onAnimationLoop defines the callback to call when an animation loops
  88216. * @returns the animatable object created for this animation
  88217. */
  88218. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88219. /**
  88220. * Will start the animation sequence of a given target and its hierarchy
  88221. * @param target defines the target
  88222. * @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.
  88223. * @param from defines from which frame should animation start
  88224. * @param to defines until which frame should animation run.
  88225. * @param loop defines if the animation loops
  88226. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88227. * @param onAnimationEnd defines the function to be executed when the animation ends
  88228. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88229. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88230. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88231. * @param onAnimationLoop defines the callback to call when an animation loops
  88232. * @returns the list of created animatables
  88233. */
  88234. 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[];
  88235. /**
  88236. * Begin a new animation on a given node
  88237. * @param target defines the target where the animation will take place
  88238. * @param animations defines the list of animations to start
  88239. * @param from defines the initial value
  88240. * @param to defines the final value
  88241. * @param loop defines if you want animation to loop (off by default)
  88242. * @param speedRatio defines the speed ratio to apply to all animations
  88243. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88244. * @param onAnimationLoop defines the callback to call when an animation loops
  88245. * @returns the list of created animatables
  88246. */
  88247. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88248. /**
  88249. * Begin a new animation on a given node and its hierarchy
  88250. * @param target defines the root node where the animation will take place
  88251. * @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.
  88252. * @param animations defines the list of animations to start
  88253. * @param from defines the initial value
  88254. * @param to defines the final value
  88255. * @param loop defines if you want animation to loop (off by default)
  88256. * @param speedRatio defines the speed ratio to apply to all animations
  88257. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88258. * @param onAnimationLoop defines the callback to call when an animation loops
  88259. * @returns the list of animatables created for all nodes
  88260. */
  88261. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88262. /**
  88263. * Gets the animatable associated with a specific target
  88264. * @param target defines the target of the animatable
  88265. * @returns the required animatable if found
  88266. */
  88267. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88268. /**
  88269. * Gets all animatables associated with a given target
  88270. * @param target defines the target to look animatables for
  88271. * @returns an array of Animatables
  88272. */
  88273. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88274. /**
  88275. * Gets all animatable attached to the scene
  88276. */
  88277. readonly animatables: Animatable[];
  88278. /**
  88279. * Will stop the animation of the given target
  88280. * @param target - the target
  88281. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  88282. * @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)
  88283. */
  88284. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  88285. /**
  88286. * Stops and removes all animations that have been applied to the scene
  88287. */
  88288. stopAllAnimations(): void;
  88289. /**
  88290. * Resets the last animation time frame.
  88291. * Useful to override when animations start running when loading a scene for the first time.
  88292. */
  88293. resetLastAnimationTimeFrame(): void;
  88294. private _animate;
  88295. /** @hidden */
  88296. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88297. private _processLateAnimationBindingsForMatrices;
  88298. private _processLateAnimationBindingsForQuaternions;
  88299. private _processLateAnimationBindings;
  88300. /** @hidden */
  88301. _switchToAlternateCameraConfiguration(active: boolean): void;
  88302. /**
  88303. * Gets the current view matrix
  88304. * @returns a Matrix
  88305. */
  88306. getViewMatrix(): Matrix;
  88307. /**
  88308. * Gets the current projection matrix
  88309. * @returns a Matrix
  88310. */
  88311. getProjectionMatrix(): Matrix;
  88312. /**
  88313. * Gets the current transform matrix
  88314. * @returns a Matrix made of View * Projection
  88315. */
  88316. getTransformMatrix(): Matrix;
  88317. /**
  88318. * Sets the current transform matrix
  88319. * @param view defines the View matrix to use
  88320. * @param projection defines the Projection matrix to use
  88321. */
  88322. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88323. /** @hidden */
  88324. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88325. /**
  88326. * Gets the uniform buffer used to store scene data
  88327. * @returns a UniformBuffer
  88328. */
  88329. getSceneUniformBuffer(): UniformBuffer;
  88330. /**
  88331. * Gets an unique (relatively to the current scene) Id
  88332. * @returns an unique number for the scene
  88333. */
  88334. getUniqueId(): number;
  88335. /**
  88336. * Add a mesh to the list of scene's meshes
  88337. * @param newMesh defines the mesh to add
  88338. * @param recursive if all child meshes should also be added to the scene
  88339. */
  88340. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88341. /**
  88342. * Remove a mesh for the list of scene's meshes
  88343. * @param toRemove defines the mesh to remove
  88344. * @param recursive if all child meshes should also be removed from the scene
  88345. * @returns the index where the mesh was in the mesh list
  88346. */
  88347. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88348. /**
  88349. * Add a transform node to the list of scene's transform nodes
  88350. * @param newTransformNode defines the transform node to add
  88351. */
  88352. addTransformNode(newTransformNode: TransformNode): void;
  88353. /**
  88354. * Remove a transform node for the list of scene's transform nodes
  88355. * @param toRemove defines the transform node to remove
  88356. * @returns the index where the transform node was in the transform node list
  88357. */
  88358. removeTransformNode(toRemove: TransformNode): number;
  88359. /**
  88360. * Remove a skeleton for the list of scene's skeletons
  88361. * @param toRemove defines the skeleton to remove
  88362. * @returns the index where the skeleton was in the skeleton list
  88363. */
  88364. removeSkeleton(toRemove: Skeleton): number;
  88365. /**
  88366. * Remove a morph target for the list of scene's morph targets
  88367. * @param toRemove defines the morph target to remove
  88368. * @returns the index where the morph target was in the morph target list
  88369. */
  88370. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88371. /**
  88372. * Remove a light for the list of scene's lights
  88373. * @param toRemove defines the light to remove
  88374. * @returns the index where the light was in the light list
  88375. */
  88376. removeLight(toRemove: Light): number;
  88377. /**
  88378. * Remove a camera for the list of scene's cameras
  88379. * @param toRemove defines the camera to remove
  88380. * @returns the index where the camera was in the camera list
  88381. */
  88382. removeCamera(toRemove: Camera): number;
  88383. /**
  88384. * Remove a particle system for the list of scene's particle systems
  88385. * @param toRemove defines the particle system to remove
  88386. * @returns the index where the particle system was in the particle system list
  88387. */
  88388. removeParticleSystem(toRemove: IParticleSystem): number;
  88389. /**
  88390. * Remove a animation for the list of scene's animations
  88391. * @param toRemove defines the animation to remove
  88392. * @returns the index where the animation was in the animation list
  88393. */
  88394. removeAnimation(toRemove: Animation): number;
  88395. /**
  88396. * Removes the given animation group from this scene.
  88397. * @param toRemove The animation group to remove
  88398. * @returns The index of the removed animation group
  88399. */
  88400. removeAnimationGroup(toRemove: AnimationGroup): number;
  88401. /**
  88402. * Removes the given multi-material from this scene.
  88403. * @param toRemove The multi-material to remove
  88404. * @returns The index of the removed multi-material
  88405. */
  88406. removeMultiMaterial(toRemove: MultiMaterial): number;
  88407. /**
  88408. * Removes the given material from this scene.
  88409. * @param toRemove The material to remove
  88410. * @returns The index of the removed material
  88411. */
  88412. removeMaterial(toRemove: Material): number;
  88413. /**
  88414. * Removes the given action manager from this scene.
  88415. * @param toRemove The action manager to remove
  88416. * @returns The index of the removed action manager
  88417. */
  88418. removeActionManager(toRemove: AbstractActionManager): number;
  88419. /**
  88420. * Removes the given texture from this scene.
  88421. * @param toRemove The texture to remove
  88422. * @returns The index of the removed texture
  88423. */
  88424. removeTexture(toRemove: BaseTexture): number;
  88425. /**
  88426. * Adds the given light to this scene
  88427. * @param newLight The light to add
  88428. */
  88429. addLight(newLight: Light): void;
  88430. /**
  88431. * Sorts the list list based on light priorities
  88432. */
  88433. sortLightsByPriority(): void;
  88434. /**
  88435. * Adds the given camera to this scene
  88436. * @param newCamera The camera to add
  88437. */
  88438. addCamera(newCamera: Camera): void;
  88439. /**
  88440. * Adds the given skeleton to this scene
  88441. * @param newSkeleton The skeleton to add
  88442. */
  88443. addSkeleton(newSkeleton: Skeleton): void;
  88444. /**
  88445. * Adds the given particle system to this scene
  88446. * @param newParticleSystem The particle system to add
  88447. */
  88448. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88449. /**
  88450. * Adds the given animation to this scene
  88451. * @param newAnimation The animation to add
  88452. */
  88453. addAnimation(newAnimation: Animation): void;
  88454. /**
  88455. * Adds the given animation group to this scene.
  88456. * @param newAnimationGroup The animation group to add
  88457. */
  88458. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88459. /**
  88460. * Adds the given multi-material to this scene
  88461. * @param newMultiMaterial The multi-material to add
  88462. */
  88463. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88464. /**
  88465. * Adds the given material to this scene
  88466. * @param newMaterial The material to add
  88467. */
  88468. addMaterial(newMaterial: Material): void;
  88469. /**
  88470. * Adds the given morph target to this scene
  88471. * @param newMorphTargetManager The morph target to add
  88472. */
  88473. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88474. /**
  88475. * Adds the given geometry to this scene
  88476. * @param newGeometry The geometry to add
  88477. */
  88478. addGeometry(newGeometry: Geometry): void;
  88479. /**
  88480. * Adds the given action manager to this scene
  88481. * @param newActionManager The action manager to add
  88482. */
  88483. addActionManager(newActionManager: AbstractActionManager): void;
  88484. /**
  88485. * Adds the given texture to this scene.
  88486. * @param newTexture The texture to add
  88487. */
  88488. addTexture(newTexture: BaseTexture): void;
  88489. /**
  88490. * Switch active camera
  88491. * @param newCamera defines the new active camera
  88492. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88493. */
  88494. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88495. /**
  88496. * sets the active camera of the scene using its ID
  88497. * @param id defines the camera's ID
  88498. * @return the new active camera or null if none found.
  88499. */
  88500. setActiveCameraByID(id: string): Nullable<Camera>;
  88501. /**
  88502. * sets the active camera of the scene using its name
  88503. * @param name defines the camera's name
  88504. * @returns the new active camera or null if none found.
  88505. */
  88506. setActiveCameraByName(name: string): Nullable<Camera>;
  88507. /**
  88508. * get an animation group using its name
  88509. * @param name defines the material's name
  88510. * @return the animation group or null if none found.
  88511. */
  88512. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88513. /**
  88514. * get a material using its id
  88515. * @param id defines the material's ID
  88516. * @return the material or null if none found.
  88517. */
  88518. getMaterialByID(id: string): Nullable<Material>;
  88519. /**
  88520. * Gets a material using its name
  88521. * @param name defines the material's name
  88522. * @return the material or null if none found.
  88523. */
  88524. getMaterialByName(name: string): Nullable<Material>;
  88525. /**
  88526. * Gets a camera using its id
  88527. * @param id defines the id to look for
  88528. * @returns the camera or null if not found
  88529. */
  88530. getCameraByID(id: string): Nullable<Camera>;
  88531. /**
  88532. * Gets a camera using its unique id
  88533. * @param uniqueId defines the unique id to look for
  88534. * @returns the camera or null if not found
  88535. */
  88536. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88537. /**
  88538. * Gets a camera using its name
  88539. * @param name defines the camera's name
  88540. * @return the camera or null if none found.
  88541. */
  88542. getCameraByName(name: string): Nullable<Camera>;
  88543. /**
  88544. * Gets a bone using its id
  88545. * @param id defines the bone's id
  88546. * @return the bone or null if not found
  88547. */
  88548. getBoneByID(id: string): Nullable<Bone>;
  88549. /**
  88550. * Gets a bone using its id
  88551. * @param name defines the bone's name
  88552. * @return the bone or null if not found
  88553. */
  88554. getBoneByName(name: string): Nullable<Bone>;
  88555. /**
  88556. * Gets a light node using its name
  88557. * @param name defines the the light's name
  88558. * @return the light or null if none found.
  88559. */
  88560. getLightByName(name: string): Nullable<Light>;
  88561. /**
  88562. * Gets a light node using its id
  88563. * @param id defines the light's id
  88564. * @return the light or null if none found.
  88565. */
  88566. getLightByID(id: string): Nullable<Light>;
  88567. /**
  88568. * Gets a light node using its scene-generated unique ID
  88569. * @param uniqueId defines the light's unique id
  88570. * @return the light or null if none found.
  88571. */
  88572. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  88573. /**
  88574. * Gets a particle system by id
  88575. * @param id defines the particle system id
  88576. * @return the corresponding system or null if none found
  88577. */
  88578. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  88579. /**
  88580. * Gets a geometry using its ID
  88581. * @param id defines the geometry's id
  88582. * @return the geometry or null if none found.
  88583. */
  88584. getGeometryByID(id: string): Nullable<Geometry>;
  88585. private _getGeometryByUniqueID;
  88586. /**
  88587. * Add a new geometry to this scene
  88588. * @param geometry defines the geometry to be added to the scene.
  88589. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  88590. * @return a boolean defining if the geometry was added or not
  88591. */
  88592. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  88593. /**
  88594. * Removes an existing geometry
  88595. * @param geometry defines the geometry to be removed from the scene
  88596. * @return a boolean defining if the geometry was removed or not
  88597. */
  88598. removeGeometry(geometry: Geometry): boolean;
  88599. /**
  88600. * Gets the list of geometries attached to the scene
  88601. * @returns an array of Geometry
  88602. */
  88603. getGeometries(): Geometry[];
  88604. /**
  88605. * Gets the first added mesh found of a given ID
  88606. * @param id defines the id to search for
  88607. * @return the mesh found or null if not found at all
  88608. */
  88609. getMeshByID(id: string): Nullable<AbstractMesh>;
  88610. /**
  88611. * Gets a list of meshes using their id
  88612. * @param id defines the id to search for
  88613. * @returns a list of meshes
  88614. */
  88615. getMeshesByID(id: string): Array<AbstractMesh>;
  88616. /**
  88617. * Gets the first added transform node found of a given ID
  88618. * @param id defines the id to search for
  88619. * @return the found transform node or null if not found at all.
  88620. */
  88621. getTransformNodeByID(id: string): Nullable<TransformNode>;
  88622. /**
  88623. * Gets a list of transform nodes using their id
  88624. * @param id defines the id to search for
  88625. * @returns a list of transform nodes
  88626. */
  88627. getTransformNodesByID(id: string): Array<TransformNode>;
  88628. /**
  88629. * Gets a mesh with its auto-generated unique id
  88630. * @param uniqueId defines the unique id to search for
  88631. * @return the found mesh or null if not found at all.
  88632. */
  88633. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  88634. /**
  88635. * Gets a the last added mesh using a given id
  88636. * @param id defines the id to search for
  88637. * @return the found mesh or null if not found at all.
  88638. */
  88639. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  88640. /**
  88641. * Gets a the last added node (Mesh, Camera, Light) using a given id
  88642. * @param id defines the id to search for
  88643. * @return the found node or null if not found at all
  88644. */
  88645. getLastEntryByID(id: string): Nullable<Node>;
  88646. /**
  88647. * Gets a node (Mesh, Camera, Light) using a given id
  88648. * @param id defines the id to search for
  88649. * @return the found node or null if not found at all
  88650. */
  88651. getNodeByID(id: string): Nullable<Node>;
  88652. /**
  88653. * Gets a node (Mesh, Camera, Light) using a given name
  88654. * @param name defines the name to search for
  88655. * @return the found node or null if not found at all.
  88656. */
  88657. getNodeByName(name: string): Nullable<Node>;
  88658. /**
  88659. * Gets a mesh using a given name
  88660. * @param name defines the name to search for
  88661. * @return the found mesh or null if not found at all.
  88662. */
  88663. getMeshByName(name: string): Nullable<AbstractMesh>;
  88664. /**
  88665. * Gets a transform node using a given name
  88666. * @param name defines the name to search for
  88667. * @return the found transform node or null if not found at all.
  88668. */
  88669. getTransformNodeByName(name: string): Nullable<TransformNode>;
  88670. /**
  88671. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  88672. * @param id defines the id to search for
  88673. * @return the found skeleton or null if not found at all.
  88674. */
  88675. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  88676. /**
  88677. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  88678. * @param id defines the id to search for
  88679. * @return the found skeleton or null if not found at all.
  88680. */
  88681. getSkeletonById(id: string): Nullable<Skeleton>;
  88682. /**
  88683. * Gets a skeleton using a given name
  88684. * @param name defines the name to search for
  88685. * @return the found skeleton or null if not found at all.
  88686. */
  88687. getSkeletonByName(name: string): Nullable<Skeleton>;
  88688. /**
  88689. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  88690. * @param id defines the id to search for
  88691. * @return the found morph target manager or null if not found at all.
  88692. */
  88693. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  88694. /**
  88695. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  88696. * @param id defines the id to search for
  88697. * @return the found morph target or null if not found at all.
  88698. */
  88699. getMorphTargetById(id: string): Nullable<MorphTarget>;
  88700. /**
  88701. * Gets a boolean indicating if the given mesh is active
  88702. * @param mesh defines the mesh to look for
  88703. * @returns true if the mesh is in the active list
  88704. */
  88705. isActiveMesh(mesh: AbstractMesh): boolean;
  88706. /**
  88707. * Return a unique id as a string which can serve as an identifier for the scene
  88708. */
  88709. readonly uid: string;
  88710. /**
  88711. * Add an externaly attached data from its key.
  88712. * This method call will fail and return false, if such key already exists.
  88713. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88714. * @param key the unique key that identifies the data
  88715. * @param data the data object to associate to the key for this Engine instance
  88716. * @return true if no such key were already present and the data was added successfully, false otherwise
  88717. */
  88718. addExternalData<T>(key: string, data: T): boolean;
  88719. /**
  88720. * Get an externaly attached data from its key
  88721. * @param key the unique key that identifies the data
  88722. * @return the associated data, if present (can be null), or undefined if not present
  88723. */
  88724. getExternalData<T>(key: string): Nullable<T>;
  88725. /**
  88726. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88727. * @param key the unique key that identifies the data
  88728. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88729. * @return the associated data, can be null if the factory returned null.
  88730. */
  88731. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88732. /**
  88733. * Remove an externaly attached data from the Engine instance
  88734. * @param key the unique key that identifies the data
  88735. * @return true if the data was successfully removed, false if it doesn't exist
  88736. */
  88737. removeExternalData(key: string): boolean;
  88738. private _evaluateSubMesh;
  88739. /**
  88740. * Clear the processed materials smart array preventing retention point in material dispose.
  88741. */
  88742. freeProcessedMaterials(): void;
  88743. private _preventFreeActiveMeshesAndRenderingGroups;
  88744. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  88745. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  88746. * when disposing several meshes in a row or a hierarchy of meshes.
  88747. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  88748. */
  88749. blockfreeActiveMeshesAndRenderingGroups: boolean;
  88750. /**
  88751. * Clear the active meshes smart array preventing retention point in mesh dispose.
  88752. */
  88753. freeActiveMeshes(): void;
  88754. /**
  88755. * Clear the info related to rendering groups preventing retention points during dispose.
  88756. */
  88757. freeRenderingGroups(): void;
  88758. /** @hidden */
  88759. _isInIntermediateRendering(): boolean;
  88760. /**
  88761. * Lambda returning the list of potentially active meshes.
  88762. */
  88763. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  88764. /**
  88765. * Lambda returning the list of potentially active sub meshes.
  88766. */
  88767. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  88768. /**
  88769. * Lambda returning the list of potentially intersecting sub meshes.
  88770. */
  88771. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  88772. /**
  88773. * Lambda returning the list of potentially colliding sub meshes.
  88774. */
  88775. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  88776. private _activeMeshesFrozen;
  88777. /**
  88778. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  88779. * @returns the current scene
  88780. */
  88781. freezeActiveMeshes(): Scene;
  88782. /**
  88783. * Use this function to restart evaluating active meshes on every frame
  88784. * @returns the current scene
  88785. */
  88786. unfreezeActiveMeshes(): Scene;
  88787. private _evaluateActiveMeshes;
  88788. private _activeMesh;
  88789. /**
  88790. * Update the transform matrix to update from the current active camera
  88791. * @param force defines a boolean used to force the update even if cache is up to date
  88792. */
  88793. updateTransformMatrix(force?: boolean): void;
  88794. /**
  88795. * 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)
  88796. * @param alternateCamera defines the camera to use
  88797. */
  88798. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  88799. /** @hidden */
  88800. _allowPostProcessClearColor: boolean;
  88801. private _renderForCamera;
  88802. private _processSubCameras;
  88803. private _checkIntersections;
  88804. /** @hidden */
  88805. _advancePhysicsEngineStep(step: number): void;
  88806. /**
  88807. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  88808. */
  88809. getDeterministicFrameTime: () => number;
  88810. /**
  88811. * Render the scene
  88812. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  88813. */
  88814. render(updateCameras?: boolean): void;
  88815. /**
  88816. * Freeze all materials
  88817. * A frozen material will not be updatable but should be faster to render
  88818. */
  88819. freezeMaterials(): void;
  88820. /**
  88821. * Unfreeze all materials
  88822. * A frozen material will not be updatable but should be faster to render
  88823. */
  88824. unfreezeMaterials(): void;
  88825. /**
  88826. * Releases all held ressources
  88827. */
  88828. dispose(): void;
  88829. /**
  88830. * Gets if the scene is already disposed
  88831. */
  88832. readonly isDisposed: boolean;
  88833. /**
  88834. * Call this function to reduce memory footprint of the scene.
  88835. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  88836. */
  88837. clearCachedVertexData(): void;
  88838. /**
  88839. * This function will remove the local cached buffer data from texture.
  88840. * It will save memory but will prevent the texture from being rebuilt
  88841. */
  88842. cleanCachedTextureBuffer(): void;
  88843. /**
  88844. * Get the world extend vectors with an optional filter
  88845. *
  88846. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  88847. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  88848. */
  88849. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  88850. min: Vector3;
  88851. max: Vector3;
  88852. };
  88853. /**
  88854. * Creates a ray that can be used to pick in the scene
  88855. * @param x defines the x coordinate of the origin (on-screen)
  88856. * @param y defines the y coordinate of the origin (on-screen)
  88857. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88858. * @param camera defines the camera to use for the picking
  88859. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88860. * @returns a Ray
  88861. */
  88862. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  88863. /**
  88864. * Creates a ray that can be used to pick in the scene
  88865. * @param x defines the x coordinate of the origin (on-screen)
  88866. * @param y defines the y coordinate of the origin (on-screen)
  88867. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88868. * @param result defines the ray where to store the picking ray
  88869. * @param camera defines the camera to use for the picking
  88870. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88871. * @returns the current scene
  88872. */
  88873. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  88874. /**
  88875. * Creates a ray that can be used to pick in the scene
  88876. * @param x defines the x coordinate of the origin (on-screen)
  88877. * @param y defines the y coordinate of the origin (on-screen)
  88878. * @param camera defines the camera to use for the picking
  88879. * @returns a Ray
  88880. */
  88881. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  88882. /**
  88883. * Creates a ray that can be used to pick in the scene
  88884. * @param x defines the x coordinate of the origin (on-screen)
  88885. * @param y defines the y coordinate of the origin (on-screen)
  88886. * @param result defines the ray where to store the picking ray
  88887. * @param camera defines the camera to use for the picking
  88888. * @returns the current scene
  88889. */
  88890. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  88891. private _internalPick;
  88892. private _internalMultiPick;
  88893. private _tempPickingRay;
  88894. /** Launch a ray to try to pick a mesh in the scene
  88895. * @param x position on screen
  88896. * @param y position on screen
  88897. * @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
  88898. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  88899. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88900. * @returns a PickingInfo
  88901. */
  88902. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  88903. private _cachedRayForTransform;
  88904. /** Use the given ray to pick a mesh in the scene
  88905. * @param ray The ray to use to pick meshes
  88906. * @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
  88907. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  88908. * @returns a PickingInfo
  88909. */
  88910. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88911. /**
  88912. * Launch a ray to try to pick a mesh in the scene
  88913. * @param x X position on screen
  88914. * @param y Y position on screen
  88915. * @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
  88916. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88917. * @returns an array of PickingInfo
  88918. */
  88919. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88920. /**
  88921. * Launch a ray to try to pick a mesh in the scene
  88922. * @param ray Ray to use
  88923. * @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
  88924. * @returns an array of PickingInfo
  88925. */
  88926. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  88927. /**
  88928. * Force the value of meshUnderPointer
  88929. * @param mesh defines the mesh to use
  88930. */
  88931. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  88932. /**
  88933. * Gets the mesh under the pointer
  88934. * @returns a Mesh or null if no mesh is under the pointer
  88935. */
  88936. getPointerOverMesh(): Nullable<AbstractMesh>;
  88937. /** @hidden */
  88938. _rebuildGeometries(): void;
  88939. /** @hidden */
  88940. _rebuildTextures(): void;
  88941. private _getByTags;
  88942. /**
  88943. * Get a list of meshes by tags
  88944. * @param tagsQuery defines the tags query to use
  88945. * @param forEach defines a predicate used to filter results
  88946. * @returns an array of Mesh
  88947. */
  88948. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  88949. /**
  88950. * Get a list of cameras by tags
  88951. * @param tagsQuery defines the tags query to use
  88952. * @param forEach defines a predicate used to filter results
  88953. * @returns an array of Camera
  88954. */
  88955. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  88956. /**
  88957. * Get a list of lights by tags
  88958. * @param tagsQuery defines the tags query to use
  88959. * @param forEach defines a predicate used to filter results
  88960. * @returns an array of Light
  88961. */
  88962. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  88963. /**
  88964. * Get a list of materials by tags
  88965. * @param tagsQuery defines the tags query to use
  88966. * @param forEach defines a predicate used to filter results
  88967. * @returns an array of Material
  88968. */
  88969. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  88970. /**
  88971. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88972. * This allowed control for front to back rendering or reversly depending of the special needs.
  88973. *
  88974. * @param renderingGroupId The rendering group id corresponding to its index
  88975. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88976. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88977. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88978. */
  88979. 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;
  88980. /**
  88981. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88982. *
  88983. * @param renderingGroupId The rendering group id corresponding to its index
  88984. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88985. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88986. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88987. */
  88988. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88989. /**
  88990. * Gets the current auto clear configuration for one rendering group of the rendering
  88991. * manager.
  88992. * @param index the rendering group index to get the information for
  88993. * @returns The auto clear setup for the requested rendering group
  88994. */
  88995. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88996. private _blockMaterialDirtyMechanism;
  88997. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  88998. blockMaterialDirtyMechanism: boolean;
  88999. /**
  89000. * Will flag all materials as dirty to trigger new shader compilation
  89001. * @param flag defines the flag used to specify which material part must be marked as dirty
  89002. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89003. */
  89004. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89005. /** @hidden */
  89006. _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;
  89007. /** @hidden */
  89008. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89009. }
  89010. }
  89011. declare module BABYLON {
  89012. /**
  89013. * Set of assets to keep when moving a scene into an asset container.
  89014. */
  89015. export class KeepAssets extends AbstractScene {
  89016. }
  89017. /**
  89018. * Container with a set of assets that can be added or removed from a scene.
  89019. */
  89020. export class AssetContainer extends AbstractScene {
  89021. /**
  89022. * The scene the AssetContainer belongs to.
  89023. */
  89024. scene: Scene;
  89025. /**
  89026. * Instantiates an AssetContainer.
  89027. * @param scene The scene the AssetContainer belongs to.
  89028. */
  89029. constructor(scene: Scene);
  89030. /**
  89031. * Adds all the assets from the container to the scene.
  89032. */
  89033. addAllToScene(): void;
  89034. /**
  89035. * Removes all the assets in the container from the scene
  89036. */
  89037. removeAllFromScene(): void;
  89038. /**
  89039. * Disposes all the assets in the container
  89040. */
  89041. dispose(): void;
  89042. private _moveAssets;
  89043. /**
  89044. * Removes all the assets contained in the scene and adds them to the container.
  89045. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89046. */
  89047. moveAllFromScene(keepAssets?: KeepAssets): void;
  89048. /**
  89049. * 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.
  89050. * @returns the root mesh
  89051. */
  89052. createRootMesh(): Mesh;
  89053. }
  89054. }
  89055. declare module BABYLON {
  89056. /**
  89057. * Defines how the parser contract is defined.
  89058. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89059. */
  89060. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89061. /**
  89062. * Defines how the individual parser contract is defined.
  89063. * These parser can parse an individual asset
  89064. */
  89065. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89066. /**
  89067. * Base class of the scene acting as a container for the different elements composing a scene.
  89068. * This class is dynamically extended by the different components of the scene increasing
  89069. * flexibility and reducing coupling
  89070. */
  89071. export abstract class AbstractScene {
  89072. /**
  89073. * Stores the list of available parsers in the application.
  89074. */
  89075. private static _BabylonFileParsers;
  89076. /**
  89077. * Stores the list of available individual parsers in the application.
  89078. */
  89079. private static _IndividualBabylonFileParsers;
  89080. /**
  89081. * Adds a parser in the list of available ones
  89082. * @param name Defines the name of the parser
  89083. * @param parser Defines the parser to add
  89084. */
  89085. static AddParser(name: string, parser: BabylonFileParser): void;
  89086. /**
  89087. * Gets a general parser from the list of avaialble ones
  89088. * @param name Defines the name of the parser
  89089. * @returns the requested parser or null
  89090. */
  89091. static GetParser(name: string): Nullable<BabylonFileParser>;
  89092. /**
  89093. * Adds n individual parser in the list of available ones
  89094. * @param name Defines the name of the parser
  89095. * @param parser Defines the parser to add
  89096. */
  89097. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89098. /**
  89099. * Gets an individual parser from the list of avaialble ones
  89100. * @param name Defines the name of the parser
  89101. * @returns the requested parser or null
  89102. */
  89103. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89104. /**
  89105. * Parser json data and populate both a scene and its associated container object
  89106. * @param jsonData Defines the data to parse
  89107. * @param scene Defines the scene to parse the data for
  89108. * @param container Defines the container attached to the parsing sequence
  89109. * @param rootUrl Defines the root url of the data
  89110. */
  89111. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89112. /**
  89113. * Gets the list of root nodes (ie. nodes with no parent)
  89114. */
  89115. rootNodes: Node[];
  89116. /** All of the cameras added to this scene
  89117. * @see http://doc.babylonjs.com/babylon101/cameras
  89118. */
  89119. cameras: Camera[];
  89120. /**
  89121. * All of the lights added to this scene
  89122. * @see http://doc.babylonjs.com/babylon101/lights
  89123. */
  89124. lights: Light[];
  89125. /**
  89126. * All of the (abstract) meshes added to this scene
  89127. */
  89128. meshes: AbstractMesh[];
  89129. /**
  89130. * The list of skeletons added to the scene
  89131. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89132. */
  89133. skeletons: Skeleton[];
  89134. /**
  89135. * All of the particle systems added to this scene
  89136. * @see http://doc.babylonjs.com/babylon101/particles
  89137. */
  89138. particleSystems: IParticleSystem[];
  89139. /**
  89140. * Gets a list of Animations associated with the scene
  89141. */
  89142. animations: Animation[];
  89143. /**
  89144. * All of the animation groups added to this scene
  89145. * @see http://doc.babylonjs.com/how_to/group
  89146. */
  89147. animationGroups: AnimationGroup[];
  89148. /**
  89149. * All of the multi-materials added to this scene
  89150. * @see http://doc.babylonjs.com/how_to/multi_materials
  89151. */
  89152. multiMaterials: MultiMaterial[];
  89153. /**
  89154. * All of the materials added to this scene
  89155. * In the context of a Scene, it is not supposed to be modified manually.
  89156. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89157. * Note also that the order of the Material wihin the array is not significant and might change.
  89158. * @see http://doc.babylonjs.com/babylon101/materials
  89159. */
  89160. materials: Material[];
  89161. /**
  89162. * The list of morph target managers added to the scene
  89163. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89164. */
  89165. morphTargetManagers: MorphTargetManager[];
  89166. /**
  89167. * The list of geometries used in the scene.
  89168. */
  89169. geometries: Geometry[];
  89170. /**
  89171. * All of the tranform nodes added to this scene
  89172. * In the context of a Scene, it is not supposed to be modified manually.
  89173. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89174. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89175. * @see http://doc.babylonjs.com/how_to/transformnode
  89176. */
  89177. transformNodes: TransformNode[];
  89178. /**
  89179. * ActionManagers available on the scene.
  89180. */
  89181. actionManagers: AbstractActionManager[];
  89182. /**
  89183. * Textures to keep.
  89184. */
  89185. textures: BaseTexture[];
  89186. }
  89187. }
  89188. declare module BABYLON {
  89189. /**
  89190. * Defines a sound that can be played in the application.
  89191. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89193. */
  89194. export class Sound {
  89195. /**
  89196. * The name of the sound in the scene.
  89197. */
  89198. name: string;
  89199. /**
  89200. * Does the sound autoplay once loaded.
  89201. */
  89202. autoplay: boolean;
  89203. /**
  89204. * Does the sound loop after it finishes playing once.
  89205. */
  89206. loop: boolean;
  89207. /**
  89208. * Does the sound use a custom attenuation curve to simulate the falloff
  89209. * happening when the source gets further away from the camera.
  89210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89211. */
  89212. useCustomAttenuation: boolean;
  89213. /**
  89214. * The sound track id this sound belongs to.
  89215. */
  89216. soundTrackId: number;
  89217. /**
  89218. * Is this sound currently played.
  89219. */
  89220. isPlaying: boolean;
  89221. /**
  89222. * Is this sound currently paused.
  89223. */
  89224. isPaused: boolean;
  89225. /**
  89226. * Does this sound enables spatial sound.
  89227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89228. */
  89229. spatialSound: boolean;
  89230. /**
  89231. * Define the reference distance the sound should be heard perfectly.
  89232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89233. */
  89234. refDistance: number;
  89235. /**
  89236. * Define the roll off factor of spatial sounds.
  89237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89238. */
  89239. rolloffFactor: number;
  89240. /**
  89241. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89243. */
  89244. maxDistance: number;
  89245. /**
  89246. * Define the distance attenuation model the sound will follow.
  89247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89248. */
  89249. distanceModel: string;
  89250. /**
  89251. * @hidden
  89252. * Back Compat
  89253. **/
  89254. onended: () => any;
  89255. /**
  89256. * Observable event when the current playing sound finishes.
  89257. */
  89258. onEndedObservable: Observable<Sound>;
  89259. private _panningModel;
  89260. private _playbackRate;
  89261. private _streaming;
  89262. private _startTime;
  89263. private _startOffset;
  89264. private _position;
  89265. /** @hidden */
  89266. _positionInEmitterSpace: boolean;
  89267. private _localDirection;
  89268. private _volume;
  89269. private _isReadyToPlay;
  89270. private _isDirectional;
  89271. private _readyToPlayCallback;
  89272. private _audioBuffer;
  89273. private _soundSource;
  89274. private _streamingSource;
  89275. private _soundPanner;
  89276. private _soundGain;
  89277. private _inputAudioNode;
  89278. private _outputAudioNode;
  89279. private _coneInnerAngle;
  89280. private _coneOuterAngle;
  89281. private _coneOuterGain;
  89282. private _scene;
  89283. private _connectedTransformNode;
  89284. private _customAttenuationFunction;
  89285. private _registerFunc;
  89286. private _isOutputConnected;
  89287. private _htmlAudioElement;
  89288. private _urlType;
  89289. /** @hidden */
  89290. static _SceneComponentInitialization: (scene: Scene) => void;
  89291. /**
  89292. * Create a sound and attach it to a scene
  89293. * @param name Name of your sound
  89294. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89295. * @param scene defines the scene the sound belongs to
  89296. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89297. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89298. */
  89299. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89300. /**
  89301. * Release the sound and its associated resources
  89302. */
  89303. dispose(): void;
  89304. /**
  89305. * Gets if the sounds is ready to be played or not.
  89306. * @returns true if ready, otherwise false
  89307. */
  89308. isReady(): boolean;
  89309. private _soundLoaded;
  89310. /**
  89311. * Sets the data of the sound from an audiobuffer
  89312. * @param audioBuffer The audioBuffer containing the data
  89313. */
  89314. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89315. /**
  89316. * Updates the current sounds options such as maxdistance, loop...
  89317. * @param options A JSON object containing values named as the object properties
  89318. */
  89319. updateOptions(options: any): void;
  89320. private _createSpatialParameters;
  89321. private _updateSpatialParameters;
  89322. /**
  89323. * Switch the panning model to HRTF:
  89324. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89326. */
  89327. switchPanningModelToHRTF(): void;
  89328. /**
  89329. * Switch the panning model to Equal Power:
  89330. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89332. */
  89333. switchPanningModelToEqualPower(): void;
  89334. private _switchPanningModel;
  89335. /**
  89336. * Connect this sound to a sound track audio node like gain...
  89337. * @param soundTrackAudioNode the sound track audio node to connect to
  89338. */
  89339. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89340. /**
  89341. * Transform this sound into a directional source
  89342. * @param coneInnerAngle Size of the inner cone in degree
  89343. * @param coneOuterAngle Size of the outer cone in degree
  89344. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89345. */
  89346. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89347. /**
  89348. * Gets or sets the inner angle for the directional cone.
  89349. */
  89350. /**
  89351. * Gets or sets the inner angle for the directional cone.
  89352. */
  89353. directionalConeInnerAngle: number;
  89354. /**
  89355. * Gets or sets the outer angle for the directional cone.
  89356. */
  89357. /**
  89358. * Gets or sets the outer angle for the directional cone.
  89359. */
  89360. directionalConeOuterAngle: number;
  89361. /**
  89362. * Sets the position of the emitter if spatial sound is enabled
  89363. * @param newPosition Defines the new posisiton
  89364. */
  89365. setPosition(newPosition: Vector3): void;
  89366. /**
  89367. * Sets the local direction of the emitter if spatial sound is enabled
  89368. * @param newLocalDirection Defines the new local direction
  89369. */
  89370. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89371. private _updateDirection;
  89372. /** @hidden */
  89373. updateDistanceFromListener(): void;
  89374. /**
  89375. * Sets a new custom attenuation function for the sound.
  89376. * @param callback Defines the function used for the attenuation
  89377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89378. */
  89379. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89380. /**
  89381. * Play the sound
  89382. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89383. * @param offset (optional) Start the sound setting it at a specific time
  89384. */
  89385. play(time?: number, offset?: number): void;
  89386. private _onended;
  89387. /**
  89388. * Stop the sound
  89389. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89390. */
  89391. stop(time?: number): void;
  89392. /**
  89393. * Put the sound in pause
  89394. */
  89395. pause(): void;
  89396. /**
  89397. * Sets a dedicated volume for this sounds
  89398. * @param newVolume Define the new volume of the sound
  89399. * @param time Define in how long the sound should be at this value
  89400. */
  89401. setVolume(newVolume: number, time?: number): void;
  89402. /**
  89403. * Set the sound play back rate
  89404. * @param newPlaybackRate Define the playback rate the sound should be played at
  89405. */
  89406. setPlaybackRate(newPlaybackRate: number): void;
  89407. /**
  89408. * Gets the volume of the sound.
  89409. * @returns the volume of the sound
  89410. */
  89411. getVolume(): number;
  89412. /**
  89413. * Attach the sound to a dedicated mesh
  89414. * @param transformNode The transform node to connect the sound with
  89415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89416. */
  89417. attachToMesh(transformNode: TransformNode): void;
  89418. /**
  89419. * Detach the sound from the previously attached mesh
  89420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89421. */
  89422. detachFromMesh(): void;
  89423. private _onRegisterAfterWorldMatrixUpdate;
  89424. /**
  89425. * Clone the current sound in the scene.
  89426. * @returns the new sound clone
  89427. */
  89428. clone(): Nullable<Sound>;
  89429. /**
  89430. * Gets the current underlying audio buffer containing the data
  89431. * @returns the audio buffer
  89432. */
  89433. getAudioBuffer(): Nullable<AudioBuffer>;
  89434. /**
  89435. * Serializes the Sound in a JSON representation
  89436. * @returns the JSON representation of the sound
  89437. */
  89438. serialize(): any;
  89439. /**
  89440. * Parse a JSON representation of a sound to innstantiate in a given scene
  89441. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89442. * @param scene Define the scene the new parsed sound should be created in
  89443. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89444. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89445. * @returns the newly parsed sound
  89446. */
  89447. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89448. }
  89449. }
  89450. declare module BABYLON {
  89451. /**
  89452. * This defines an action helpful to play a defined sound on a triggered action.
  89453. */
  89454. export class PlaySoundAction extends Action {
  89455. private _sound;
  89456. /**
  89457. * Instantiate the action
  89458. * @param triggerOptions defines the trigger options
  89459. * @param sound defines the sound to play
  89460. * @param condition defines the trigger related conditions
  89461. */
  89462. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89463. /** @hidden */
  89464. _prepare(): void;
  89465. /**
  89466. * Execute the action and play the sound.
  89467. */
  89468. execute(): void;
  89469. /**
  89470. * Serializes the actions and its related information.
  89471. * @param parent defines the object to serialize in
  89472. * @returns the serialized object
  89473. */
  89474. serialize(parent: any): any;
  89475. }
  89476. /**
  89477. * This defines an action helpful to stop a defined sound on a triggered action.
  89478. */
  89479. export class StopSoundAction extends Action {
  89480. private _sound;
  89481. /**
  89482. * Instantiate the action
  89483. * @param triggerOptions defines the trigger options
  89484. * @param sound defines the sound to stop
  89485. * @param condition defines the trigger related conditions
  89486. */
  89487. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89488. /** @hidden */
  89489. _prepare(): void;
  89490. /**
  89491. * Execute the action and stop the sound.
  89492. */
  89493. execute(): void;
  89494. /**
  89495. * Serializes the actions and its related information.
  89496. * @param parent defines the object to serialize in
  89497. * @returns the serialized object
  89498. */
  89499. serialize(parent: any): any;
  89500. }
  89501. }
  89502. declare module BABYLON {
  89503. /**
  89504. * This defines an action responsible to change the value of a property
  89505. * by interpolating between its current value and the newly set one once triggered.
  89506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89507. */
  89508. export class InterpolateValueAction extends Action {
  89509. /**
  89510. * Defines the path of the property where the value should be interpolated
  89511. */
  89512. propertyPath: string;
  89513. /**
  89514. * Defines the target value at the end of the interpolation.
  89515. */
  89516. value: any;
  89517. /**
  89518. * Defines the time it will take for the property to interpolate to the value.
  89519. */
  89520. duration: number;
  89521. /**
  89522. * Defines if the other scene animations should be stopped when the action has been triggered
  89523. */
  89524. stopOtherAnimations?: boolean;
  89525. /**
  89526. * Defines a callback raised once the interpolation animation has been done.
  89527. */
  89528. onInterpolationDone?: () => void;
  89529. /**
  89530. * Observable triggered once the interpolation animation has been done.
  89531. */
  89532. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89533. private _target;
  89534. private _effectiveTarget;
  89535. private _property;
  89536. /**
  89537. * Instantiate the action
  89538. * @param triggerOptions defines the trigger options
  89539. * @param target defines the object containing the value to interpolate
  89540. * @param propertyPath defines the path to the property in the target object
  89541. * @param value defines the target value at the end of the interpolation
  89542. * @param duration deines the time it will take for the property to interpolate to the value.
  89543. * @param condition defines the trigger related conditions
  89544. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89545. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89546. */
  89547. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89548. /** @hidden */
  89549. _prepare(): void;
  89550. /**
  89551. * Execute the action starts the value interpolation.
  89552. */
  89553. execute(): void;
  89554. /**
  89555. * Serializes the actions and its related information.
  89556. * @param parent defines the object to serialize in
  89557. * @returns the serialized object
  89558. */
  89559. serialize(parent: any): any;
  89560. }
  89561. }
  89562. declare module BABYLON {
  89563. /**
  89564. * Options allowed during the creation of a sound track.
  89565. */
  89566. export interface ISoundTrackOptions {
  89567. /**
  89568. * The volume the sound track should take during creation
  89569. */
  89570. volume?: number;
  89571. /**
  89572. * Define if the sound track is the main sound track of the scene
  89573. */
  89574. mainTrack?: boolean;
  89575. }
  89576. /**
  89577. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  89578. * It will be also used in a future release to apply effects on a specific track.
  89579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89580. */
  89581. export class SoundTrack {
  89582. /**
  89583. * The unique identifier of the sound track in the scene.
  89584. */
  89585. id: number;
  89586. /**
  89587. * The list of sounds included in the sound track.
  89588. */
  89589. soundCollection: Array<Sound>;
  89590. private _outputAudioNode;
  89591. private _scene;
  89592. private _isMainTrack;
  89593. private _connectedAnalyser;
  89594. private _options;
  89595. private _isInitialized;
  89596. /**
  89597. * Creates a new sound track.
  89598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89599. * @param scene Define the scene the sound track belongs to
  89600. * @param options
  89601. */
  89602. constructor(scene: Scene, options?: ISoundTrackOptions);
  89603. private _initializeSoundTrackAudioGraph;
  89604. /**
  89605. * Release the sound track and its associated resources
  89606. */
  89607. dispose(): void;
  89608. /**
  89609. * Adds a sound to this sound track
  89610. * @param sound define the cound to add
  89611. * @ignoreNaming
  89612. */
  89613. AddSound(sound: Sound): void;
  89614. /**
  89615. * Removes a sound to this sound track
  89616. * @param sound define the cound to remove
  89617. * @ignoreNaming
  89618. */
  89619. RemoveSound(sound: Sound): void;
  89620. /**
  89621. * Set a global volume for the full sound track.
  89622. * @param newVolume Define the new volume of the sound track
  89623. */
  89624. setVolume(newVolume: number): void;
  89625. /**
  89626. * Switch the panning model to HRTF:
  89627. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89629. */
  89630. switchPanningModelToHRTF(): void;
  89631. /**
  89632. * Switch the panning model to Equal Power:
  89633. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89635. */
  89636. switchPanningModelToEqualPower(): void;
  89637. /**
  89638. * Connect the sound track to an audio analyser allowing some amazing
  89639. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89641. * @param analyser The analyser to connect to the engine
  89642. */
  89643. connectToAnalyser(analyser: Analyser): void;
  89644. }
  89645. }
  89646. declare module BABYLON {
  89647. interface AbstractScene {
  89648. /**
  89649. * The list of sounds used in the scene.
  89650. */
  89651. sounds: Nullable<Array<Sound>>;
  89652. }
  89653. interface Scene {
  89654. /**
  89655. * @hidden
  89656. * Backing field
  89657. */
  89658. _mainSoundTrack: SoundTrack;
  89659. /**
  89660. * The main sound track played by the scene.
  89661. * It cotains your primary collection of sounds.
  89662. */
  89663. mainSoundTrack: SoundTrack;
  89664. /**
  89665. * The list of sound tracks added to the scene
  89666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89667. */
  89668. soundTracks: Nullable<Array<SoundTrack>>;
  89669. /**
  89670. * Gets a sound using a given name
  89671. * @param name defines the name to search for
  89672. * @return the found sound or null if not found at all.
  89673. */
  89674. getSoundByName(name: string): Nullable<Sound>;
  89675. /**
  89676. * Gets or sets if audio support is enabled
  89677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89678. */
  89679. audioEnabled: boolean;
  89680. /**
  89681. * Gets or sets if audio will be output to headphones
  89682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89683. */
  89684. headphone: boolean;
  89685. }
  89686. /**
  89687. * Defines the sound scene component responsible to manage any sounds
  89688. * in a given scene.
  89689. */
  89690. export class AudioSceneComponent implements ISceneSerializableComponent {
  89691. /**
  89692. * The component name helpfull to identify the component in the list of scene components.
  89693. */
  89694. readonly name: string;
  89695. /**
  89696. * The scene the component belongs to.
  89697. */
  89698. scene: Scene;
  89699. private _audioEnabled;
  89700. /**
  89701. * Gets whether audio is enabled or not.
  89702. * Please use related enable/disable method to switch state.
  89703. */
  89704. readonly audioEnabled: boolean;
  89705. private _headphone;
  89706. /**
  89707. * Gets whether audio is outputing to headphone or not.
  89708. * Please use the according Switch methods to change output.
  89709. */
  89710. readonly headphone: boolean;
  89711. /**
  89712. * Creates a new instance of the component for the given scene
  89713. * @param scene Defines the scene to register the component in
  89714. */
  89715. constructor(scene: Scene);
  89716. /**
  89717. * Registers the component in a given scene
  89718. */
  89719. register(): void;
  89720. /**
  89721. * Rebuilds the elements related to this component in case of
  89722. * context lost for instance.
  89723. */
  89724. rebuild(): void;
  89725. /**
  89726. * Serializes the component data to the specified json object
  89727. * @param serializationObject The object to serialize to
  89728. */
  89729. serialize(serializationObject: any): void;
  89730. /**
  89731. * Adds all the element from the container to the scene
  89732. * @param container the container holding the elements
  89733. */
  89734. addFromContainer(container: AbstractScene): void;
  89735. /**
  89736. * Removes all the elements in the container from the scene
  89737. * @param container contains the elements to remove
  89738. */
  89739. removeFromContainer(container: AbstractScene): void;
  89740. /**
  89741. * Disposes the component and the associated ressources.
  89742. */
  89743. dispose(): void;
  89744. /**
  89745. * Disables audio in the associated scene.
  89746. */
  89747. disableAudio(): void;
  89748. /**
  89749. * Enables audio in the associated scene.
  89750. */
  89751. enableAudio(): void;
  89752. /**
  89753. * Switch audio to headphone output.
  89754. */
  89755. switchAudioModeForHeadphones(): void;
  89756. /**
  89757. * Switch audio to normal speakers.
  89758. */
  89759. switchAudioModeForNormalSpeakers(): void;
  89760. private _afterRender;
  89761. }
  89762. }
  89763. declare module BABYLON {
  89764. /**
  89765. * Wraps one or more Sound objects and selects one with random weight for playback.
  89766. */
  89767. export class WeightedSound {
  89768. /** When true a Sound will be selected and played when the current playing Sound completes. */
  89769. loop: boolean;
  89770. private _coneInnerAngle;
  89771. private _coneOuterAngle;
  89772. private _volume;
  89773. /** A Sound is currently playing. */
  89774. isPlaying: boolean;
  89775. /** A Sound is currently paused. */
  89776. isPaused: boolean;
  89777. private _sounds;
  89778. private _weights;
  89779. private _currentIndex?;
  89780. /**
  89781. * Creates a new WeightedSound from the list of sounds given.
  89782. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  89783. * @param sounds Array of Sounds that will be selected from.
  89784. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  89785. */
  89786. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  89787. /**
  89788. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  89789. */
  89790. /**
  89791. * The size of cone in degress for a directional sound in which there will be no attenuation.
  89792. */
  89793. directionalConeInnerAngle: number;
  89794. /**
  89795. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89796. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89797. */
  89798. /**
  89799. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89800. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89801. */
  89802. directionalConeOuterAngle: number;
  89803. /**
  89804. * Playback volume.
  89805. */
  89806. /**
  89807. * Playback volume.
  89808. */
  89809. volume: number;
  89810. private _onended;
  89811. /**
  89812. * Suspend playback
  89813. */
  89814. pause(): void;
  89815. /**
  89816. * Stop playback
  89817. */
  89818. stop(): void;
  89819. /**
  89820. * Start playback.
  89821. * @param startOffset Position the clip head at a specific time in seconds.
  89822. */
  89823. play(startOffset?: number): void;
  89824. }
  89825. }
  89826. declare module BABYLON {
  89827. /**
  89828. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  89829. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  89830. */
  89831. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  89832. /**
  89833. * Gets the name of the behavior.
  89834. */
  89835. readonly name: string;
  89836. /**
  89837. * The easing function used by animations
  89838. */
  89839. static EasingFunction: BackEase;
  89840. /**
  89841. * The easing mode used by animations
  89842. */
  89843. static EasingMode: number;
  89844. /**
  89845. * The duration of the animation, in milliseconds
  89846. */
  89847. transitionDuration: number;
  89848. /**
  89849. * Length of the distance animated by the transition when lower radius is reached
  89850. */
  89851. lowerRadiusTransitionRange: number;
  89852. /**
  89853. * Length of the distance animated by the transition when upper radius is reached
  89854. */
  89855. upperRadiusTransitionRange: number;
  89856. private _autoTransitionRange;
  89857. /**
  89858. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89859. */
  89860. /**
  89861. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89862. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  89863. */
  89864. autoTransitionRange: boolean;
  89865. private _attachedCamera;
  89866. private _onAfterCheckInputsObserver;
  89867. private _onMeshTargetChangedObserver;
  89868. /**
  89869. * Initializes the behavior.
  89870. */
  89871. init(): void;
  89872. /**
  89873. * Attaches the behavior to its arc rotate camera.
  89874. * @param camera Defines the camera to attach the behavior to
  89875. */
  89876. attach(camera: ArcRotateCamera): void;
  89877. /**
  89878. * Detaches the behavior from its current arc rotate camera.
  89879. */
  89880. detach(): void;
  89881. private _radiusIsAnimating;
  89882. private _radiusBounceTransition;
  89883. private _animatables;
  89884. private _cachedWheelPrecision;
  89885. /**
  89886. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  89887. * @param radiusLimit The limit to check against.
  89888. * @return Bool to indicate if at limit.
  89889. */
  89890. private _isRadiusAtLimit;
  89891. /**
  89892. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  89893. * @param radiusDelta The delta by which to animate to. Can be negative.
  89894. */
  89895. private _applyBoundRadiusAnimation;
  89896. /**
  89897. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  89898. */
  89899. protected _clearAnimationLocks(): void;
  89900. /**
  89901. * Stops and removes all animations that have been applied to the camera
  89902. */
  89903. stopAllAnimations(): void;
  89904. }
  89905. }
  89906. declare module BABYLON {
  89907. /**
  89908. * 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.
  89909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  89910. */
  89911. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  89912. /**
  89913. * Gets the name of the behavior.
  89914. */
  89915. readonly name: string;
  89916. private _mode;
  89917. private _radiusScale;
  89918. private _positionScale;
  89919. private _defaultElevation;
  89920. private _elevationReturnTime;
  89921. private _elevationReturnWaitTime;
  89922. private _zoomStopsAnimation;
  89923. private _framingTime;
  89924. /**
  89925. * The easing function used by animations
  89926. */
  89927. static EasingFunction: ExponentialEase;
  89928. /**
  89929. * The easing mode used by animations
  89930. */
  89931. static EasingMode: number;
  89932. /**
  89933. * Sets the current mode used by the behavior
  89934. */
  89935. /**
  89936. * Gets current mode used by the behavior.
  89937. */
  89938. mode: number;
  89939. /**
  89940. * Sets the scale applied to the radius (1 by default)
  89941. */
  89942. /**
  89943. * Gets the scale applied to the radius
  89944. */
  89945. radiusScale: number;
  89946. /**
  89947. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  89948. */
  89949. /**
  89950. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  89951. */
  89952. positionScale: number;
  89953. /**
  89954. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  89955. * behaviour is triggered, in radians.
  89956. */
  89957. /**
  89958. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  89959. * behaviour is triggered, in radians.
  89960. */
  89961. defaultElevation: number;
  89962. /**
  89963. * Sets the time (in milliseconds) taken to return to the default beta position.
  89964. * Negative value indicates camera should not return to default.
  89965. */
  89966. /**
  89967. * Gets the time (in milliseconds) taken to return to the default beta position.
  89968. * Negative value indicates camera should not return to default.
  89969. */
  89970. elevationReturnTime: number;
  89971. /**
  89972. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  89973. */
  89974. /**
  89975. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  89976. */
  89977. elevationReturnWaitTime: number;
  89978. /**
  89979. * Sets the flag that indicates if user zooming should stop animation.
  89980. */
  89981. /**
  89982. * Gets the flag that indicates if user zooming should stop animation.
  89983. */
  89984. zoomStopsAnimation: boolean;
  89985. /**
  89986. * Sets the transition time when framing the mesh, in milliseconds
  89987. */
  89988. /**
  89989. * Gets the transition time when framing the mesh, in milliseconds
  89990. */
  89991. framingTime: number;
  89992. /**
  89993. * Define if the behavior should automatically change the configured
  89994. * camera limits and sensibilities.
  89995. */
  89996. autoCorrectCameraLimitsAndSensibility: boolean;
  89997. private _onPrePointerObservableObserver;
  89998. private _onAfterCheckInputsObserver;
  89999. private _onMeshTargetChangedObserver;
  90000. private _attachedCamera;
  90001. private _isPointerDown;
  90002. private _lastInteractionTime;
  90003. /**
  90004. * Initializes the behavior.
  90005. */
  90006. init(): void;
  90007. /**
  90008. * Attaches the behavior to its arc rotate camera.
  90009. * @param camera Defines the camera to attach the behavior to
  90010. */
  90011. attach(camera: ArcRotateCamera): void;
  90012. /**
  90013. * Detaches the behavior from its current arc rotate camera.
  90014. */
  90015. detach(): void;
  90016. private _animatables;
  90017. private _betaIsAnimating;
  90018. private _betaTransition;
  90019. private _radiusTransition;
  90020. private _vectorTransition;
  90021. /**
  90022. * Targets the given mesh and updates zoom level accordingly.
  90023. * @param mesh The mesh to target.
  90024. * @param radius Optional. If a cached radius position already exists, overrides default.
  90025. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90026. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90027. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90028. */
  90029. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90030. /**
  90031. * Targets the given mesh with its children and updates zoom level accordingly.
  90032. * @param mesh The mesh to target.
  90033. * @param radius Optional. If a cached radius position already exists, overrides default.
  90034. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90035. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90036. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90037. */
  90038. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90039. /**
  90040. * Targets the given meshes with their children and updates zoom level accordingly.
  90041. * @param meshes The mesh to target.
  90042. * @param radius Optional. If a cached radius position already exists, overrides default.
  90043. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90044. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90045. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90046. */
  90047. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90048. /**
  90049. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90050. * @param minimumWorld Determines the smaller position of the bounding box extend
  90051. * @param maximumWorld Determines the bigger position of the bounding box extend
  90052. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90053. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90054. */
  90055. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90056. /**
  90057. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90058. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90059. * frustum width.
  90060. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90061. * to fully enclose the mesh in the viewing frustum.
  90062. */
  90063. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90064. /**
  90065. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90066. * is automatically returned to its default position (expected to be above ground plane).
  90067. */
  90068. private _maintainCameraAboveGround;
  90069. /**
  90070. * Returns the frustum slope based on the canvas ratio and camera FOV
  90071. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90072. */
  90073. private _getFrustumSlope;
  90074. /**
  90075. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90076. */
  90077. private _clearAnimationLocks;
  90078. /**
  90079. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90080. */
  90081. private _applyUserInteraction;
  90082. /**
  90083. * Stops and removes all animations that have been applied to the camera
  90084. */
  90085. stopAllAnimations(): void;
  90086. /**
  90087. * Gets a value indicating if the user is moving the camera
  90088. */
  90089. readonly isUserIsMoving: boolean;
  90090. /**
  90091. * The camera can move all the way towards the mesh.
  90092. */
  90093. static IgnoreBoundsSizeMode: number;
  90094. /**
  90095. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90096. */
  90097. static FitFrustumSidesMode: number;
  90098. }
  90099. }
  90100. declare module BABYLON {
  90101. /**
  90102. * Manage the pointers inputs to control an arc rotate camera.
  90103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90104. */
  90105. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90106. /**
  90107. * Defines the camera the input is attached to.
  90108. */
  90109. camera: ArcRotateCamera;
  90110. /**
  90111. * Defines the buttons associated with the input to handle camera move.
  90112. */
  90113. buttons: number[];
  90114. /**
  90115. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90116. */
  90117. angularSensibilityX: number;
  90118. /**
  90119. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90120. */
  90121. angularSensibilityY: number;
  90122. /**
  90123. * Defines the pointer pinch precision or how fast is the camera zooming.
  90124. */
  90125. pinchPrecision: number;
  90126. /**
  90127. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90128. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90129. */
  90130. pinchDeltaPercentage: number;
  90131. /**
  90132. * Defines the pointer panning sensibility or how fast is the camera moving.
  90133. */
  90134. panningSensibility: number;
  90135. /**
  90136. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90137. */
  90138. multiTouchPanning: boolean;
  90139. /**
  90140. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90141. */
  90142. multiTouchPanAndZoom: boolean;
  90143. /**
  90144. * Revers pinch action direction.
  90145. */
  90146. pinchInwards: boolean;
  90147. private _isPanClick;
  90148. private _pointerInput;
  90149. private _observer;
  90150. private _onMouseMove;
  90151. private _onGestureStart;
  90152. private _onGesture;
  90153. private _MSGestureHandler;
  90154. private _onLostFocus;
  90155. private _onContextMenu;
  90156. /**
  90157. * Attach the input controls to a specific dom element to get the input from.
  90158. * @param element Defines the element the controls should be listened from
  90159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90160. */
  90161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90162. /**
  90163. * Detach the current controls from the specified dom element.
  90164. * @param element Defines the element to stop listening the inputs from
  90165. */
  90166. detachControl(element: Nullable<HTMLElement>): void;
  90167. /**
  90168. * Gets the class name of the current intput.
  90169. * @returns the class name
  90170. */
  90171. getClassName(): string;
  90172. /**
  90173. * Get the friendly name associated with the input class.
  90174. * @returns the input friendly name
  90175. */
  90176. getSimpleName(): string;
  90177. }
  90178. }
  90179. declare module BABYLON {
  90180. /**
  90181. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90183. */
  90184. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90185. /**
  90186. * Defines the camera the input is attached to.
  90187. */
  90188. camera: ArcRotateCamera;
  90189. /**
  90190. * Defines the list of key codes associated with the up action (increase alpha)
  90191. */
  90192. keysUp: number[];
  90193. /**
  90194. * Defines the list of key codes associated with the down action (decrease alpha)
  90195. */
  90196. keysDown: number[];
  90197. /**
  90198. * Defines the list of key codes associated with the left action (increase beta)
  90199. */
  90200. keysLeft: number[];
  90201. /**
  90202. * Defines the list of key codes associated with the right action (decrease beta)
  90203. */
  90204. keysRight: number[];
  90205. /**
  90206. * Defines the list of key codes associated with the reset action.
  90207. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90208. */
  90209. keysReset: number[];
  90210. /**
  90211. * Defines the panning sensibility of the inputs.
  90212. * (How fast is the camera paning)
  90213. */
  90214. panningSensibility: number;
  90215. /**
  90216. * Defines the zooming sensibility of the inputs.
  90217. * (How fast is the camera zooming)
  90218. */
  90219. zoomingSensibility: number;
  90220. /**
  90221. * Defines wether maintaining the alt key down switch the movement mode from
  90222. * orientation to zoom.
  90223. */
  90224. useAltToZoom: boolean;
  90225. /**
  90226. * Rotation speed of the camera
  90227. */
  90228. angularSpeed: number;
  90229. private _keys;
  90230. private _ctrlPressed;
  90231. private _altPressed;
  90232. private _onCanvasBlurObserver;
  90233. private _onKeyboardObserver;
  90234. private _engine;
  90235. private _scene;
  90236. /**
  90237. * Attach the input controls to a specific dom element to get the input from.
  90238. * @param element Defines the element the controls should be listened from
  90239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90240. */
  90241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90242. /**
  90243. * Detach the current controls from the specified dom element.
  90244. * @param element Defines the element to stop listening the inputs from
  90245. */
  90246. detachControl(element: Nullable<HTMLElement>): void;
  90247. /**
  90248. * Update the current camera state depending on the inputs that have been used this frame.
  90249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90250. */
  90251. checkInputs(): void;
  90252. /**
  90253. * Gets the class name of the current intput.
  90254. * @returns the class name
  90255. */
  90256. getClassName(): string;
  90257. /**
  90258. * Get the friendly name associated with the input class.
  90259. * @returns the input friendly name
  90260. */
  90261. getSimpleName(): string;
  90262. }
  90263. }
  90264. declare module BABYLON {
  90265. /**
  90266. * Manage the mouse wheel inputs to control an arc rotate camera.
  90267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90268. */
  90269. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90270. /**
  90271. * Defines the camera the input is attached to.
  90272. */
  90273. camera: ArcRotateCamera;
  90274. /**
  90275. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90276. */
  90277. wheelPrecision: number;
  90278. /**
  90279. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90280. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90281. */
  90282. wheelDeltaPercentage: number;
  90283. private _wheel;
  90284. private _observer;
  90285. /**
  90286. * Attach the input controls to a specific dom element to get the input from.
  90287. * @param element Defines the element the controls should be listened from
  90288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90289. */
  90290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90291. /**
  90292. * Detach the current controls from the specified dom element.
  90293. * @param element Defines the element to stop listening the inputs from
  90294. */
  90295. detachControl(element: Nullable<HTMLElement>): void;
  90296. /**
  90297. * Gets the class name of the current intput.
  90298. * @returns the class name
  90299. */
  90300. getClassName(): string;
  90301. /**
  90302. * Get the friendly name associated with the input class.
  90303. * @returns the input friendly name
  90304. */
  90305. getSimpleName(): string;
  90306. }
  90307. }
  90308. declare module BABYLON {
  90309. /**
  90310. * Default Inputs manager for the ArcRotateCamera.
  90311. * It groups all the default supported inputs for ease of use.
  90312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90313. */
  90314. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90315. /**
  90316. * Instantiates a new ArcRotateCameraInputsManager.
  90317. * @param camera Defines the camera the inputs belong to
  90318. */
  90319. constructor(camera: ArcRotateCamera);
  90320. /**
  90321. * Add mouse wheel input support to the input manager.
  90322. * @returns the current input manager
  90323. */
  90324. addMouseWheel(): ArcRotateCameraInputsManager;
  90325. /**
  90326. * Add pointers input support to the input manager.
  90327. * @returns the current input manager
  90328. */
  90329. addPointers(): ArcRotateCameraInputsManager;
  90330. /**
  90331. * Add keyboard input support to the input manager.
  90332. * @returns the current input manager
  90333. */
  90334. addKeyboard(): ArcRotateCameraInputsManager;
  90335. }
  90336. }
  90337. declare module BABYLON {
  90338. /**
  90339. * This represents an orbital type of camera.
  90340. *
  90341. * 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.
  90342. * 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.
  90343. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90344. */
  90345. export class ArcRotateCamera extends TargetCamera {
  90346. /**
  90347. * Defines the rotation angle of the camera along the longitudinal axis.
  90348. */
  90349. alpha: number;
  90350. /**
  90351. * Defines the rotation angle of the camera along the latitudinal axis.
  90352. */
  90353. beta: number;
  90354. /**
  90355. * Defines the radius of the camera from it s target point.
  90356. */
  90357. radius: number;
  90358. protected _target: Vector3;
  90359. protected _targetHost: Nullable<AbstractMesh>;
  90360. /**
  90361. * Defines the target point of the camera.
  90362. * The camera looks towards it form the radius distance.
  90363. */
  90364. target: Vector3;
  90365. /**
  90366. * Current inertia value on the longitudinal axis.
  90367. * The bigger this number the longer it will take for the camera to stop.
  90368. */
  90369. inertialAlphaOffset: number;
  90370. /**
  90371. * Current inertia value on the latitudinal axis.
  90372. * The bigger this number the longer it will take for the camera to stop.
  90373. */
  90374. inertialBetaOffset: number;
  90375. /**
  90376. * Current inertia value on the radius axis.
  90377. * The bigger this number the longer it will take for the camera to stop.
  90378. */
  90379. inertialRadiusOffset: number;
  90380. /**
  90381. * Minimum allowed angle on the longitudinal axis.
  90382. * This can help limiting how the Camera is able to move in the scene.
  90383. */
  90384. lowerAlphaLimit: Nullable<number>;
  90385. /**
  90386. * Maximum allowed angle on the longitudinal axis.
  90387. * This can help limiting how the Camera is able to move in the scene.
  90388. */
  90389. upperAlphaLimit: Nullable<number>;
  90390. /**
  90391. * Minimum allowed angle on the latitudinal axis.
  90392. * This can help limiting how the Camera is able to move in the scene.
  90393. */
  90394. lowerBetaLimit: number;
  90395. /**
  90396. * Maximum allowed angle on the latitudinal axis.
  90397. * This can help limiting how the Camera is able to move in the scene.
  90398. */
  90399. upperBetaLimit: number;
  90400. /**
  90401. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90402. * This can help limiting how the Camera is able to move in the scene.
  90403. */
  90404. lowerRadiusLimit: Nullable<number>;
  90405. /**
  90406. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90407. * This can help limiting how the Camera is able to move in the scene.
  90408. */
  90409. upperRadiusLimit: Nullable<number>;
  90410. /**
  90411. * Defines the current inertia value used during panning of the camera along the X axis.
  90412. */
  90413. inertialPanningX: number;
  90414. /**
  90415. * Defines the current inertia value used during panning of the camera along the Y axis.
  90416. */
  90417. inertialPanningY: number;
  90418. /**
  90419. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90420. * Basically if your fingers moves away from more than this distance you will be considered
  90421. * in pinch mode.
  90422. */
  90423. pinchToPanMaxDistance: number;
  90424. /**
  90425. * Defines the maximum distance the camera can pan.
  90426. * This could help keeping the cammera always in your scene.
  90427. */
  90428. panningDistanceLimit: Nullable<number>;
  90429. /**
  90430. * Defines the target of the camera before paning.
  90431. */
  90432. panningOriginTarget: Vector3;
  90433. /**
  90434. * Defines the value of the inertia used during panning.
  90435. * 0 would mean stop inertia and one would mean no decelleration at all.
  90436. */
  90437. panningInertia: number;
  90438. /**
  90439. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90440. */
  90441. angularSensibilityX: number;
  90442. /**
  90443. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90444. */
  90445. angularSensibilityY: number;
  90446. /**
  90447. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90448. */
  90449. pinchPrecision: number;
  90450. /**
  90451. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90452. * It will be used instead of pinchDeltaPrecision if different from 0.
  90453. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90454. */
  90455. pinchDeltaPercentage: number;
  90456. /**
  90457. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90458. */
  90459. panningSensibility: number;
  90460. /**
  90461. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90462. */
  90463. keysUp: number[];
  90464. /**
  90465. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90466. */
  90467. keysDown: number[];
  90468. /**
  90469. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90470. */
  90471. keysLeft: number[];
  90472. /**
  90473. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90474. */
  90475. keysRight: number[];
  90476. /**
  90477. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90478. */
  90479. wheelPrecision: number;
  90480. /**
  90481. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90482. * It will be used instead of pinchDeltaPrecision if different from 0.
  90483. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90484. */
  90485. wheelDeltaPercentage: number;
  90486. /**
  90487. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90488. */
  90489. zoomOnFactor: number;
  90490. /**
  90491. * Defines a screen offset for the camera position.
  90492. */
  90493. targetScreenOffset: Vector2;
  90494. /**
  90495. * Allows the camera to be completely reversed.
  90496. * If false the camera can not arrive upside down.
  90497. */
  90498. allowUpsideDown: boolean;
  90499. /**
  90500. * Define if double tap/click is used to restore the previously saved state of the camera.
  90501. */
  90502. useInputToRestoreState: boolean;
  90503. /** @hidden */
  90504. _viewMatrix: Matrix;
  90505. /** @hidden */
  90506. _useCtrlForPanning: boolean;
  90507. /** @hidden */
  90508. _panningMouseButton: number;
  90509. /**
  90510. * Defines the input associated to the camera.
  90511. */
  90512. inputs: ArcRotateCameraInputsManager;
  90513. /** @hidden */
  90514. _reset: () => void;
  90515. /**
  90516. * Defines the allowed panning axis.
  90517. */
  90518. panningAxis: Vector3;
  90519. protected _localDirection: Vector3;
  90520. protected _transformedDirection: Vector3;
  90521. private _bouncingBehavior;
  90522. /**
  90523. * Gets the bouncing behavior of the camera if it has been enabled.
  90524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90525. */
  90526. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90527. /**
  90528. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90530. */
  90531. useBouncingBehavior: boolean;
  90532. private _framingBehavior;
  90533. /**
  90534. * Gets the framing behavior of the camera if it has been enabled.
  90535. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90536. */
  90537. readonly framingBehavior: Nullable<FramingBehavior>;
  90538. /**
  90539. * Defines if the framing behavior of the camera is enabled on the camera.
  90540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90541. */
  90542. useFramingBehavior: boolean;
  90543. private _autoRotationBehavior;
  90544. /**
  90545. * Gets the auto rotation behavior of the camera if it has been enabled.
  90546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90547. */
  90548. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90549. /**
  90550. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90551. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90552. */
  90553. useAutoRotationBehavior: boolean;
  90554. /**
  90555. * Observable triggered when the mesh target has been changed on the camera.
  90556. */
  90557. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90558. /**
  90559. * Event raised when the camera is colliding with a mesh.
  90560. */
  90561. onCollide: (collidedMesh: AbstractMesh) => void;
  90562. /**
  90563. * Defines whether the camera should check collision with the objects oh the scene.
  90564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  90565. */
  90566. checkCollisions: boolean;
  90567. /**
  90568. * Defines the collision radius of the camera.
  90569. * This simulates a sphere around the camera.
  90570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  90571. */
  90572. collisionRadius: Vector3;
  90573. protected _collider: Collider;
  90574. protected _previousPosition: Vector3;
  90575. protected _collisionVelocity: Vector3;
  90576. protected _newPosition: Vector3;
  90577. protected _previousAlpha: number;
  90578. protected _previousBeta: number;
  90579. protected _previousRadius: number;
  90580. protected _collisionTriggered: boolean;
  90581. protected _targetBoundingCenter: Nullable<Vector3>;
  90582. private _computationVector;
  90583. private _tempAxisVector;
  90584. private _tempAxisRotationMatrix;
  90585. /**
  90586. * Instantiates a new ArcRotateCamera in a given scene
  90587. * @param name Defines the name of the camera
  90588. * @param alpha Defines the camera rotation along the logitudinal axis
  90589. * @param beta Defines the camera rotation along the latitudinal axis
  90590. * @param radius Defines the camera distance from its target
  90591. * @param target Defines the camera target
  90592. * @param scene Defines the scene the camera belongs to
  90593. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90594. */
  90595. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90596. /** @hidden */
  90597. _initCache(): void;
  90598. /** @hidden */
  90599. _updateCache(ignoreParentClass?: boolean): void;
  90600. protected _getTargetPosition(): Vector3;
  90601. private _storedAlpha;
  90602. private _storedBeta;
  90603. private _storedRadius;
  90604. private _storedTarget;
  90605. /**
  90606. * Stores the current state of the camera (alpha, beta, radius and target)
  90607. * @returns the camera itself
  90608. */
  90609. storeState(): Camera;
  90610. /**
  90611. * @hidden
  90612. * Restored camera state. You must call storeState() first
  90613. */
  90614. _restoreStateValues(): boolean;
  90615. /** @hidden */
  90616. _isSynchronizedViewMatrix(): boolean;
  90617. /**
  90618. * Attached controls to the current camera.
  90619. * @param element Defines the element the controls should be listened from
  90620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90621. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  90622. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  90623. */
  90624. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  90625. /**
  90626. * Detach the current controls from the camera.
  90627. * The camera will stop reacting to inputs.
  90628. * @param element Defines the element to stop listening the inputs from
  90629. */
  90630. detachControl(element: HTMLElement): void;
  90631. /** @hidden */
  90632. _checkInputs(): void;
  90633. protected _checkLimits(): void;
  90634. /**
  90635. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  90636. */
  90637. rebuildAnglesAndRadius(): void;
  90638. /**
  90639. * Use a position to define the current camera related information like aplha, beta and radius
  90640. * @param position Defines the position to set the camera at
  90641. */
  90642. setPosition(position: Vector3): void;
  90643. /**
  90644. * Defines the target the camera should look at.
  90645. * This will automatically adapt alpha beta and radius to fit within the new target.
  90646. * @param target Defines the new target as a Vector or a mesh
  90647. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  90648. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  90649. */
  90650. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  90651. /** @hidden */
  90652. _getViewMatrix(): Matrix;
  90653. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  90654. /**
  90655. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  90656. * @param meshes Defines the mesh to zoom on
  90657. * @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)
  90658. */
  90659. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  90660. /**
  90661. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  90662. * The target will be changed but the radius
  90663. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  90664. * @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)
  90665. */
  90666. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  90667. min: Vector3;
  90668. max: Vector3;
  90669. distance: number;
  90670. }, doNotUpdateMaxZ?: boolean): void;
  90671. /**
  90672. * @override
  90673. * Override Camera.createRigCamera
  90674. */
  90675. createRigCamera(name: string, cameraIndex: number): Camera;
  90676. /**
  90677. * @hidden
  90678. * @override
  90679. * Override Camera._updateRigCameras
  90680. */
  90681. _updateRigCameras(): void;
  90682. /**
  90683. * Destroy the camera and release the current resources hold by it.
  90684. */
  90685. dispose(): void;
  90686. /**
  90687. * Gets the current object class name.
  90688. * @return the class name
  90689. */
  90690. getClassName(): string;
  90691. }
  90692. }
  90693. declare module BABYLON {
  90694. /**
  90695. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  90696. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90697. */
  90698. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  90699. /**
  90700. * Gets the name of the behavior.
  90701. */
  90702. readonly name: string;
  90703. private _zoomStopsAnimation;
  90704. private _idleRotationSpeed;
  90705. private _idleRotationWaitTime;
  90706. private _idleRotationSpinupTime;
  90707. /**
  90708. * Sets the flag that indicates if user zooming should stop animation.
  90709. */
  90710. /**
  90711. * Gets the flag that indicates if user zooming should stop animation.
  90712. */
  90713. zoomStopsAnimation: boolean;
  90714. /**
  90715. * Sets the default speed at which the camera rotates around the model.
  90716. */
  90717. /**
  90718. * Gets the default speed at which the camera rotates around the model.
  90719. */
  90720. idleRotationSpeed: number;
  90721. /**
  90722. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  90723. */
  90724. /**
  90725. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  90726. */
  90727. idleRotationWaitTime: number;
  90728. /**
  90729. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90730. */
  90731. /**
  90732. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90733. */
  90734. idleRotationSpinupTime: number;
  90735. /**
  90736. * Gets a value indicating if the camera is currently rotating because of this behavior
  90737. */
  90738. readonly rotationInProgress: boolean;
  90739. private _onPrePointerObservableObserver;
  90740. private _onAfterCheckInputsObserver;
  90741. private _attachedCamera;
  90742. private _isPointerDown;
  90743. private _lastFrameTime;
  90744. private _lastInteractionTime;
  90745. private _cameraRotationSpeed;
  90746. /**
  90747. * Initializes the behavior.
  90748. */
  90749. init(): void;
  90750. /**
  90751. * Attaches the behavior to its arc rotate camera.
  90752. * @param camera Defines the camera to attach the behavior to
  90753. */
  90754. attach(camera: ArcRotateCamera): void;
  90755. /**
  90756. * Detaches the behavior from its current arc rotate camera.
  90757. */
  90758. detach(): void;
  90759. /**
  90760. * Returns true if user is scrolling.
  90761. * @return true if user is scrolling.
  90762. */
  90763. private _userIsZooming;
  90764. private _lastFrameRadius;
  90765. private _shouldAnimationStopForInteraction;
  90766. /**
  90767. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90768. */
  90769. private _applyUserInteraction;
  90770. private _userIsMoving;
  90771. }
  90772. }
  90773. declare module BABYLON {
  90774. /**
  90775. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  90776. */
  90777. export class AttachToBoxBehavior implements Behavior<Mesh> {
  90778. private ui;
  90779. /**
  90780. * The name of the behavior
  90781. */
  90782. name: string;
  90783. /**
  90784. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  90785. */
  90786. distanceAwayFromFace: number;
  90787. /**
  90788. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  90789. */
  90790. distanceAwayFromBottomOfFace: number;
  90791. private _faceVectors;
  90792. private _target;
  90793. private _scene;
  90794. private _onRenderObserver;
  90795. private _tmpMatrix;
  90796. private _tmpVector;
  90797. /**
  90798. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  90799. * @param ui The transform node that should be attched to the mesh
  90800. */
  90801. constructor(ui: TransformNode);
  90802. /**
  90803. * Initializes the behavior
  90804. */
  90805. init(): void;
  90806. private _closestFace;
  90807. private _zeroVector;
  90808. private _lookAtTmpMatrix;
  90809. private _lookAtToRef;
  90810. /**
  90811. * Attaches the AttachToBoxBehavior to the passed in mesh
  90812. * @param target The mesh that the specified node will be attached to
  90813. */
  90814. attach(target: Mesh): void;
  90815. /**
  90816. * Detaches the behavior from the mesh
  90817. */
  90818. detach(): void;
  90819. }
  90820. }
  90821. declare module BABYLON {
  90822. /**
  90823. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  90824. */
  90825. export class FadeInOutBehavior implements Behavior<Mesh> {
  90826. /**
  90827. * Time in milliseconds to delay before fading in (Default: 0)
  90828. */
  90829. delay: number;
  90830. /**
  90831. * Time in milliseconds for the mesh to fade in (Default: 300)
  90832. */
  90833. fadeInTime: number;
  90834. private _millisecondsPerFrame;
  90835. private _hovered;
  90836. private _hoverValue;
  90837. private _ownerNode;
  90838. /**
  90839. * Instatiates the FadeInOutBehavior
  90840. */
  90841. constructor();
  90842. /**
  90843. * The name of the behavior
  90844. */
  90845. readonly name: string;
  90846. /**
  90847. * Initializes the behavior
  90848. */
  90849. init(): void;
  90850. /**
  90851. * Attaches the fade behavior on the passed in mesh
  90852. * @param ownerNode The mesh that will be faded in/out once attached
  90853. */
  90854. attach(ownerNode: Mesh): void;
  90855. /**
  90856. * Detaches the behavior from the mesh
  90857. */
  90858. detach(): void;
  90859. /**
  90860. * Triggers the mesh to begin fading in or out
  90861. * @param value if the object should fade in or out (true to fade in)
  90862. */
  90863. fadeIn(value: boolean): void;
  90864. private _update;
  90865. private _setAllVisibility;
  90866. }
  90867. }
  90868. declare module BABYLON {
  90869. /**
  90870. * Class containing a set of static utilities functions for managing Pivots
  90871. * @hidden
  90872. */
  90873. export class PivotTools {
  90874. private static _PivotCached;
  90875. private static _OldPivotPoint;
  90876. private static _PivotTranslation;
  90877. private static _PivotTmpVector;
  90878. /** @hidden */
  90879. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  90880. /** @hidden */
  90881. static _RestorePivotPoint(mesh: AbstractMesh): void;
  90882. }
  90883. }
  90884. declare module BABYLON {
  90885. /**
  90886. * Class containing static functions to help procedurally build meshes
  90887. */
  90888. export class PlaneBuilder {
  90889. /**
  90890. * Creates a plane mesh
  90891. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90892. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90893. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90897. * @param name defines the name of the mesh
  90898. * @param options defines the options used to create the mesh
  90899. * @param scene defines the hosting scene
  90900. * @returns the plane mesh
  90901. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90902. */
  90903. static CreatePlane(name: string, options: {
  90904. size?: number;
  90905. width?: number;
  90906. height?: number;
  90907. sideOrientation?: number;
  90908. frontUVs?: Vector4;
  90909. backUVs?: Vector4;
  90910. updatable?: boolean;
  90911. sourcePlane?: Plane;
  90912. }, scene: Scene): Mesh;
  90913. }
  90914. }
  90915. declare module BABYLON {
  90916. /**
  90917. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  90918. */
  90919. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  90920. private static _AnyMouseID;
  90921. private _attachedNode;
  90922. private _dragPlane;
  90923. private _scene;
  90924. private _pointerObserver;
  90925. private _beforeRenderObserver;
  90926. private static _planeScene;
  90927. /**
  90928. * 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)
  90929. */
  90930. maxDragAngle: number;
  90931. /**
  90932. * @hidden
  90933. */
  90934. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  90935. /**
  90936. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  90937. */
  90938. currentDraggingPointerID: number;
  90939. /**
  90940. * The last position where the pointer hit the drag plane in world space
  90941. */
  90942. lastDragPosition: Vector3;
  90943. /**
  90944. * If the behavior is currently in a dragging state
  90945. */
  90946. dragging: boolean;
  90947. /**
  90948. * 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)
  90949. */
  90950. dragDeltaRatio: number;
  90951. /**
  90952. * If the drag plane orientation should be updated during the dragging (Default: true)
  90953. */
  90954. updateDragPlane: boolean;
  90955. private _debugMode;
  90956. private _moving;
  90957. /**
  90958. * Fires each time the attached mesh is dragged with the pointer
  90959. * * delta between last drag position and current drag position in world space
  90960. * * dragDistance along the drag axis
  90961. * * dragPlaneNormal normal of the current drag plane used during the drag
  90962. * * dragPlanePoint in world space where the drag intersects the drag plane
  90963. */
  90964. onDragObservable: Observable<{
  90965. delta: Vector3;
  90966. dragPlanePoint: Vector3;
  90967. dragPlaneNormal: Vector3;
  90968. dragDistance: number;
  90969. pointerId: number;
  90970. }>;
  90971. /**
  90972. * Fires each time a drag begins (eg. mouse down on mesh)
  90973. */
  90974. onDragStartObservable: Observable<{
  90975. dragPlanePoint: Vector3;
  90976. pointerId: number;
  90977. }>;
  90978. /**
  90979. * Fires each time a drag ends (eg. mouse release after drag)
  90980. */
  90981. onDragEndObservable: Observable<{
  90982. dragPlanePoint: Vector3;
  90983. pointerId: number;
  90984. }>;
  90985. /**
  90986. * If the attached mesh should be moved when dragged
  90987. */
  90988. moveAttached: boolean;
  90989. /**
  90990. * If the drag behavior will react to drag events (Default: true)
  90991. */
  90992. enabled: boolean;
  90993. /**
  90994. * If camera controls should be detached during the drag
  90995. */
  90996. detachCameraControls: boolean;
  90997. /**
  90998. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  90999. */
  91000. useObjectOrienationForDragging: boolean;
  91001. private _options;
  91002. /**
  91003. * Creates a pointer drag behavior that can be attached to a mesh
  91004. * @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)
  91005. */
  91006. constructor(options?: {
  91007. dragAxis?: Vector3;
  91008. dragPlaneNormal?: Vector3;
  91009. });
  91010. /**
  91011. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91012. */
  91013. validateDrag: (targetPosition: Vector3) => boolean;
  91014. /**
  91015. * The name of the behavior
  91016. */
  91017. readonly name: string;
  91018. /**
  91019. * Initializes the behavior
  91020. */
  91021. init(): void;
  91022. private _tmpVector;
  91023. private _alternatePickedPoint;
  91024. private _worldDragAxis;
  91025. private _targetPosition;
  91026. private _attachedElement;
  91027. /**
  91028. * Attaches the drag behavior the passed in mesh
  91029. * @param ownerNode The mesh that will be dragged around once attached
  91030. */
  91031. attach(ownerNode: AbstractMesh): void;
  91032. /**
  91033. * Force relase the drag action by code.
  91034. */
  91035. releaseDrag(): void;
  91036. private _startDragRay;
  91037. private _lastPointerRay;
  91038. /**
  91039. * Simulates the start of a pointer drag event on the behavior
  91040. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91041. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91042. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91043. */
  91044. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91045. private _startDrag;
  91046. private _dragDelta;
  91047. private _moveDrag;
  91048. private _pickWithRayOnDragPlane;
  91049. private _pointA;
  91050. private _pointB;
  91051. private _pointC;
  91052. private _lineA;
  91053. private _lineB;
  91054. private _localAxis;
  91055. private _lookAt;
  91056. private _updateDragPlanePosition;
  91057. /**
  91058. * Detaches the behavior from the mesh
  91059. */
  91060. detach(): void;
  91061. }
  91062. }
  91063. declare module BABYLON {
  91064. /**
  91065. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91066. */
  91067. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91068. private _dragBehaviorA;
  91069. private _dragBehaviorB;
  91070. private _startDistance;
  91071. private _initialScale;
  91072. private _targetScale;
  91073. private _ownerNode;
  91074. private _sceneRenderObserver;
  91075. /**
  91076. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91077. */
  91078. constructor();
  91079. /**
  91080. * The name of the behavior
  91081. */
  91082. readonly name: string;
  91083. /**
  91084. * Initializes the behavior
  91085. */
  91086. init(): void;
  91087. private _getCurrentDistance;
  91088. /**
  91089. * Attaches the scale behavior the passed in mesh
  91090. * @param ownerNode The mesh that will be scaled around once attached
  91091. */
  91092. attach(ownerNode: Mesh): void;
  91093. /**
  91094. * Detaches the behavior from the mesh
  91095. */
  91096. detach(): void;
  91097. }
  91098. }
  91099. declare module BABYLON {
  91100. /**
  91101. * 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
  91102. */
  91103. export class SixDofDragBehavior implements Behavior<Mesh> {
  91104. private static _virtualScene;
  91105. private _ownerNode;
  91106. private _sceneRenderObserver;
  91107. private _scene;
  91108. private _targetPosition;
  91109. private _virtualOriginMesh;
  91110. private _virtualDragMesh;
  91111. private _pointerObserver;
  91112. private _moving;
  91113. private _startingOrientation;
  91114. /**
  91115. * 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)
  91116. */
  91117. private zDragFactor;
  91118. /**
  91119. * If the object should rotate to face the drag origin
  91120. */
  91121. rotateDraggedObject: boolean;
  91122. /**
  91123. * If the behavior is currently in a dragging state
  91124. */
  91125. dragging: boolean;
  91126. /**
  91127. * 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)
  91128. */
  91129. dragDeltaRatio: number;
  91130. /**
  91131. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91132. */
  91133. currentDraggingPointerID: number;
  91134. /**
  91135. * If camera controls should be detached during the drag
  91136. */
  91137. detachCameraControls: boolean;
  91138. /**
  91139. * Fires each time a drag starts
  91140. */
  91141. onDragStartObservable: Observable<{}>;
  91142. /**
  91143. * Fires each time a drag ends (eg. mouse release after drag)
  91144. */
  91145. onDragEndObservable: Observable<{}>;
  91146. /**
  91147. * 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
  91148. */
  91149. constructor();
  91150. /**
  91151. * The name of the behavior
  91152. */
  91153. readonly name: string;
  91154. /**
  91155. * Initializes the behavior
  91156. */
  91157. init(): void;
  91158. /**
  91159. * Attaches the scale behavior the passed in mesh
  91160. * @param ownerNode The mesh that will be scaled around once attached
  91161. */
  91162. attach(ownerNode: Mesh): void;
  91163. /**
  91164. * Detaches the behavior from the mesh
  91165. */
  91166. detach(): void;
  91167. }
  91168. }
  91169. declare module BABYLON {
  91170. /**
  91171. * Class used to apply inverse kinematics to bones
  91172. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91173. */
  91174. export class BoneIKController {
  91175. private static _tmpVecs;
  91176. private static _tmpQuat;
  91177. private static _tmpMats;
  91178. /**
  91179. * Gets or sets the target mesh
  91180. */
  91181. targetMesh: AbstractMesh;
  91182. /** Gets or sets the mesh used as pole */
  91183. poleTargetMesh: AbstractMesh;
  91184. /**
  91185. * Gets or sets the bone used as pole
  91186. */
  91187. poleTargetBone: Nullable<Bone>;
  91188. /**
  91189. * Gets or sets the target position
  91190. */
  91191. targetPosition: Vector3;
  91192. /**
  91193. * Gets or sets the pole target position
  91194. */
  91195. poleTargetPosition: Vector3;
  91196. /**
  91197. * Gets or sets the pole target local offset
  91198. */
  91199. poleTargetLocalOffset: Vector3;
  91200. /**
  91201. * Gets or sets the pole angle
  91202. */
  91203. poleAngle: number;
  91204. /**
  91205. * Gets or sets the mesh associated with the controller
  91206. */
  91207. mesh: AbstractMesh;
  91208. /**
  91209. * 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)
  91210. */
  91211. slerpAmount: number;
  91212. private _bone1Quat;
  91213. private _bone1Mat;
  91214. private _bone2Ang;
  91215. private _bone1;
  91216. private _bone2;
  91217. private _bone1Length;
  91218. private _bone2Length;
  91219. private _maxAngle;
  91220. private _maxReach;
  91221. private _rightHandedSystem;
  91222. private _bendAxis;
  91223. private _slerping;
  91224. private _adjustRoll;
  91225. /**
  91226. * Gets or sets maximum allowed angle
  91227. */
  91228. maxAngle: number;
  91229. /**
  91230. * Creates a new BoneIKController
  91231. * @param mesh defines the mesh to control
  91232. * @param bone defines the bone to control
  91233. * @param options defines options to set up the controller
  91234. */
  91235. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91236. targetMesh?: AbstractMesh;
  91237. poleTargetMesh?: AbstractMesh;
  91238. poleTargetBone?: Bone;
  91239. poleTargetLocalOffset?: Vector3;
  91240. poleAngle?: number;
  91241. bendAxis?: Vector3;
  91242. maxAngle?: number;
  91243. slerpAmount?: number;
  91244. });
  91245. private _setMaxAngle;
  91246. /**
  91247. * Force the controller to update the bones
  91248. */
  91249. update(): void;
  91250. }
  91251. }
  91252. declare module BABYLON {
  91253. /**
  91254. * Class used to make a bone look toward a point in space
  91255. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91256. */
  91257. export class BoneLookController {
  91258. private static _tmpVecs;
  91259. private static _tmpQuat;
  91260. private static _tmpMats;
  91261. /**
  91262. * The target Vector3 that the bone will look at
  91263. */
  91264. target: Vector3;
  91265. /**
  91266. * The mesh that the bone is attached to
  91267. */
  91268. mesh: AbstractMesh;
  91269. /**
  91270. * The bone that will be looking to the target
  91271. */
  91272. bone: Bone;
  91273. /**
  91274. * The up axis of the coordinate system that is used when the bone is rotated
  91275. */
  91276. upAxis: Vector3;
  91277. /**
  91278. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91279. */
  91280. upAxisSpace: Space;
  91281. /**
  91282. * Used to make an adjustment to the yaw of the bone
  91283. */
  91284. adjustYaw: number;
  91285. /**
  91286. * Used to make an adjustment to the pitch of the bone
  91287. */
  91288. adjustPitch: number;
  91289. /**
  91290. * Used to make an adjustment to the roll of the bone
  91291. */
  91292. adjustRoll: number;
  91293. /**
  91294. * 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)
  91295. */
  91296. slerpAmount: number;
  91297. private _minYaw;
  91298. private _maxYaw;
  91299. private _minPitch;
  91300. private _maxPitch;
  91301. private _minYawSin;
  91302. private _minYawCos;
  91303. private _maxYawSin;
  91304. private _maxYawCos;
  91305. private _midYawConstraint;
  91306. private _minPitchTan;
  91307. private _maxPitchTan;
  91308. private _boneQuat;
  91309. private _slerping;
  91310. private _transformYawPitch;
  91311. private _transformYawPitchInv;
  91312. private _firstFrameSkipped;
  91313. private _yawRange;
  91314. private _fowardAxis;
  91315. /**
  91316. * Gets or sets the minimum yaw angle that the bone can look to
  91317. */
  91318. minYaw: number;
  91319. /**
  91320. * Gets or sets the maximum yaw angle that the bone can look to
  91321. */
  91322. maxYaw: number;
  91323. /**
  91324. * Gets or sets the minimum pitch angle that the bone can look to
  91325. */
  91326. minPitch: number;
  91327. /**
  91328. * Gets or sets the maximum pitch angle that the bone can look to
  91329. */
  91330. maxPitch: number;
  91331. /**
  91332. * Create a BoneLookController
  91333. * @param mesh the mesh that the bone belongs to
  91334. * @param bone the bone that will be looking to the target
  91335. * @param target the target Vector3 to look at
  91336. * @param options optional settings:
  91337. * * maxYaw: the maximum angle the bone will yaw to
  91338. * * minYaw: the minimum angle the bone will yaw to
  91339. * * maxPitch: the maximum angle the bone will pitch to
  91340. * * minPitch: the minimum angle the bone will yaw to
  91341. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91342. * * upAxis: the up axis of the coordinate system
  91343. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91344. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91345. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91346. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91347. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91348. * * adjustRoll: used to make an adjustment to the roll of the bone
  91349. **/
  91350. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91351. maxYaw?: number;
  91352. minYaw?: number;
  91353. maxPitch?: number;
  91354. minPitch?: number;
  91355. slerpAmount?: number;
  91356. upAxis?: Vector3;
  91357. upAxisSpace?: Space;
  91358. yawAxis?: Vector3;
  91359. pitchAxis?: Vector3;
  91360. adjustYaw?: number;
  91361. adjustPitch?: number;
  91362. adjustRoll?: number;
  91363. });
  91364. /**
  91365. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91366. */
  91367. update(): void;
  91368. private _getAngleDiff;
  91369. private _getAngleBetween;
  91370. private _isAngleBetween;
  91371. }
  91372. }
  91373. declare module BABYLON {
  91374. /**
  91375. * Manage the gamepad inputs to control an arc rotate camera.
  91376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91377. */
  91378. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91379. /**
  91380. * Defines the camera the input is attached to.
  91381. */
  91382. camera: ArcRotateCamera;
  91383. /**
  91384. * Defines the gamepad the input is gathering event from.
  91385. */
  91386. gamepad: Nullable<Gamepad>;
  91387. /**
  91388. * Defines the gamepad rotation sensiblity.
  91389. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91390. */
  91391. gamepadRotationSensibility: number;
  91392. /**
  91393. * Defines the gamepad move sensiblity.
  91394. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91395. */
  91396. gamepadMoveSensibility: number;
  91397. private _onGamepadConnectedObserver;
  91398. private _onGamepadDisconnectedObserver;
  91399. /**
  91400. * Attach the input controls to a specific dom element to get the input from.
  91401. * @param element Defines the element the controls should be listened from
  91402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91403. */
  91404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91405. /**
  91406. * Detach the current controls from the specified dom element.
  91407. * @param element Defines the element to stop listening the inputs from
  91408. */
  91409. detachControl(element: Nullable<HTMLElement>): void;
  91410. /**
  91411. * Update the current camera state depending on the inputs that have been used this frame.
  91412. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91413. */
  91414. checkInputs(): void;
  91415. /**
  91416. * Gets the class name of the current intput.
  91417. * @returns the class name
  91418. */
  91419. getClassName(): string;
  91420. /**
  91421. * Get the friendly name associated with the input class.
  91422. * @returns the input friendly name
  91423. */
  91424. getSimpleName(): string;
  91425. }
  91426. }
  91427. declare module BABYLON {
  91428. interface ArcRotateCameraInputsManager {
  91429. /**
  91430. * Add orientation input support to the input manager.
  91431. * @returns the current input manager
  91432. */
  91433. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91434. }
  91435. /**
  91436. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91438. */
  91439. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91440. /**
  91441. * Defines the camera the input is attached to.
  91442. */
  91443. camera: ArcRotateCamera;
  91444. /**
  91445. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91446. */
  91447. alphaCorrection: number;
  91448. /**
  91449. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91450. */
  91451. gammaCorrection: number;
  91452. private _alpha;
  91453. private _gamma;
  91454. private _dirty;
  91455. private _deviceOrientationHandler;
  91456. /**
  91457. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91458. */
  91459. constructor();
  91460. /**
  91461. * Attach the input controls to a specific dom element to get the input from.
  91462. * @param element Defines the element the controls should be listened from
  91463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91464. */
  91465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91466. /** @hidden */
  91467. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91468. /**
  91469. * Update the current camera state depending on the inputs that have been used this frame.
  91470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91471. */
  91472. checkInputs(): void;
  91473. /**
  91474. * Detach the current controls from the specified dom element.
  91475. * @param element Defines the element to stop listening the inputs from
  91476. */
  91477. detachControl(element: Nullable<HTMLElement>): void;
  91478. /**
  91479. * Gets the class name of the current intput.
  91480. * @returns the class name
  91481. */
  91482. getClassName(): string;
  91483. /**
  91484. * Get the friendly name associated with the input class.
  91485. * @returns the input friendly name
  91486. */
  91487. getSimpleName(): string;
  91488. }
  91489. }
  91490. declare module BABYLON {
  91491. /**
  91492. * Listen to mouse events to control the camera.
  91493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91494. */
  91495. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91496. /**
  91497. * Defines the camera the input is attached to.
  91498. */
  91499. camera: FlyCamera;
  91500. /**
  91501. * Defines if touch is enabled. (Default is true.)
  91502. */
  91503. touchEnabled: boolean;
  91504. /**
  91505. * Defines the buttons associated with the input to handle camera rotation.
  91506. */
  91507. buttons: number[];
  91508. /**
  91509. * Assign buttons for Yaw control.
  91510. */
  91511. buttonsYaw: number[];
  91512. /**
  91513. * Assign buttons for Pitch control.
  91514. */
  91515. buttonsPitch: number[];
  91516. /**
  91517. * Assign buttons for Roll control.
  91518. */
  91519. buttonsRoll: number[];
  91520. /**
  91521. * Detect if any button is being pressed while mouse is moved.
  91522. * -1 = Mouse locked.
  91523. * 0 = Left button.
  91524. * 1 = Middle Button.
  91525. * 2 = Right Button.
  91526. */
  91527. activeButton: number;
  91528. /**
  91529. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91530. * Higher values reduce its sensitivity.
  91531. */
  91532. angularSensibility: number;
  91533. private _mousemoveCallback;
  91534. private _observer;
  91535. private _rollObserver;
  91536. private previousPosition;
  91537. private noPreventDefault;
  91538. private element;
  91539. /**
  91540. * Listen to mouse events to control the camera.
  91541. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91543. */
  91544. constructor(touchEnabled?: boolean);
  91545. /**
  91546. * Attach the mouse control to the HTML DOM element.
  91547. * @param element Defines the element that listens to the input events.
  91548. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91549. */
  91550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91551. /**
  91552. * Detach the current controls from the specified dom element.
  91553. * @param element Defines the element to stop listening the inputs from
  91554. */
  91555. detachControl(element: Nullable<HTMLElement>): void;
  91556. /**
  91557. * Gets the class name of the current input.
  91558. * @returns the class name.
  91559. */
  91560. getClassName(): string;
  91561. /**
  91562. * Get the friendly name associated with the input class.
  91563. * @returns the input's friendly name.
  91564. */
  91565. getSimpleName(): string;
  91566. private _pointerInput;
  91567. private _onMouseMove;
  91568. /**
  91569. * Rotate camera by mouse offset.
  91570. */
  91571. private rotateCamera;
  91572. }
  91573. }
  91574. declare module BABYLON {
  91575. /**
  91576. * Default Inputs manager for the FlyCamera.
  91577. * It groups all the default supported inputs for ease of use.
  91578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91579. */
  91580. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  91581. /**
  91582. * Instantiates a new FlyCameraInputsManager.
  91583. * @param camera Defines the camera the inputs belong to.
  91584. */
  91585. constructor(camera: FlyCamera);
  91586. /**
  91587. * Add keyboard input support to the input manager.
  91588. * @returns the new FlyCameraKeyboardMoveInput().
  91589. */
  91590. addKeyboard(): FlyCameraInputsManager;
  91591. /**
  91592. * Add mouse input support to the input manager.
  91593. * @param touchEnabled Enable touch screen support.
  91594. * @returns the new FlyCameraMouseInput().
  91595. */
  91596. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  91597. }
  91598. }
  91599. declare module BABYLON {
  91600. /**
  91601. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91602. * such as in a 3D Space Shooter or a Flight Simulator.
  91603. */
  91604. export class FlyCamera extends TargetCamera {
  91605. /**
  91606. * Define the collision ellipsoid of the camera.
  91607. * This is helpful for simulating a camera body, like a player's body.
  91608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91609. */
  91610. ellipsoid: Vector3;
  91611. /**
  91612. * Define an offset for the position of the ellipsoid around the camera.
  91613. * This can be helpful if the camera is attached away from the player's body center,
  91614. * such as at its head.
  91615. */
  91616. ellipsoidOffset: Vector3;
  91617. /**
  91618. * Enable or disable collisions of the camera with the rest of the scene objects.
  91619. */
  91620. checkCollisions: boolean;
  91621. /**
  91622. * Enable or disable gravity on the camera.
  91623. */
  91624. applyGravity: boolean;
  91625. /**
  91626. * Define the current direction the camera is moving to.
  91627. */
  91628. cameraDirection: Vector3;
  91629. /**
  91630. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  91631. * This overrides and empties cameraRotation.
  91632. */
  91633. rotationQuaternion: Quaternion;
  91634. /**
  91635. * Track Roll to maintain the wanted Rolling when looking around.
  91636. */
  91637. _trackRoll: number;
  91638. /**
  91639. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  91640. */
  91641. rollCorrect: number;
  91642. /**
  91643. * Mimic a banked turn, Rolling the camera when Yawing.
  91644. * It's recommended to use rollCorrect = 10 for faster banking correction.
  91645. */
  91646. bankedTurn: boolean;
  91647. /**
  91648. * Limit in radians for how much Roll banking will add. (Default: 90°)
  91649. */
  91650. bankedTurnLimit: number;
  91651. /**
  91652. * Value of 0 disables the banked Roll.
  91653. * Value of 1 is equal to the Yaw angle in radians.
  91654. */
  91655. bankedTurnMultiplier: number;
  91656. /**
  91657. * The inputs manager loads all the input sources, such as keyboard and mouse.
  91658. */
  91659. inputs: FlyCameraInputsManager;
  91660. /**
  91661. * Gets the input sensibility for mouse input.
  91662. * Higher values reduce sensitivity.
  91663. */
  91664. /**
  91665. * Sets the input sensibility for a mouse input.
  91666. * Higher values reduce sensitivity.
  91667. */
  91668. angularSensibility: number;
  91669. /**
  91670. * Get the keys for camera movement forward.
  91671. */
  91672. /**
  91673. * Set the keys for camera movement forward.
  91674. */
  91675. keysForward: number[];
  91676. /**
  91677. * Get the keys for camera movement backward.
  91678. */
  91679. keysBackward: number[];
  91680. /**
  91681. * Get the keys for camera movement up.
  91682. */
  91683. /**
  91684. * Set the keys for camera movement up.
  91685. */
  91686. keysUp: number[];
  91687. /**
  91688. * Get the keys for camera movement down.
  91689. */
  91690. /**
  91691. * Set the keys for camera movement down.
  91692. */
  91693. keysDown: number[];
  91694. /**
  91695. * Get the keys for camera movement left.
  91696. */
  91697. /**
  91698. * Set the keys for camera movement left.
  91699. */
  91700. keysLeft: number[];
  91701. /**
  91702. * Set the keys for camera movement right.
  91703. */
  91704. /**
  91705. * Set the keys for camera movement right.
  91706. */
  91707. keysRight: number[];
  91708. /**
  91709. * Event raised when the camera collides with a mesh in the scene.
  91710. */
  91711. onCollide: (collidedMesh: AbstractMesh) => void;
  91712. private _collider;
  91713. private _needMoveForGravity;
  91714. private _oldPosition;
  91715. private _diffPosition;
  91716. private _newPosition;
  91717. /** @hidden */
  91718. _localDirection: Vector3;
  91719. /** @hidden */
  91720. _transformedDirection: Vector3;
  91721. /**
  91722. * Instantiates a FlyCamera.
  91723. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91724. * such as in a 3D Space Shooter or a Flight Simulator.
  91725. * @param name Define the name of the camera in the scene.
  91726. * @param position Define the starting position of the camera in the scene.
  91727. * @param scene Define the scene the camera belongs to.
  91728. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  91729. */
  91730. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91731. /**
  91732. * Attach a control to the HTML DOM element.
  91733. * @param element Defines the element that listens to the input events.
  91734. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  91735. */
  91736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91737. /**
  91738. * Detach a control from the HTML DOM element.
  91739. * The camera will stop reacting to that input.
  91740. * @param element Defines the element that listens to the input events.
  91741. */
  91742. detachControl(element: HTMLElement): void;
  91743. private _collisionMask;
  91744. /**
  91745. * Get the mask that the camera ignores in collision events.
  91746. */
  91747. /**
  91748. * Set the mask that the camera ignores in collision events.
  91749. */
  91750. collisionMask: number;
  91751. /** @hidden */
  91752. _collideWithWorld(displacement: Vector3): void;
  91753. /** @hidden */
  91754. private _onCollisionPositionChange;
  91755. /** @hidden */
  91756. _checkInputs(): void;
  91757. /** @hidden */
  91758. _decideIfNeedsToMove(): boolean;
  91759. /** @hidden */
  91760. _updatePosition(): void;
  91761. /**
  91762. * Restore the Roll to its target value at the rate specified.
  91763. * @param rate - Higher means slower restoring.
  91764. * @hidden
  91765. */
  91766. restoreRoll(rate: number): void;
  91767. /**
  91768. * Destroy the camera and release the current resources held by it.
  91769. */
  91770. dispose(): void;
  91771. /**
  91772. * Get the current object class name.
  91773. * @returns the class name.
  91774. */
  91775. getClassName(): string;
  91776. }
  91777. }
  91778. declare module BABYLON {
  91779. /**
  91780. * Listen to keyboard events to control the camera.
  91781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91782. */
  91783. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  91784. /**
  91785. * Defines the camera the input is attached to.
  91786. */
  91787. camera: FlyCamera;
  91788. /**
  91789. * The list of keyboard keys used to control the forward move of the camera.
  91790. */
  91791. keysForward: number[];
  91792. /**
  91793. * The list of keyboard keys used to control the backward move of the camera.
  91794. */
  91795. keysBackward: number[];
  91796. /**
  91797. * The list of keyboard keys used to control the forward move of the camera.
  91798. */
  91799. keysUp: number[];
  91800. /**
  91801. * The list of keyboard keys used to control the backward move of the camera.
  91802. */
  91803. keysDown: number[];
  91804. /**
  91805. * The list of keyboard keys used to control the right strafe move of the camera.
  91806. */
  91807. keysRight: number[];
  91808. /**
  91809. * The list of keyboard keys used to control the left strafe move of the camera.
  91810. */
  91811. keysLeft: number[];
  91812. private _keys;
  91813. private _onCanvasBlurObserver;
  91814. private _onKeyboardObserver;
  91815. private _engine;
  91816. private _scene;
  91817. /**
  91818. * Attach the input controls to a specific dom element to get the input from.
  91819. * @param element Defines the element the controls should be listened from
  91820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91821. */
  91822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91823. /**
  91824. * Detach the current controls from the specified dom element.
  91825. * @param element Defines the element to stop listening the inputs from
  91826. */
  91827. detachControl(element: Nullable<HTMLElement>): void;
  91828. /**
  91829. * Gets the class name of the current intput.
  91830. * @returns the class name
  91831. */
  91832. getClassName(): string;
  91833. /** @hidden */
  91834. _onLostFocus(e: FocusEvent): void;
  91835. /**
  91836. * Get the friendly name associated with the input class.
  91837. * @returns the input friendly name
  91838. */
  91839. getSimpleName(): string;
  91840. /**
  91841. * Update the current camera state depending on the inputs that have been used this frame.
  91842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91843. */
  91844. checkInputs(): void;
  91845. }
  91846. }
  91847. declare module BABYLON {
  91848. interface FreeCameraInputsManager {
  91849. /**
  91850. * Add orientation input support to the input manager.
  91851. * @returns the current input manager
  91852. */
  91853. addDeviceOrientation(): FreeCameraInputsManager;
  91854. }
  91855. /**
  91856. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  91857. * Screen rotation is taken into account.
  91858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91859. */
  91860. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  91861. private _camera;
  91862. private _screenOrientationAngle;
  91863. private _constantTranform;
  91864. private _screenQuaternion;
  91865. private _alpha;
  91866. private _beta;
  91867. private _gamma;
  91868. /**
  91869. * Instantiates a new input
  91870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91871. */
  91872. constructor();
  91873. /**
  91874. * Define the camera controlled by the input.
  91875. */
  91876. camera: FreeCamera;
  91877. /**
  91878. * Attach the input controls to a specific dom element to get the input from.
  91879. * @param element Defines the element the controls should be listened from
  91880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91881. */
  91882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91883. private _orientationChanged;
  91884. private _deviceOrientation;
  91885. /**
  91886. * Detach the current controls from the specified dom element.
  91887. * @param element Defines the element to stop listening the inputs from
  91888. */
  91889. detachControl(element: Nullable<HTMLElement>): void;
  91890. /**
  91891. * Update the current camera state depending on the inputs that have been used this frame.
  91892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91893. */
  91894. checkInputs(): void;
  91895. /**
  91896. * Gets the class name of the current intput.
  91897. * @returns the class name
  91898. */
  91899. getClassName(): string;
  91900. /**
  91901. * Get the friendly name associated with the input class.
  91902. * @returns the input friendly name
  91903. */
  91904. getSimpleName(): string;
  91905. }
  91906. }
  91907. declare module BABYLON {
  91908. /**
  91909. * Manage the gamepad inputs to control a free camera.
  91910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91911. */
  91912. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  91913. /**
  91914. * Define the camera the input is attached to.
  91915. */
  91916. camera: FreeCamera;
  91917. /**
  91918. * Define the Gamepad controlling the input
  91919. */
  91920. gamepad: Nullable<Gamepad>;
  91921. /**
  91922. * Defines the gamepad rotation sensiblity.
  91923. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91924. */
  91925. gamepadAngularSensibility: number;
  91926. /**
  91927. * Defines the gamepad move sensiblity.
  91928. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91929. */
  91930. gamepadMoveSensibility: number;
  91931. private _onGamepadConnectedObserver;
  91932. private _onGamepadDisconnectedObserver;
  91933. private _cameraTransform;
  91934. private _deltaTransform;
  91935. private _vector3;
  91936. private _vector2;
  91937. /**
  91938. * Attach the input controls to a specific dom element to get the input from.
  91939. * @param element Defines the element the controls should be listened from
  91940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91941. */
  91942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91943. /**
  91944. * Detach the current controls from the specified dom element.
  91945. * @param element Defines the element to stop listening the inputs from
  91946. */
  91947. detachControl(element: Nullable<HTMLElement>): void;
  91948. /**
  91949. * Update the current camera state depending on the inputs that have been used this frame.
  91950. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91951. */
  91952. checkInputs(): void;
  91953. /**
  91954. * Gets the class name of the current intput.
  91955. * @returns the class name
  91956. */
  91957. getClassName(): string;
  91958. /**
  91959. * Get the friendly name associated with the input class.
  91960. * @returns the input friendly name
  91961. */
  91962. getSimpleName(): string;
  91963. }
  91964. }
  91965. declare module BABYLON {
  91966. /**
  91967. * Defines the potential axis of a Joystick
  91968. */
  91969. export enum JoystickAxis {
  91970. /** X axis */
  91971. X = 0,
  91972. /** Y axis */
  91973. Y = 1,
  91974. /** Z axis */
  91975. Z = 2
  91976. }
  91977. /**
  91978. * Class used to define virtual joystick (used in touch mode)
  91979. */
  91980. export class VirtualJoystick {
  91981. /**
  91982. * Gets or sets a boolean indicating that left and right values must be inverted
  91983. */
  91984. reverseLeftRight: boolean;
  91985. /**
  91986. * Gets or sets a boolean indicating that up and down values must be inverted
  91987. */
  91988. reverseUpDown: boolean;
  91989. /**
  91990. * Gets the offset value for the position (ie. the change of the position value)
  91991. */
  91992. deltaPosition: Vector3;
  91993. /**
  91994. * Gets a boolean indicating if the virtual joystick was pressed
  91995. */
  91996. pressed: boolean;
  91997. /**
  91998. * Canvas the virtual joystick will render onto, default z-index of this is 5
  91999. */
  92000. static Canvas: Nullable<HTMLCanvasElement>;
  92001. private static _globalJoystickIndex;
  92002. private static vjCanvasContext;
  92003. private static vjCanvasWidth;
  92004. private static vjCanvasHeight;
  92005. private static halfWidth;
  92006. private _action;
  92007. private _axisTargetedByLeftAndRight;
  92008. private _axisTargetedByUpAndDown;
  92009. private _joystickSensibility;
  92010. private _inversedSensibility;
  92011. private _joystickPointerID;
  92012. private _joystickColor;
  92013. private _joystickPointerPos;
  92014. private _joystickPreviousPointerPos;
  92015. private _joystickPointerStartPos;
  92016. private _deltaJoystickVector;
  92017. private _leftJoystick;
  92018. private _touches;
  92019. private _onPointerDownHandlerRef;
  92020. private _onPointerMoveHandlerRef;
  92021. private _onPointerUpHandlerRef;
  92022. private _onResize;
  92023. /**
  92024. * Creates a new virtual joystick
  92025. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92026. */
  92027. constructor(leftJoystick?: boolean);
  92028. /**
  92029. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92030. * @param newJoystickSensibility defines the new sensibility
  92031. */
  92032. setJoystickSensibility(newJoystickSensibility: number): void;
  92033. private _onPointerDown;
  92034. private _onPointerMove;
  92035. private _onPointerUp;
  92036. /**
  92037. * Change the color of the virtual joystick
  92038. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92039. */
  92040. setJoystickColor(newColor: string): void;
  92041. /**
  92042. * Defines a callback to call when the joystick is touched
  92043. * @param action defines the callback
  92044. */
  92045. setActionOnTouch(action: () => any): void;
  92046. /**
  92047. * Defines which axis you'd like to control for left & right
  92048. * @param axis defines the axis to use
  92049. */
  92050. setAxisForLeftRight(axis: JoystickAxis): void;
  92051. /**
  92052. * Defines which axis you'd like to control for up & down
  92053. * @param axis defines the axis to use
  92054. */
  92055. setAxisForUpDown(axis: JoystickAxis): void;
  92056. private _drawVirtualJoystick;
  92057. /**
  92058. * Release internal HTML canvas
  92059. */
  92060. releaseCanvas(): void;
  92061. }
  92062. }
  92063. declare module BABYLON {
  92064. interface FreeCameraInputsManager {
  92065. /**
  92066. * Add virtual joystick input support to the input manager.
  92067. * @returns the current input manager
  92068. */
  92069. addVirtualJoystick(): FreeCameraInputsManager;
  92070. }
  92071. /**
  92072. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92074. */
  92075. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92076. /**
  92077. * Defines the camera the input is attached to.
  92078. */
  92079. camera: FreeCamera;
  92080. private _leftjoystick;
  92081. private _rightjoystick;
  92082. /**
  92083. * Gets the left stick of the virtual joystick.
  92084. * @returns The virtual Joystick
  92085. */
  92086. getLeftJoystick(): VirtualJoystick;
  92087. /**
  92088. * Gets the right stick of the virtual joystick.
  92089. * @returns The virtual Joystick
  92090. */
  92091. getRightJoystick(): VirtualJoystick;
  92092. /**
  92093. * Update the current camera state depending on the inputs that have been used this frame.
  92094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92095. */
  92096. checkInputs(): void;
  92097. /**
  92098. * Attach the input controls to a specific dom element to get the input from.
  92099. * @param element Defines the element the controls should be listened from
  92100. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92101. */
  92102. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92103. /**
  92104. * Detach the current controls from the specified dom element.
  92105. * @param element Defines the element to stop listening the inputs from
  92106. */
  92107. detachControl(element: Nullable<HTMLElement>): void;
  92108. /**
  92109. * Gets the class name of the current intput.
  92110. * @returns the class name
  92111. */
  92112. getClassName(): string;
  92113. /**
  92114. * Get the friendly name associated with the input class.
  92115. * @returns the input friendly name
  92116. */
  92117. getSimpleName(): string;
  92118. }
  92119. }
  92120. declare module BABYLON {
  92121. /**
  92122. * This represents a FPS type of camera controlled by touch.
  92123. * This is like a universal camera minus the Gamepad controls.
  92124. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92125. */
  92126. export class TouchCamera extends FreeCamera {
  92127. /**
  92128. * Defines the touch sensibility for rotation.
  92129. * The higher the faster.
  92130. */
  92131. touchAngularSensibility: number;
  92132. /**
  92133. * Defines the touch sensibility for move.
  92134. * The higher the faster.
  92135. */
  92136. touchMoveSensibility: number;
  92137. /**
  92138. * Instantiates a new touch camera.
  92139. * This represents a FPS type of camera controlled by touch.
  92140. * This is like a universal camera minus the Gamepad controls.
  92141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92142. * @param name Define the name of the camera in the scene
  92143. * @param position Define the start position of the camera in the scene
  92144. * @param scene Define the scene the camera belongs to
  92145. */
  92146. constructor(name: string, position: Vector3, scene: Scene);
  92147. /**
  92148. * Gets the current object class name.
  92149. * @return the class name
  92150. */
  92151. getClassName(): string;
  92152. /** @hidden */
  92153. _setupInputs(): void;
  92154. }
  92155. }
  92156. declare module BABYLON {
  92157. /**
  92158. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92159. * being tilted forward or back and left or right.
  92160. */
  92161. export class DeviceOrientationCamera extends FreeCamera {
  92162. private _initialQuaternion;
  92163. private _quaternionCache;
  92164. /**
  92165. * Creates a new device orientation camera
  92166. * @param name The name of the camera
  92167. * @param position The start position camera
  92168. * @param scene The scene the camera belongs to
  92169. */
  92170. constructor(name: string, position: Vector3, scene: Scene);
  92171. /**
  92172. * Gets the current instance class name ("DeviceOrientationCamera").
  92173. * This helps avoiding instanceof at run time.
  92174. * @returns the class name
  92175. */
  92176. getClassName(): string;
  92177. /**
  92178. * @hidden
  92179. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92180. */
  92181. _checkInputs(): void;
  92182. /**
  92183. * Reset the camera to its default orientation on the specified axis only.
  92184. * @param axis The axis to reset
  92185. */
  92186. resetToCurrentRotation(axis?: Axis): void;
  92187. }
  92188. }
  92189. declare module BABYLON {
  92190. /**
  92191. * Manage the keyboard inputs to control the movement of a follow camera.
  92192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92193. */
  92194. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92195. /**
  92196. * Defines the camera the input is attached to.
  92197. */
  92198. camera: FollowCamera;
  92199. /**
  92200. * Defines the list of key codes associated with the up action (increase heightOffset)
  92201. */
  92202. keysHeightOffsetIncr: number[];
  92203. /**
  92204. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92205. */
  92206. keysHeightOffsetDecr: number[];
  92207. /**
  92208. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92209. */
  92210. keysHeightOffsetModifierAlt: boolean;
  92211. /**
  92212. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92213. */
  92214. keysHeightOffsetModifierCtrl: boolean;
  92215. /**
  92216. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92217. */
  92218. keysHeightOffsetModifierShift: boolean;
  92219. /**
  92220. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92221. */
  92222. keysRotationOffsetIncr: number[];
  92223. /**
  92224. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92225. */
  92226. keysRotationOffsetDecr: number[];
  92227. /**
  92228. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92229. */
  92230. keysRotationOffsetModifierAlt: boolean;
  92231. /**
  92232. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92233. */
  92234. keysRotationOffsetModifierCtrl: boolean;
  92235. /**
  92236. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92237. */
  92238. keysRotationOffsetModifierShift: boolean;
  92239. /**
  92240. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92241. */
  92242. keysRadiusIncr: number[];
  92243. /**
  92244. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92245. */
  92246. keysRadiusDecr: number[];
  92247. /**
  92248. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92249. */
  92250. keysRadiusModifierAlt: boolean;
  92251. /**
  92252. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92253. */
  92254. keysRadiusModifierCtrl: boolean;
  92255. /**
  92256. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92257. */
  92258. keysRadiusModifierShift: boolean;
  92259. /**
  92260. * Defines the rate of change of heightOffset.
  92261. */
  92262. heightSensibility: number;
  92263. /**
  92264. * Defines the rate of change of rotationOffset.
  92265. */
  92266. rotationSensibility: number;
  92267. /**
  92268. * Defines the rate of change of radius.
  92269. */
  92270. radiusSensibility: number;
  92271. private _keys;
  92272. private _ctrlPressed;
  92273. private _altPressed;
  92274. private _shiftPressed;
  92275. private _onCanvasBlurObserver;
  92276. private _onKeyboardObserver;
  92277. private _engine;
  92278. private _scene;
  92279. /**
  92280. * Attach the input controls to a specific dom element to get the input from.
  92281. * @param element Defines the element the controls should be listened from
  92282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92283. */
  92284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92285. /**
  92286. * Detach the current controls from the specified dom element.
  92287. * @param element Defines the element to stop listening the inputs from
  92288. */
  92289. detachControl(element: Nullable<HTMLElement>): void;
  92290. /**
  92291. * Update the current camera state depending on the inputs that have been used this frame.
  92292. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92293. */
  92294. checkInputs(): 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 friendly name
  92303. */
  92304. getSimpleName(): string;
  92305. /**
  92306. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92307. * allow modification of the heightOffset value.
  92308. */
  92309. private _modifierHeightOffset;
  92310. /**
  92311. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92312. * allow modification of the rotationOffset value.
  92313. */
  92314. private _modifierRotationOffset;
  92315. /**
  92316. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92317. * allow modification of the radius value.
  92318. */
  92319. private _modifierRadius;
  92320. }
  92321. }
  92322. declare module BABYLON {
  92323. /**
  92324. * Manage the mouse wheel inputs to control a follow camera.
  92325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92326. */
  92327. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92328. /**
  92329. * Defines the camera the input is attached to.
  92330. */
  92331. camera: FollowCamera;
  92332. /**
  92333. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92334. */
  92335. axisControlRadius: boolean;
  92336. /**
  92337. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92338. */
  92339. axisControlHeight: boolean;
  92340. /**
  92341. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92342. */
  92343. axisControlRotation: boolean;
  92344. /**
  92345. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92346. * relation to mouseWheel events.
  92347. */
  92348. wheelPrecision: number;
  92349. /**
  92350. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92351. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92352. */
  92353. wheelDeltaPercentage: number;
  92354. private _wheel;
  92355. private _observer;
  92356. /**
  92357. * Attach the input controls to a specific dom element to get the input from.
  92358. * @param element Defines the element the controls should be listened from
  92359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92360. */
  92361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92362. /**
  92363. * Detach the current controls from the specified dom element.
  92364. * @param element Defines the element to stop listening the inputs from
  92365. */
  92366. detachControl(element: Nullable<HTMLElement>): void;
  92367. /**
  92368. * Gets the class name of the current intput.
  92369. * @returns the class name
  92370. */
  92371. getClassName(): string;
  92372. /**
  92373. * Get the friendly name associated with the input class.
  92374. * @returns the input friendly name
  92375. */
  92376. getSimpleName(): string;
  92377. }
  92378. }
  92379. declare module BABYLON {
  92380. /**
  92381. * Default Inputs manager for the FollowCamera.
  92382. * It groups all the default supported inputs for ease of use.
  92383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92384. */
  92385. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92386. /**
  92387. * Instantiates a new FollowCameraInputsManager.
  92388. * @param camera Defines the camera the inputs belong to
  92389. */
  92390. constructor(camera: FollowCamera);
  92391. /**
  92392. * Add keyboard input support to the input manager.
  92393. * @returns the current input manager
  92394. */
  92395. addKeyboard(): FollowCameraInputsManager;
  92396. /**
  92397. * Add mouse wheel input support to the input manager.
  92398. * @returns the current input manager
  92399. */
  92400. addMouseWheel(): FollowCameraInputsManager;
  92401. /**
  92402. * Add pointers input support to the input manager.
  92403. * @returns the current input manager
  92404. */
  92405. addPointers(): FollowCameraInputsManager;
  92406. /**
  92407. * Add orientation input support to the input manager.
  92408. * @returns the current input manager
  92409. */
  92410. addVRDeviceOrientation(): FollowCameraInputsManager;
  92411. }
  92412. }
  92413. declare module BABYLON {
  92414. /**
  92415. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92416. * an arc rotate version arcFollowCamera are available.
  92417. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92418. */
  92419. export class FollowCamera extends TargetCamera {
  92420. /**
  92421. * Distance the follow camera should follow an object at
  92422. */
  92423. radius: number;
  92424. /**
  92425. * Minimum allowed distance of the camera to the axis of rotation
  92426. * (The camera can not get closer).
  92427. * This can help limiting how the Camera is able to move in the scene.
  92428. */
  92429. lowerRadiusLimit: Nullable<number>;
  92430. /**
  92431. * Maximum allowed distance of the camera to the axis of rotation
  92432. * (The camera can not get further).
  92433. * This can help limiting how the Camera is able to move in the scene.
  92434. */
  92435. upperRadiusLimit: Nullable<number>;
  92436. /**
  92437. * Define a rotation offset between the camera and the object it follows
  92438. */
  92439. rotationOffset: number;
  92440. /**
  92441. * Minimum allowed angle to camera position relative to target object.
  92442. * This can help limiting how the Camera is able to move in the scene.
  92443. */
  92444. lowerRotationOffsetLimit: Nullable<number>;
  92445. /**
  92446. * Maximum allowed angle to camera position relative to target object.
  92447. * This can help limiting how the Camera is able to move in the scene.
  92448. */
  92449. upperRotationOffsetLimit: Nullable<number>;
  92450. /**
  92451. * Define a height offset between the camera and the object it follows.
  92452. * It can help following an object from the top (like a car chaing a plane)
  92453. */
  92454. heightOffset: number;
  92455. /**
  92456. * Minimum allowed height of camera position relative to target object.
  92457. * This can help limiting how the Camera is able to move in the scene.
  92458. */
  92459. lowerHeightOffsetLimit: Nullable<number>;
  92460. /**
  92461. * Maximum allowed height of camera position relative to target object.
  92462. * This can help limiting how the Camera is able to move in the scene.
  92463. */
  92464. upperHeightOffsetLimit: Nullable<number>;
  92465. /**
  92466. * Define how fast the camera can accelerate to follow it s target.
  92467. */
  92468. cameraAcceleration: number;
  92469. /**
  92470. * Define the speed limit of the camera following an object.
  92471. */
  92472. maxCameraSpeed: number;
  92473. /**
  92474. * Define the target of the camera.
  92475. */
  92476. lockedTarget: Nullable<AbstractMesh>;
  92477. /**
  92478. * Defines the input associated with the camera.
  92479. */
  92480. inputs: FollowCameraInputsManager;
  92481. /**
  92482. * Instantiates the follow camera.
  92483. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92484. * @param name Define the name of the camera in the scene
  92485. * @param position Define the position of the camera
  92486. * @param scene Define the scene the camera belong to
  92487. * @param lockedTarget Define the target of the camera
  92488. */
  92489. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92490. private _follow;
  92491. /**
  92492. * Attached controls to the current camera.
  92493. * @param element Defines the element the controls should be listened from
  92494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92495. */
  92496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92497. /**
  92498. * Detach the current controls from the camera.
  92499. * The camera will stop reacting to inputs.
  92500. * @param element Defines the element to stop listening the inputs from
  92501. */
  92502. detachControl(element: HTMLElement): void;
  92503. /** @hidden */
  92504. _checkInputs(): void;
  92505. private _checkLimits;
  92506. /**
  92507. * Gets the camera class name.
  92508. * @returns the class name
  92509. */
  92510. getClassName(): string;
  92511. }
  92512. /**
  92513. * Arc Rotate version of the follow camera.
  92514. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92515. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92516. */
  92517. export class ArcFollowCamera extends TargetCamera {
  92518. /** The longitudinal angle of the camera */
  92519. alpha: number;
  92520. /** The latitudinal angle of the camera */
  92521. beta: number;
  92522. /** The radius of the camera from its target */
  92523. radius: number;
  92524. /** Define the camera target (the messh it should follow) */
  92525. target: Nullable<AbstractMesh>;
  92526. private _cartesianCoordinates;
  92527. /**
  92528. * Instantiates a new ArcFollowCamera
  92529. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92530. * @param name Define the name of the camera
  92531. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92532. * @param beta Define the rotation angle of the camera around the elevation axis
  92533. * @param radius Define the radius of the camera from its target point
  92534. * @param target Define the target of the camera
  92535. * @param scene Define the scene the camera belongs to
  92536. */
  92537. constructor(name: string,
  92538. /** The longitudinal angle of the camera */
  92539. alpha: number,
  92540. /** The latitudinal angle of the camera */
  92541. beta: number,
  92542. /** The radius of the camera from its target */
  92543. radius: number,
  92544. /** Define the camera target (the messh it should follow) */
  92545. target: Nullable<AbstractMesh>, scene: Scene);
  92546. private _follow;
  92547. /** @hidden */
  92548. _checkInputs(): void;
  92549. /**
  92550. * Returns the class name of the object.
  92551. * It is mostly used internally for serialization purposes.
  92552. */
  92553. getClassName(): string;
  92554. }
  92555. }
  92556. declare module BABYLON {
  92557. /**
  92558. * 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,
  92559. * which still works and will still be found in many Playgrounds.
  92560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92561. */
  92562. export class UniversalCamera extends TouchCamera {
  92563. /**
  92564. * Defines the gamepad rotation sensiblity.
  92565. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92566. */
  92567. gamepadAngularSensibility: number;
  92568. /**
  92569. * Defines the gamepad move sensiblity.
  92570. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92571. */
  92572. gamepadMoveSensibility: number;
  92573. /**
  92574. * 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,
  92575. * which still works and will still be found in many Playgrounds.
  92576. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92577. * @param name Define the name of the camera in the scene
  92578. * @param position Define the start position of the camera in the scene
  92579. * @param scene Define the scene the camera belongs to
  92580. */
  92581. constructor(name: string, position: Vector3, scene: Scene);
  92582. /**
  92583. * Gets the current object class name.
  92584. * @return the class name
  92585. */
  92586. getClassName(): string;
  92587. }
  92588. }
  92589. declare module BABYLON {
  92590. /**
  92591. * This represents a FPS type of camera. This is only here for back compat purpose.
  92592. * Please use the UniversalCamera instead as both are identical.
  92593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92594. */
  92595. export class GamepadCamera extends UniversalCamera {
  92596. /**
  92597. * Instantiates a new Gamepad Camera
  92598. * This represents a FPS type of camera. This is only here for back compat purpose.
  92599. * Please use the UniversalCamera instead as both are identical.
  92600. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92601. * @param name Define the name of the camera in the scene
  92602. * @param position Define the start position of the camera in the scene
  92603. * @param scene Define the scene the camera belongs to
  92604. */
  92605. constructor(name: string, position: Vector3, scene: Scene);
  92606. /**
  92607. * Gets the current object class name.
  92608. * @return the class name
  92609. */
  92610. getClassName(): string;
  92611. }
  92612. }
  92613. declare module BABYLON {
  92614. /** @hidden */
  92615. export var passPixelShader: {
  92616. name: string;
  92617. shader: string;
  92618. };
  92619. }
  92620. declare module BABYLON {
  92621. /** @hidden */
  92622. export var passCubePixelShader: {
  92623. name: string;
  92624. shader: string;
  92625. };
  92626. }
  92627. declare module BABYLON {
  92628. /**
  92629. * PassPostProcess which produces an output the same as it's input
  92630. */
  92631. export class PassPostProcess extends PostProcess {
  92632. /**
  92633. * Creates the PassPostProcess
  92634. * @param name The name of the effect.
  92635. * @param options The required width/height ratio to downsize to before computing the render pass.
  92636. * @param camera The camera to apply the render pass to.
  92637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92638. * @param engine The engine which the post process will be applied. (default: current engine)
  92639. * @param reusable If the post process can be reused on the same frame. (default: false)
  92640. * @param textureType The type of texture to be used when performing the post processing.
  92641. * @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)
  92642. */
  92643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92644. }
  92645. /**
  92646. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  92647. */
  92648. export class PassCubePostProcess extends PostProcess {
  92649. private _face;
  92650. /**
  92651. * Gets or sets the cube face to display.
  92652. * * 0 is +X
  92653. * * 1 is -X
  92654. * * 2 is +Y
  92655. * * 3 is -Y
  92656. * * 4 is +Z
  92657. * * 5 is -Z
  92658. */
  92659. face: number;
  92660. /**
  92661. * Creates the PassCubePostProcess
  92662. * @param name The name of the effect.
  92663. * @param options The required width/height ratio to downsize to before computing the render pass.
  92664. * @param camera The camera to apply the render pass to.
  92665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92666. * @param engine The engine which the post process will be applied. (default: current engine)
  92667. * @param reusable If the post process can be reused on the same frame. (default: false)
  92668. * @param textureType The type of texture to be used when performing the post processing.
  92669. * @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)
  92670. */
  92671. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92672. }
  92673. }
  92674. declare module BABYLON {
  92675. /** @hidden */
  92676. export var anaglyphPixelShader: {
  92677. name: string;
  92678. shader: string;
  92679. };
  92680. }
  92681. declare module BABYLON {
  92682. /**
  92683. * Postprocess used to generate anaglyphic rendering
  92684. */
  92685. export class AnaglyphPostProcess extends PostProcess {
  92686. private _passedProcess;
  92687. /**
  92688. * Creates a new AnaglyphPostProcess
  92689. * @param name defines postprocess name
  92690. * @param options defines creation options or target ratio scale
  92691. * @param rigCameras defines cameras using this postprocess
  92692. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  92693. * @param engine defines hosting engine
  92694. * @param reusable defines if the postprocess will be reused multiple times per frame
  92695. */
  92696. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  92697. }
  92698. }
  92699. declare module BABYLON {
  92700. /**
  92701. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  92702. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92703. */
  92704. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  92705. /**
  92706. * Creates a new AnaglyphArcRotateCamera
  92707. * @param name defines camera name
  92708. * @param alpha defines alpha angle (in radians)
  92709. * @param beta defines beta angle (in radians)
  92710. * @param radius defines radius
  92711. * @param target defines camera target
  92712. * @param interaxialDistance defines distance between each color axis
  92713. * @param scene defines the hosting scene
  92714. */
  92715. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  92716. /**
  92717. * Gets camera class name
  92718. * @returns AnaglyphArcRotateCamera
  92719. */
  92720. getClassName(): string;
  92721. }
  92722. }
  92723. declare module BABYLON {
  92724. /**
  92725. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  92726. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92727. */
  92728. export class AnaglyphFreeCamera extends FreeCamera {
  92729. /**
  92730. * Creates a new AnaglyphFreeCamera
  92731. * @param name defines camera name
  92732. * @param position defines initial position
  92733. * @param interaxialDistance defines distance between each color axis
  92734. * @param scene defines the hosting scene
  92735. */
  92736. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92737. /**
  92738. * Gets camera class name
  92739. * @returns AnaglyphFreeCamera
  92740. */
  92741. getClassName(): string;
  92742. }
  92743. }
  92744. declare module BABYLON {
  92745. /**
  92746. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  92747. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92748. */
  92749. export class AnaglyphGamepadCamera extends GamepadCamera {
  92750. /**
  92751. * Creates a new AnaglyphGamepadCamera
  92752. * @param name defines camera name
  92753. * @param position defines initial position
  92754. * @param interaxialDistance defines distance between each color axis
  92755. * @param scene defines the hosting scene
  92756. */
  92757. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92758. /**
  92759. * Gets camera class name
  92760. * @returns AnaglyphGamepadCamera
  92761. */
  92762. getClassName(): string;
  92763. }
  92764. }
  92765. declare module BABYLON {
  92766. /**
  92767. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  92768. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92769. */
  92770. export class AnaglyphUniversalCamera extends UniversalCamera {
  92771. /**
  92772. * Creates a new AnaglyphUniversalCamera
  92773. * @param name defines camera name
  92774. * @param position defines initial position
  92775. * @param interaxialDistance defines distance between each color axis
  92776. * @param scene defines the hosting scene
  92777. */
  92778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92779. /**
  92780. * Gets camera class name
  92781. * @returns AnaglyphUniversalCamera
  92782. */
  92783. getClassName(): string;
  92784. }
  92785. }
  92786. declare module BABYLON {
  92787. /** @hidden */
  92788. export var stereoscopicInterlacePixelShader: {
  92789. name: string;
  92790. shader: string;
  92791. };
  92792. }
  92793. declare module BABYLON {
  92794. /**
  92795. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  92796. */
  92797. export class StereoscopicInterlacePostProcess extends PostProcess {
  92798. private _stepSize;
  92799. private _passedProcess;
  92800. /**
  92801. * Initializes a StereoscopicInterlacePostProcess
  92802. * @param name The name of the effect.
  92803. * @param rigCameras The rig cameras to be appled to the post process
  92804. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  92805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92806. * @param engine The engine which the post process will be applied. (default: current engine)
  92807. * @param reusable If the post process can be reused on the same frame. (default: false)
  92808. */
  92809. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  92810. }
  92811. }
  92812. declare module BABYLON {
  92813. /**
  92814. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  92815. * @see http://doc.babylonjs.com/features/cameras
  92816. */
  92817. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  92818. /**
  92819. * Creates a new StereoscopicArcRotateCamera
  92820. * @param name defines camera name
  92821. * @param alpha defines alpha angle (in radians)
  92822. * @param beta defines beta angle (in radians)
  92823. * @param radius defines radius
  92824. * @param target defines camera target
  92825. * @param interaxialDistance defines distance between each color axis
  92826. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92827. * @param scene defines the hosting scene
  92828. */
  92829. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92830. /**
  92831. * Gets camera class name
  92832. * @returns StereoscopicArcRotateCamera
  92833. */
  92834. getClassName(): string;
  92835. }
  92836. }
  92837. declare module BABYLON {
  92838. /**
  92839. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  92840. * @see http://doc.babylonjs.com/features/cameras
  92841. */
  92842. export class StereoscopicFreeCamera extends FreeCamera {
  92843. /**
  92844. * Creates a new StereoscopicFreeCamera
  92845. * @param name defines camera name
  92846. * @param position defines initial position
  92847. * @param interaxialDistance defines distance between each color axis
  92848. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92849. * @param scene defines the hosting scene
  92850. */
  92851. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92852. /**
  92853. * Gets camera class name
  92854. * @returns StereoscopicFreeCamera
  92855. */
  92856. getClassName(): string;
  92857. }
  92858. }
  92859. declare module BABYLON {
  92860. /**
  92861. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  92862. * @see http://doc.babylonjs.com/features/cameras
  92863. */
  92864. export class StereoscopicGamepadCamera extends GamepadCamera {
  92865. /**
  92866. * Creates a new StereoscopicGamepadCamera
  92867. * @param name defines camera name
  92868. * @param position defines initial position
  92869. * @param interaxialDistance defines distance between each color axis
  92870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92871. * @param scene defines the hosting scene
  92872. */
  92873. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92874. /**
  92875. * Gets camera class name
  92876. * @returns StereoscopicGamepadCamera
  92877. */
  92878. getClassName(): string;
  92879. }
  92880. }
  92881. declare module BABYLON {
  92882. /**
  92883. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  92884. * @see http://doc.babylonjs.com/features/cameras
  92885. */
  92886. export class StereoscopicUniversalCamera extends UniversalCamera {
  92887. /**
  92888. * Creates a new StereoscopicUniversalCamera
  92889. * @param name defines camera name
  92890. * @param position defines initial position
  92891. * @param interaxialDistance defines distance between each color axis
  92892. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92893. * @param scene defines the hosting scene
  92894. */
  92895. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92896. /**
  92897. * Gets camera class name
  92898. * @returns StereoscopicUniversalCamera
  92899. */
  92900. getClassName(): string;
  92901. }
  92902. }
  92903. declare module BABYLON {
  92904. /**
  92905. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92906. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92907. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92908. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92909. */
  92910. export class VirtualJoysticksCamera extends FreeCamera {
  92911. /**
  92912. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  92913. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92914. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92915. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92916. * @param name Define the name of the camera in the scene
  92917. * @param position Define the start position of the camera in the scene
  92918. * @param scene Define the scene the camera belongs to
  92919. */
  92920. constructor(name: string, position: Vector3, scene: Scene);
  92921. /**
  92922. * Gets the current object class name.
  92923. * @return the class name
  92924. */
  92925. getClassName(): string;
  92926. }
  92927. }
  92928. declare module BABYLON {
  92929. /**
  92930. * This represents all the required metrics to create a VR camera.
  92931. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  92932. */
  92933. export class VRCameraMetrics {
  92934. /**
  92935. * Define the horizontal resolution off the screen.
  92936. */
  92937. hResolution: number;
  92938. /**
  92939. * Define the vertical resolution off the screen.
  92940. */
  92941. vResolution: number;
  92942. /**
  92943. * Define the horizontal screen size.
  92944. */
  92945. hScreenSize: number;
  92946. /**
  92947. * Define the vertical screen size.
  92948. */
  92949. vScreenSize: number;
  92950. /**
  92951. * Define the vertical screen center position.
  92952. */
  92953. vScreenCenter: number;
  92954. /**
  92955. * Define the distance of the eyes to the screen.
  92956. */
  92957. eyeToScreenDistance: number;
  92958. /**
  92959. * Define the distance between both lenses
  92960. */
  92961. lensSeparationDistance: number;
  92962. /**
  92963. * Define the distance between both viewer's eyes.
  92964. */
  92965. interpupillaryDistance: number;
  92966. /**
  92967. * Define the distortion factor of the VR postprocess.
  92968. * Please, touch with care.
  92969. */
  92970. distortionK: number[];
  92971. /**
  92972. * Define the chromatic aberration correction factors for the VR post process.
  92973. */
  92974. chromaAbCorrection: number[];
  92975. /**
  92976. * Define the scale factor of the post process.
  92977. * The smaller the better but the slower.
  92978. */
  92979. postProcessScaleFactor: number;
  92980. /**
  92981. * Define an offset for the lens center.
  92982. */
  92983. lensCenterOffset: number;
  92984. /**
  92985. * Define if the current vr camera should compensate the distortion of the lense or not.
  92986. */
  92987. compensateDistortion: boolean;
  92988. /**
  92989. * Gets the rendering aspect ratio based on the provided resolutions.
  92990. */
  92991. readonly aspectRatio: number;
  92992. /**
  92993. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  92994. */
  92995. readonly aspectRatioFov: number;
  92996. /**
  92997. * @hidden
  92998. */
  92999. readonly leftHMatrix: Matrix;
  93000. /**
  93001. * @hidden
  93002. */
  93003. readonly rightHMatrix: Matrix;
  93004. /**
  93005. * @hidden
  93006. */
  93007. readonly leftPreViewMatrix: Matrix;
  93008. /**
  93009. * @hidden
  93010. */
  93011. readonly rightPreViewMatrix: Matrix;
  93012. /**
  93013. * Get the default VRMetrics based on the most generic setup.
  93014. * @returns the default vr metrics
  93015. */
  93016. static GetDefault(): VRCameraMetrics;
  93017. }
  93018. }
  93019. declare module BABYLON {
  93020. /** @hidden */
  93021. export var vrDistortionCorrectionPixelShader: {
  93022. name: string;
  93023. shader: string;
  93024. };
  93025. }
  93026. declare module BABYLON {
  93027. /**
  93028. * VRDistortionCorrectionPostProcess used for mobile VR
  93029. */
  93030. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93031. private _isRightEye;
  93032. private _distortionFactors;
  93033. private _postProcessScaleFactor;
  93034. private _lensCenterOffset;
  93035. private _scaleIn;
  93036. private _scaleFactor;
  93037. private _lensCenter;
  93038. /**
  93039. * Initializes the VRDistortionCorrectionPostProcess
  93040. * @param name The name of the effect.
  93041. * @param camera The camera to apply the render pass to.
  93042. * @param isRightEye If this is for the right eye distortion
  93043. * @param vrMetrics All the required metrics for the VR camera
  93044. */
  93045. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93046. }
  93047. }
  93048. declare module BABYLON {
  93049. /**
  93050. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93051. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93052. */
  93053. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93054. /**
  93055. * Creates a new VRDeviceOrientationArcRotateCamera
  93056. * @param name defines camera name
  93057. * @param alpha defines the camera rotation along the logitudinal axis
  93058. * @param beta defines the camera rotation along the latitudinal axis
  93059. * @param radius defines the camera distance from its target
  93060. * @param target defines the camera target
  93061. * @param scene defines the scene the camera belongs to
  93062. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93063. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93064. */
  93065. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93066. /**
  93067. * Gets camera class name
  93068. * @returns VRDeviceOrientationArcRotateCamera
  93069. */
  93070. getClassName(): string;
  93071. }
  93072. }
  93073. declare module BABYLON {
  93074. /**
  93075. * Camera used to simulate VR rendering (based on FreeCamera)
  93076. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93077. */
  93078. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93079. /**
  93080. * Creates a new VRDeviceOrientationFreeCamera
  93081. * @param name defines camera name
  93082. * @param position defines the start position of the camera
  93083. * @param scene defines the scene the camera belongs to
  93084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93086. */
  93087. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93088. /**
  93089. * Gets camera class name
  93090. * @returns VRDeviceOrientationFreeCamera
  93091. */
  93092. getClassName(): string;
  93093. }
  93094. }
  93095. declare module BABYLON {
  93096. /**
  93097. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93098. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93099. */
  93100. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93101. /**
  93102. * Creates a new VRDeviceOrientationGamepadCamera
  93103. * @param name defines camera name
  93104. * @param position defines the start position of the camera
  93105. * @param scene defines the scene the camera belongs to
  93106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93108. */
  93109. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93110. /**
  93111. * Gets camera class name
  93112. * @returns VRDeviceOrientationGamepadCamera
  93113. */
  93114. getClassName(): string;
  93115. }
  93116. }
  93117. declare module BABYLON {
  93118. /**
  93119. * Defines supported buttons for XBox360 compatible gamepads
  93120. */
  93121. export enum Xbox360Button {
  93122. /** A */
  93123. A = 0,
  93124. /** B */
  93125. B = 1,
  93126. /** X */
  93127. X = 2,
  93128. /** Y */
  93129. Y = 3,
  93130. /** Start */
  93131. Start = 4,
  93132. /** Back */
  93133. Back = 5,
  93134. /** Left button */
  93135. LB = 6,
  93136. /** Right button */
  93137. RB = 7,
  93138. /** Left stick */
  93139. LeftStick = 8,
  93140. /** Right stick */
  93141. RightStick = 9
  93142. }
  93143. /** Defines values for XBox360 DPad */
  93144. export enum Xbox360Dpad {
  93145. /** Up */
  93146. Up = 0,
  93147. /** Down */
  93148. Down = 1,
  93149. /** Left */
  93150. Left = 2,
  93151. /** Right */
  93152. Right = 3
  93153. }
  93154. /**
  93155. * Defines a XBox360 gamepad
  93156. */
  93157. export class Xbox360Pad extends Gamepad {
  93158. private _leftTrigger;
  93159. private _rightTrigger;
  93160. private _onlefttriggerchanged;
  93161. private _onrighttriggerchanged;
  93162. private _onbuttondown;
  93163. private _onbuttonup;
  93164. private _ondpaddown;
  93165. private _ondpadup;
  93166. /** Observable raised when a button is pressed */
  93167. onButtonDownObservable: Observable<Xbox360Button>;
  93168. /** Observable raised when a button is released */
  93169. onButtonUpObservable: Observable<Xbox360Button>;
  93170. /** Observable raised when a pad is pressed */
  93171. onPadDownObservable: Observable<Xbox360Dpad>;
  93172. /** Observable raised when a pad is released */
  93173. onPadUpObservable: Observable<Xbox360Dpad>;
  93174. private _buttonA;
  93175. private _buttonB;
  93176. private _buttonX;
  93177. private _buttonY;
  93178. private _buttonBack;
  93179. private _buttonStart;
  93180. private _buttonLB;
  93181. private _buttonRB;
  93182. private _buttonLeftStick;
  93183. private _buttonRightStick;
  93184. private _dPadUp;
  93185. private _dPadDown;
  93186. private _dPadLeft;
  93187. private _dPadRight;
  93188. private _isXboxOnePad;
  93189. /**
  93190. * Creates a new XBox360 gamepad object
  93191. * @param id defines the id of this gamepad
  93192. * @param index defines its index
  93193. * @param gamepad defines the internal HTML gamepad object
  93194. * @param xboxOne defines if it is a XBox One gamepad
  93195. */
  93196. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93197. /**
  93198. * Defines the callback to call when left trigger is pressed
  93199. * @param callback defines the callback to use
  93200. */
  93201. onlefttriggerchanged(callback: (value: number) => void): void;
  93202. /**
  93203. * Defines the callback to call when right trigger is pressed
  93204. * @param callback defines the callback to use
  93205. */
  93206. onrighttriggerchanged(callback: (value: number) => void): void;
  93207. /**
  93208. * Gets the left trigger value
  93209. */
  93210. /**
  93211. * Sets the left trigger value
  93212. */
  93213. leftTrigger: number;
  93214. /**
  93215. * Gets the right trigger value
  93216. */
  93217. /**
  93218. * Sets the right trigger value
  93219. */
  93220. rightTrigger: number;
  93221. /**
  93222. * Defines the callback to call when a button is pressed
  93223. * @param callback defines the callback to use
  93224. */
  93225. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93226. /**
  93227. * Defines the callback to call when a button is released
  93228. * @param callback defines the callback to use
  93229. */
  93230. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93231. /**
  93232. * Defines the callback to call when a pad is pressed
  93233. * @param callback defines the callback to use
  93234. */
  93235. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93236. /**
  93237. * Defines the callback to call when a pad is released
  93238. * @param callback defines the callback to use
  93239. */
  93240. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93241. private _setButtonValue;
  93242. private _setDPadValue;
  93243. /**
  93244. * Gets the value of the `A` button
  93245. */
  93246. /**
  93247. * Sets the value of the `A` button
  93248. */
  93249. buttonA: number;
  93250. /**
  93251. * Gets the value of the `B` button
  93252. */
  93253. /**
  93254. * Sets the value of the `B` button
  93255. */
  93256. buttonB: number;
  93257. /**
  93258. * Gets the value of the `X` button
  93259. */
  93260. /**
  93261. * Sets the value of the `X` button
  93262. */
  93263. buttonX: number;
  93264. /**
  93265. * Gets the value of the `Y` button
  93266. */
  93267. /**
  93268. * Sets the value of the `Y` button
  93269. */
  93270. buttonY: number;
  93271. /**
  93272. * Gets the value of the `Start` button
  93273. */
  93274. /**
  93275. * Sets the value of the `Start` button
  93276. */
  93277. buttonStart: number;
  93278. /**
  93279. * Gets the value of the `Back` button
  93280. */
  93281. /**
  93282. * Sets the value of the `Back` button
  93283. */
  93284. buttonBack: number;
  93285. /**
  93286. * Gets the value of the `Left` button
  93287. */
  93288. /**
  93289. * Sets the value of the `Left` button
  93290. */
  93291. buttonLB: number;
  93292. /**
  93293. * Gets the value of the `Right` button
  93294. */
  93295. /**
  93296. * Sets the value of the `Right` button
  93297. */
  93298. buttonRB: number;
  93299. /**
  93300. * Gets the value of the Left joystick
  93301. */
  93302. /**
  93303. * Sets the value of the Left joystick
  93304. */
  93305. buttonLeftStick: number;
  93306. /**
  93307. * Gets the value of the Right joystick
  93308. */
  93309. /**
  93310. * Sets the value of the Right joystick
  93311. */
  93312. buttonRightStick: number;
  93313. /**
  93314. * Gets the value of D-pad up
  93315. */
  93316. /**
  93317. * Sets the value of D-pad up
  93318. */
  93319. dPadUp: number;
  93320. /**
  93321. * Gets the value of D-pad down
  93322. */
  93323. /**
  93324. * Sets the value of D-pad down
  93325. */
  93326. dPadDown: number;
  93327. /**
  93328. * Gets the value of D-pad left
  93329. */
  93330. /**
  93331. * Sets the value of D-pad left
  93332. */
  93333. dPadLeft: number;
  93334. /**
  93335. * Gets the value of D-pad right
  93336. */
  93337. /**
  93338. * Sets the value of D-pad right
  93339. */
  93340. dPadRight: number;
  93341. /**
  93342. * Force the gamepad to synchronize with device values
  93343. */
  93344. update(): void;
  93345. /**
  93346. * Disposes the gamepad
  93347. */
  93348. dispose(): void;
  93349. }
  93350. }
  93351. declare module BABYLON {
  93352. /**
  93353. * Base class of materials working in push mode in babylon JS
  93354. * @hidden
  93355. */
  93356. export class PushMaterial extends Material {
  93357. protected _activeEffect: Effect;
  93358. protected _normalMatrix: Matrix;
  93359. /**
  93360. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93361. * This means that the material can keep using a previous shader while a new one is being compiled.
  93362. * This is mostly used when shader parallel compilation is supported (true by default)
  93363. */
  93364. allowShaderHotSwapping: boolean;
  93365. constructor(name: string, scene: Scene);
  93366. getEffect(): Effect;
  93367. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93368. /**
  93369. * Binds the given world matrix to the active effect
  93370. *
  93371. * @param world the matrix to bind
  93372. */
  93373. bindOnlyWorldMatrix(world: Matrix): void;
  93374. /**
  93375. * Binds the given normal matrix to the active effect
  93376. *
  93377. * @param normalMatrix the matrix to bind
  93378. */
  93379. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93380. bind(world: Matrix, mesh?: Mesh): void;
  93381. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93382. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93383. }
  93384. }
  93385. declare module BABYLON {
  93386. /**
  93387. * This groups all the flags used to control the materials channel.
  93388. */
  93389. export class MaterialFlags {
  93390. private static _DiffuseTextureEnabled;
  93391. /**
  93392. * Are diffuse textures enabled in the application.
  93393. */
  93394. static DiffuseTextureEnabled: boolean;
  93395. private static _AmbientTextureEnabled;
  93396. /**
  93397. * Are ambient textures enabled in the application.
  93398. */
  93399. static AmbientTextureEnabled: boolean;
  93400. private static _OpacityTextureEnabled;
  93401. /**
  93402. * Are opacity textures enabled in the application.
  93403. */
  93404. static OpacityTextureEnabled: boolean;
  93405. private static _ReflectionTextureEnabled;
  93406. /**
  93407. * Are reflection textures enabled in the application.
  93408. */
  93409. static ReflectionTextureEnabled: boolean;
  93410. private static _EmissiveTextureEnabled;
  93411. /**
  93412. * Are emissive textures enabled in the application.
  93413. */
  93414. static EmissiveTextureEnabled: boolean;
  93415. private static _SpecularTextureEnabled;
  93416. /**
  93417. * Are specular textures enabled in the application.
  93418. */
  93419. static SpecularTextureEnabled: boolean;
  93420. private static _BumpTextureEnabled;
  93421. /**
  93422. * Are bump textures enabled in the application.
  93423. */
  93424. static BumpTextureEnabled: boolean;
  93425. private static _LightmapTextureEnabled;
  93426. /**
  93427. * Are lightmap textures enabled in the application.
  93428. */
  93429. static LightmapTextureEnabled: boolean;
  93430. private static _RefractionTextureEnabled;
  93431. /**
  93432. * Are refraction textures enabled in the application.
  93433. */
  93434. static RefractionTextureEnabled: boolean;
  93435. private static _ColorGradingTextureEnabled;
  93436. /**
  93437. * Are color grading textures enabled in the application.
  93438. */
  93439. static ColorGradingTextureEnabled: boolean;
  93440. private static _FresnelEnabled;
  93441. /**
  93442. * Are fresnels enabled in the application.
  93443. */
  93444. static FresnelEnabled: boolean;
  93445. }
  93446. }
  93447. declare module BABYLON {
  93448. /** @hidden */
  93449. export var defaultFragmentDeclaration: {
  93450. name: string;
  93451. shader: string;
  93452. };
  93453. }
  93454. declare module BABYLON {
  93455. /** @hidden */
  93456. export var defaultUboDeclaration: {
  93457. name: string;
  93458. shader: string;
  93459. };
  93460. }
  93461. declare module BABYLON {
  93462. /** @hidden */
  93463. export var lightFragmentDeclaration: {
  93464. name: string;
  93465. shader: string;
  93466. };
  93467. }
  93468. declare module BABYLON {
  93469. /** @hidden */
  93470. export var lightUboDeclaration: {
  93471. name: string;
  93472. shader: string;
  93473. };
  93474. }
  93475. declare module BABYLON {
  93476. /** @hidden */
  93477. export var lightsFragmentFunctions: {
  93478. name: string;
  93479. shader: string;
  93480. };
  93481. }
  93482. declare module BABYLON {
  93483. /** @hidden */
  93484. export var shadowsFragmentFunctions: {
  93485. name: string;
  93486. shader: string;
  93487. };
  93488. }
  93489. declare module BABYLON {
  93490. /** @hidden */
  93491. export var fresnelFunction: {
  93492. name: string;
  93493. shader: string;
  93494. };
  93495. }
  93496. declare module BABYLON {
  93497. /** @hidden */
  93498. export var reflectionFunction: {
  93499. name: string;
  93500. shader: string;
  93501. };
  93502. }
  93503. declare module BABYLON {
  93504. /** @hidden */
  93505. export var bumpFragmentFunctions: {
  93506. name: string;
  93507. shader: string;
  93508. };
  93509. }
  93510. declare module BABYLON {
  93511. /** @hidden */
  93512. export var logDepthDeclaration: {
  93513. name: string;
  93514. shader: string;
  93515. };
  93516. }
  93517. declare module BABYLON {
  93518. /** @hidden */
  93519. export var bumpFragment: {
  93520. name: string;
  93521. shader: string;
  93522. };
  93523. }
  93524. declare module BABYLON {
  93525. /** @hidden */
  93526. export var depthPrePass: {
  93527. name: string;
  93528. shader: string;
  93529. };
  93530. }
  93531. declare module BABYLON {
  93532. /** @hidden */
  93533. export var lightFragment: {
  93534. name: string;
  93535. shader: string;
  93536. };
  93537. }
  93538. declare module BABYLON {
  93539. /** @hidden */
  93540. export var logDepthFragment: {
  93541. name: string;
  93542. shader: string;
  93543. };
  93544. }
  93545. declare module BABYLON {
  93546. /** @hidden */
  93547. export var defaultPixelShader: {
  93548. name: string;
  93549. shader: string;
  93550. };
  93551. }
  93552. declare module BABYLON {
  93553. /** @hidden */
  93554. export var defaultVertexDeclaration: {
  93555. name: string;
  93556. shader: string;
  93557. };
  93558. }
  93559. declare module BABYLON {
  93560. /** @hidden */
  93561. export var bumpVertexDeclaration: {
  93562. name: string;
  93563. shader: string;
  93564. };
  93565. }
  93566. declare module BABYLON {
  93567. /** @hidden */
  93568. export var bumpVertex: {
  93569. name: string;
  93570. shader: string;
  93571. };
  93572. }
  93573. declare module BABYLON {
  93574. /** @hidden */
  93575. export var fogVertex: {
  93576. name: string;
  93577. shader: string;
  93578. };
  93579. }
  93580. declare module BABYLON {
  93581. /** @hidden */
  93582. export var shadowsVertex: {
  93583. name: string;
  93584. shader: string;
  93585. };
  93586. }
  93587. declare module BABYLON {
  93588. /** @hidden */
  93589. export var pointCloudVertex: {
  93590. name: string;
  93591. shader: string;
  93592. };
  93593. }
  93594. declare module BABYLON {
  93595. /** @hidden */
  93596. export var logDepthVertex: {
  93597. name: string;
  93598. shader: string;
  93599. };
  93600. }
  93601. declare module BABYLON {
  93602. /** @hidden */
  93603. export var defaultVertexShader: {
  93604. name: string;
  93605. shader: string;
  93606. };
  93607. }
  93608. declare module BABYLON {
  93609. /** @hidden */
  93610. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93611. MAINUV1: boolean;
  93612. MAINUV2: boolean;
  93613. DIFFUSE: boolean;
  93614. DIFFUSEDIRECTUV: number;
  93615. AMBIENT: boolean;
  93616. AMBIENTDIRECTUV: number;
  93617. OPACITY: boolean;
  93618. OPACITYDIRECTUV: number;
  93619. OPACITYRGB: boolean;
  93620. REFLECTION: boolean;
  93621. EMISSIVE: boolean;
  93622. EMISSIVEDIRECTUV: number;
  93623. SPECULAR: boolean;
  93624. SPECULARDIRECTUV: number;
  93625. BUMP: boolean;
  93626. BUMPDIRECTUV: number;
  93627. PARALLAX: boolean;
  93628. PARALLAXOCCLUSION: boolean;
  93629. SPECULAROVERALPHA: boolean;
  93630. CLIPPLANE: boolean;
  93631. CLIPPLANE2: boolean;
  93632. CLIPPLANE3: boolean;
  93633. CLIPPLANE4: boolean;
  93634. ALPHATEST: boolean;
  93635. DEPTHPREPASS: boolean;
  93636. ALPHAFROMDIFFUSE: boolean;
  93637. POINTSIZE: boolean;
  93638. FOG: boolean;
  93639. SPECULARTERM: boolean;
  93640. DIFFUSEFRESNEL: boolean;
  93641. OPACITYFRESNEL: boolean;
  93642. REFLECTIONFRESNEL: boolean;
  93643. REFRACTIONFRESNEL: boolean;
  93644. EMISSIVEFRESNEL: boolean;
  93645. FRESNEL: boolean;
  93646. NORMAL: boolean;
  93647. UV1: boolean;
  93648. UV2: boolean;
  93649. VERTEXCOLOR: boolean;
  93650. VERTEXALPHA: boolean;
  93651. NUM_BONE_INFLUENCERS: number;
  93652. BonesPerMesh: number;
  93653. BONETEXTURE: boolean;
  93654. INSTANCES: boolean;
  93655. GLOSSINESS: boolean;
  93656. ROUGHNESS: boolean;
  93657. EMISSIVEASILLUMINATION: boolean;
  93658. LINKEMISSIVEWITHDIFFUSE: boolean;
  93659. REFLECTIONFRESNELFROMSPECULAR: boolean;
  93660. LIGHTMAP: boolean;
  93661. LIGHTMAPDIRECTUV: number;
  93662. OBJECTSPACE_NORMALMAP: boolean;
  93663. USELIGHTMAPASSHADOWMAP: boolean;
  93664. REFLECTIONMAP_3D: boolean;
  93665. REFLECTIONMAP_SPHERICAL: boolean;
  93666. REFLECTIONMAP_PLANAR: boolean;
  93667. REFLECTIONMAP_CUBIC: boolean;
  93668. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  93669. REFLECTIONMAP_PROJECTION: boolean;
  93670. REFLECTIONMAP_SKYBOX: boolean;
  93671. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  93672. REFLECTIONMAP_EXPLICIT: boolean;
  93673. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  93674. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  93675. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  93676. INVERTCUBICMAP: boolean;
  93677. LOGARITHMICDEPTH: boolean;
  93678. REFRACTION: boolean;
  93679. REFRACTIONMAP_3D: boolean;
  93680. REFLECTIONOVERALPHA: boolean;
  93681. TWOSIDEDLIGHTING: boolean;
  93682. SHADOWFLOAT: boolean;
  93683. MORPHTARGETS: boolean;
  93684. MORPHTARGETS_NORMAL: boolean;
  93685. MORPHTARGETS_TANGENT: boolean;
  93686. NUM_MORPH_INFLUENCERS: number;
  93687. NONUNIFORMSCALING: boolean;
  93688. PREMULTIPLYALPHA: boolean;
  93689. IMAGEPROCESSING: boolean;
  93690. VIGNETTE: boolean;
  93691. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93692. VIGNETTEBLENDMODEOPAQUE: boolean;
  93693. TONEMAPPING: boolean;
  93694. TONEMAPPING_ACES: boolean;
  93695. CONTRAST: boolean;
  93696. COLORCURVES: boolean;
  93697. COLORGRADING: boolean;
  93698. COLORGRADING3D: boolean;
  93699. SAMPLER3DGREENDEPTH: boolean;
  93700. SAMPLER3DBGRMAP: boolean;
  93701. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93702. /**
  93703. * If the reflection texture on this material is in linear color space
  93704. * @hidden
  93705. */
  93706. IS_REFLECTION_LINEAR: boolean;
  93707. /**
  93708. * If the refraction texture on this material is in linear color space
  93709. * @hidden
  93710. */
  93711. IS_REFRACTION_LINEAR: boolean;
  93712. EXPOSURE: boolean;
  93713. constructor();
  93714. setReflectionMode(modeToEnable: string): void;
  93715. }
  93716. /**
  93717. * This is the default material used in Babylon. It is the best trade off between quality
  93718. * and performances.
  93719. * @see http://doc.babylonjs.com/babylon101/materials
  93720. */
  93721. export class StandardMaterial extends PushMaterial {
  93722. private _diffuseTexture;
  93723. /**
  93724. * The basic texture of the material as viewed under a light.
  93725. */
  93726. diffuseTexture: Nullable<BaseTexture>;
  93727. private _ambientTexture;
  93728. /**
  93729. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  93730. */
  93731. ambientTexture: Nullable<BaseTexture>;
  93732. private _opacityTexture;
  93733. /**
  93734. * Define the transparency of the material from a texture.
  93735. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  93736. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  93737. */
  93738. opacityTexture: Nullable<BaseTexture>;
  93739. private _reflectionTexture;
  93740. /**
  93741. * Define the texture used to display the reflection.
  93742. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93743. */
  93744. reflectionTexture: Nullable<BaseTexture>;
  93745. private _emissiveTexture;
  93746. /**
  93747. * Define texture of the material as if self lit.
  93748. * This will be mixed in the final result even in the absence of light.
  93749. */
  93750. emissiveTexture: Nullable<BaseTexture>;
  93751. private _specularTexture;
  93752. /**
  93753. * Define how the color and intensity of the highlight given by the light in the material.
  93754. */
  93755. specularTexture: Nullable<BaseTexture>;
  93756. private _bumpTexture;
  93757. /**
  93758. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  93759. * 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.
  93760. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  93761. */
  93762. bumpTexture: Nullable<BaseTexture>;
  93763. private _lightmapTexture;
  93764. /**
  93765. * Complex lighting can be computationally expensive to compute at runtime.
  93766. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  93767. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  93768. */
  93769. lightmapTexture: Nullable<BaseTexture>;
  93770. private _refractionTexture;
  93771. /**
  93772. * Define the texture used to display the refraction.
  93773. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93774. */
  93775. refractionTexture: Nullable<BaseTexture>;
  93776. /**
  93777. * The color of the material lit by the environmental background lighting.
  93778. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  93779. */
  93780. ambientColor: Color3;
  93781. /**
  93782. * The basic color of the material as viewed under a light.
  93783. */
  93784. diffuseColor: Color3;
  93785. /**
  93786. * Define how the color and intensity of the highlight given by the light in the material.
  93787. */
  93788. specularColor: Color3;
  93789. /**
  93790. * Define the color of the material as if self lit.
  93791. * This will be mixed in the final result even in the absence of light.
  93792. */
  93793. emissiveColor: Color3;
  93794. /**
  93795. * Defines how sharp are the highlights in the material.
  93796. * The bigger the value the sharper giving a more glossy feeling to the result.
  93797. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  93798. */
  93799. specularPower: number;
  93800. private _useAlphaFromDiffuseTexture;
  93801. /**
  93802. * Does the transparency come from the diffuse texture alpha channel.
  93803. */
  93804. useAlphaFromDiffuseTexture: boolean;
  93805. private _useEmissiveAsIllumination;
  93806. /**
  93807. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  93808. */
  93809. useEmissiveAsIllumination: boolean;
  93810. private _linkEmissiveWithDiffuse;
  93811. /**
  93812. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  93813. * the emissive level when the final color is close to one.
  93814. */
  93815. linkEmissiveWithDiffuse: boolean;
  93816. private _useSpecularOverAlpha;
  93817. /**
  93818. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  93819. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  93820. */
  93821. useSpecularOverAlpha: boolean;
  93822. private _useReflectionOverAlpha;
  93823. /**
  93824. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  93825. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  93826. */
  93827. useReflectionOverAlpha: boolean;
  93828. private _disableLighting;
  93829. /**
  93830. * Does lights from the scene impacts this material.
  93831. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  93832. */
  93833. disableLighting: boolean;
  93834. private _useObjectSpaceNormalMap;
  93835. /**
  93836. * Allows using an object space normal map (instead of tangent space).
  93837. */
  93838. useObjectSpaceNormalMap: boolean;
  93839. private _useParallax;
  93840. /**
  93841. * Is parallax enabled or not.
  93842. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93843. */
  93844. useParallax: boolean;
  93845. private _useParallaxOcclusion;
  93846. /**
  93847. * Is parallax occlusion enabled or not.
  93848. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  93849. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93850. */
  93851. useParallaxOcclusion: boolean;
  93852. /**
  93853. * 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.
  93854. */
  93855. parallaxScaleBias: number;
  93856. private _roughness;
  93857. /**
  93858. * Helps to define how blurry the reflections should appears in the material.
  93859. */
  93860. roughness: number;
  93861. /**
  93862. * In case of refraction, define the value of the indice of refraction.
  93863. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93864. */
  93865. indexOfRefraction: number;
  93866. /**
  93867. * Invert the refraction texture alongside the y axis.
  93868. * It can be useful with procedural textures or probe for instance.
  93869. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93870. */
  93871. invertRefractionY: boolean;
  93872. /**
  93873. * Defines the alpha limits in alpha test mode.
  93874. */
  93875. alphaCutOff: number;
  93876. private _useLightmapAsShadowmap;
  93877. /**
  93878. * In case of light mapping, define whether the map contains light or shadow informations.
  93879. */
  93880. useLightmapAsShadowmap: boolean;
  93881. private _diffuseFresnelParameters;
  93882. /**
  93883. * Define the diffuse fresnel parameters of the material.
  93884. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93885. */
  93886. diffuseFresnelParameters: FresnelParameters;
  93887. private _opacityFresnelParameters;
  93888. /**
  93889. * Define the opacity fresnel parameters of the material.
  93890. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93891. */
  93892. opacityFresnelParameters: FresnelParameters;
  93893. private _reflectionFresnelParameters;
  93894. /**
  93895. * Define the reflection fresnel parameters of the material.
  93896. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93897. */
  93898. reflectionFresnelParameters: FresnelParameters;
  93899. private _refractionFresnelParameters;
  93900. /**
  93901. * Define the refraction fresnel parameters of the material.
  93902. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93903. */
  93904. refractionFresnelParameters: FresnelParameters;
  93905. private _emissiveFresnelParameters;
  93906. /**
  93907. * Define the emissive fresnel parameters of the material.
  93908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93909. */
  93910. emissiveFresnelParameters: FresnelParameters;
  93911. private _useReflectionFresnelFromSpecular;
  93912. /**
  93913. * If true automatically deducts the fresnels values from the material specularity.
  93914. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93915. */
  93916. useReflectionFresnelFromSpecular: boolean;
  93917. private _useGlossinessFromSpecularMapAlpha;
  93918. /**
  93919. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  93920. */
  93921. useGlossinessFromSpecularMapAlpha: boolean;
  93922. private _maxSimultaneousLights;
  93923. /**
  93924. * Defines the maximum number of lights that can be used in the material
  93925. */
  93926. maxSimultaneousLights: number;
  93927. private _invertNormalMapX;
  93928. /**
  93929. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  93930. */
  93931. invertNormalMapX: boolean;
  93932. private _invertNormalMapY;
  93933. /**
  93934. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  93935. */
  93936. invertNormalMapY: boolean;
  93937. private _twoSidedLighting;
  93938. /**
  93939. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  93940. */
  93941. twoSidedLighting: boolean;
  93942. /**
  93943. * Default configuration related to image processing available in the standard Material.
  93944. */
  93945. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  93946. /**
  93947. * Gets the image processing configuration used either in this material.
  93948. */
  93949. /**
  93950. * Sets the Default image processing configuration used either in the this material.
  93951. *
  93952. * If sets to null, the scene one is in use.
  93953. */
  93954. imageProcessingConfiguration: ImageProcessingConfiguration;
  93955. /**
  93956. * Keep track of the image processing observer to allow dispose and replace.
  93957. */
  93958. private _imageProcessingObserver;
  93959. /**
  93960. * Attaches a new image processing configuration to the Standard Material.
  93961. * @param configuration
  93962. */
  93963. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93964. /**
  93965. * Gets wether the color curves effect is enabled.
  93966. */
  93967. /**
  93968. * Sets wether the color curves effect is enabled.
  93969. */
  93970. cameraColorCurvesEnabled: boolean;
  93971. /**
  93972. * Gets wether the color grading effect is enabled.
  93973. */
  93974. /**
  93975. * Gets wether the color grading effect is enabled.
  93976. */
  93977. cameraColorGradingEnabled: boolean;
  93978. /**
  93979. * Gets wether tonemapping is enabled or not.
  93980. */
  93981. /**
  93982. * Sets wether tonemapping is enabled or not
  93983. */
  93984. cameraToneMappingEnabled: boolean;
  93985. /**
  93986. * The camera exposure used on this material.
  93987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  93988. * This corresponds to a photographic exposure.
  93989. */
  93990. /**
  93991. * The camera exposure used on this material.
  93992. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  93993. * This corresponds to a photographic exposure.
  93994. */
  93995. cameraExposure: number;
  93996. /**
  93997. * Gets The camera contrast used on this material.
  93998. */
  93999. /**
  94000. * Sets The camera contrast used on this material.
  94001. */
  94002. cameraContrast: number;
  94003. /**
  94004. * Gets the Color Grading 2D Lookup Texture.
  94005. */
  94006. /**
  94007. * Sets the Color Grading 2D Lookup Texture.
  94008. */
  94009. cameraColorGradingTexture: Nullable<BaseTexture>;
  94010. /**
  94011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94013. * 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;
  94014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94015. */
  94016. /**
  94017. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94018. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94019. * 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;
  94020. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94021. */
  94022. cameraColorCurves: Nullable<ColorCurves>;
  94023. /**
  94024. * Custom callback helping to override the default shader used in the material.
  94025. */
  94026. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94027. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94028. protected _worldViewProjectionMatrix: Matrix;
  94029. protected _globalAmbientColor: Color3;
  94030. protected _useLogarithmicDepth: boolean;
  94031. /**
  94032. * Instantiates a new standard material.
  94033. * This is the default material used in Babylon. It is the best trade off between quality
  94034. * and performances.
  94035. * @see http://doc.babylonjs.com/babylon101/materials
  94036. * @param name Define the name of the material in the scene
  94037. * @param scene Define the scene the material belong to
  94038. */
  94039. constructor(name: string, scene: Scene);
  94040. /**
  94041. * Gets a boolean indicating that current material needs to register RTT
  94042. */
  94043. readonly hasRenderTargetTextures: boolean;
  94044. /**
  94045. * Gets the current class name of the material e.g. "StandardMaterial"
  94046. * Mainly use in serialization.
  94047. * @returns the class name
  94048. */
  94049. getClassName(): string;
  94050. /**
  94051. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94052. * You can try switching to logarithmic depth.
  94053. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94054. */
  94055. useLogarithmicDepth: boolean;
  94056. /**
  94057. * Specifies if the material will require alpha blending
  94058. * @returns a boolean specifying if alpha blending is needed
  94059. */
  94060. needAlphaBlending(): boolean;
  94061. /**
  94062. * Specifies if this material should be rendered in alpha test mode
  94063. * @returns a boolean specifying if an alpha test is needed.
  94064. */
  94065. needAlphaTesting(): boolean;
  94066. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94067. /**
  94068. * Get the texture used for alpha test purpose.
  94069. * @returns the diffuse texture in case of the standard material.
  94070. */
  94071. getAlphaTestTexture(): Nullable<BaseTexture>;
  94072. /**
  94073. * Get if the submesh is ready to be used and all its information available.
  94074. * Child classes can use it to update shaders
  94075. * @param mesh defines the mesh to check
  94076. * @param subMesh defines which submesh to check
  94077. * @param useInstances specifies that instances should be used
  94078. * @returns a boolean indicating that the submesh is ready or not
  94079. */
  94080. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94081. /**
  94082. * Builds the material UBO layouts.
  94083. * Used internally during the effect preparation.
  94084. */
  94085. buildUniformLayout(): void;
  94086. /**
  94087. * Unbinds the material from the mesh
  94088. */
  94089. unbind(): void;
  94090. /**
  94091. * Binds the submesh to this material by preparing the effect and shader to draw
  94092. * @param world defines the world transformation matrix
  94093. * @param mesh defines the mesh containing the submesh
  94094. * @param subMesh defines the submesh to bind the material to
  94095. */
  94096. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94097. /**
  94098. * Get the list of animatables in the material.
  94099. * @returns the list of animatables object used in the material
  94100. */
  94101. getAnimatables(): IAnimatable[];
  94102. /**
  94103. * Gets the active textures from the material
  94104. * @returns an array of textures
  94105. */
  94106. getActiveTextures(): BaseTexture[];
  94107. /**
  94108. * Specifies if the material uses a texture
  94109. * @param texture defines the texture to check against the material
  94110. * @returns a boolean specifying if the material uses the texture
  94111. */
  94112. hasTexture(texture: BaseTexture): boolean;
  94113. /**
  94114. * Disposes the material
  94115. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94116. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94117. */
  94118. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94119. /**
  94120. * Makes a duplicate of the material, and gives it a new name
  94121. * @param name defines the new name for the duplicated material
  94122. * @returns the cloned material
  94123. */
  94124. clone(name: string): StandardMaterial;
  94125. /**
  94126. * Serializes this material in a JSON representation
  94127. * @returns the serialized material object
  94128. */
  94129. serialize(): any;
  94130. /**
  94131. * Creates a standard material from parsed material data
  94132. * @param source defines the JSON representation of the material
  94133. * @param scene defines the hosting scene
  94134. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94135. * @returns a new standard material
  94136. */
  94137. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94138. /**
  94139. * Are diffuse textures enabled in the application.
  94140. */
  94141. static DiffuseTextureEnabled: boolean;
  94142. /**
  94143. * Are ambient textures enabled in the application.
  94144. */
  94145. static AmbientTextureEnabled: boolean;
  94146. /**
  94147. * Are opacity textures enabled in the application.
  94148. */
  94149. static OpacityTextureEnabled: boolean;
  94150. /**
  94151. * Are reflection textures enabled in the application.
  94152. */
  94153. static ReflectionTextureEnabled: boolean;
  94154. /**
  94155. * Are emissive textures enabled in the application.
  94156. */
  94157. static EmissiveTextureEnabled: boolean;
  94158. /**
  94159. * Are specular textures enabled in the application.
  94160. */
  94161. static SpecularTextureEnabled: boolean;
  94162. /**
  94163. * Are bump textures enabled in the application.
  94164. */
  94165. static BumpTextureEnabled: boolean;
  94166. /**
  94167. * Are lightmap textures enabled in the application.
  94168. */
  94169. static LightmapTextureEnabled: boolean;
  94170. /**
  94171. * Are refraction textures enabled in the application.
  94172. */
  94173. static RefractionTextureEnabled: boolean;
  94174. /**
  94175. * Are color grading textures enabled in the application.
  94176. */
  94177. static ColorGradingTextureEnabled: boolean;
  94178. /**
  94179. * Are fresnels enabled in the application.
  94180. */
  94181. static FresnelEnabled: boolean;
  94182. }
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * A class extending Texture allowing drawing on a texture
  94187. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94188. */
  94189. export class DynamicTexture extends Texture {
  94190. private _generateMipMaps;
  94191. private _canvas;
  94192. private _context;
  94193. private _engine;
  94194. /**
  94195. * Creates a DynamicTexture
  94196. * @param name defines the name of the texture
  94197. * @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
  94198. * @param scene defines the scene where you want the texture
  94199. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94200. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94201. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94202. */
  94203. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94204. /**
  94205. * Get the current class name of the texture useful for serialization or dynamic coding.
  94206. * @returns "DynamicTexture"
  94207. */
  94208. getClassName(): string;
  94209. /**
  94210. * Gets the current state of canRescale
  94211. */
  94212. readonly canRescale: boolean;
  94213. private _recreate;
  94214. /**
  94215. * Scales the texture
  94216. * @param ratio the scale factor to apply to both width and height
  94217. */
  94218. scale(ratio: number): void;
  94219. /**
  94220. * Resizes the texture
  94221. * @param width the new width
  94222. * @param height the new height
  94223. */
  94224. scaleTo(width: number, height: number): void;
  94225. /**
  94226. * Gets the context of the canvas used by the texture
  94227. * @returns the canvas context of the dynamic texture
  94228. */
  94229. getContext(): CanvasRenderingContext2D;
  94230. /**
  94231. * Clears the texture
  94232. */
  94233. clear(): void;
  94234. /**
  94235. * Updates the texture
  94236. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94237. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94238. */
  94239. update(invertY?: boolean, premulAlpha?: boolean): void;
  94240. /**
  94241. * Draws text onto the texture
  94242. * @param text defines the text to be drawn
  94243. * @param x defines the placement of the text from the left
  94244. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94245. * @param font defines the font to be used with font-style, font-size, font-name
  94246. * @param color defines the color used for the text
  94247. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94248. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94249. * @param update defines whether texture is immediately update (default is true)
  94250. */
  94251. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94252. /**
  94253. * Clones the texture
  94254. * @returns the clone of the texture.
  94255. */
  94256. clone(): DynamicTexture;
  94257. /**
  94258. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94259. * @returns a serialized dynamic texture object
  94260. */
  94261. serialize(): any;
  94262. /** @hidden */
  94263. _rebuild(): void;
  94264. }
  94265. }
  94266. declare module BABYLON {
  94267. /** @hidden */
  94268. export var imageProcessingPixelShader: {
  94269. name: string;
  94270. shader: string;
  94271. };
  94272. }
  94273. declare module BABYLON {
  94274. /**
  94275. * ImageProcessingPostProcess
  94276. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94277. */
  94278. export class ImageProcessingPostProcess extends PostProcess {
  94279. /**
  94280. * Default configuration related to image processing available in the PBR Material.
  94281. */
  94282. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94283. /**
  94284. * Gets the image processing configuration used either in this material.
  94285. */
  94286. /**
  94287. * Sets the Default image processing configuration used either in the this material.
  94288. *
  94289. * If sets to null, the scene one is in use.
  94290. */
  94291. imageProcessingConfiguration: ImageProcessingConfiguration;
  94292. /**
  94293. * Keep track of the image processing observer to allow dispose and replace.
  94294. */
  94295. private _imageProcessingObserver;
  94296. /**
  94297. * Attaches a new image processing configuration to the PBR Material.
  94298. * @param configuration
  94299. */
  94300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94301. /**
  94302. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94303. */
  94304. /**
  94305. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94306. */
  94307. colorCurves: Nullable<ColorCurves>;
  94308. /**
  94309. * Gets wether the color curves effect is enabled.
  94310. */
  94311. /**
  94312. * Sets wether the color curves effect is enabled.
  94313. */
  94314. colorCurvesEnabled: boolean;
  94315. /**
  94316. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94317. */
  94318. /**
  94319. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94320. */
  94321. colorGradingTexture: Nullable<BaseTexture>;
  94322. /**
  94323. * Gets wether the color grading effect is enabled.
  94324. */
  94325. /**
  94326. * Gets wether the color grading effect is enabled.
  94327. */
  94328. colorGradingEnabled: boolean;
  94329. /**
  94330. * Gets exposure used in the effect.
  94331. */
  94332. /**
  94333. * Sets exposure used in the effect.
  94334. */
  94335. exposure: number;
  94336. /**
  94337. * Gets wether tonemapping is enabled or not.
  94338. */
  94339. /**
  94340. * Sets wether tonemapping is enabled or not
  94341. */
  94342. toneMappingEnabled: boolean;
  94343. /**
  94344. * Gets contrast used in the effect.
  94345. */
  94346. /**
  94347. * Sets contrast used in the effect.
  94348. */
  94349. contrast: number;
  94350. /**
  94351. * Gets Vignette stretch size.
  94352. */
  94353. /**
  94354. * Sets Vignette stretch size.
  94355. */
  94356. vignetteStretch: number;
  94357. /**
  94358. * Gets Vignette centre X Offset.
  94359. */
  94360. /**
  94361. * Sets Vignette centre X Offset.
  94362. */
  94363. vignetteCentreX: number;
  94364. /**
  94365. * Gets Vignette centre Y Offset.
  94366. */
  94367. /**
  94368. * Sets Vignette centre Y Offset.
  94369. */
  94370. vignetteCentreY: number;
  94371. /**
  94372. * Gets Vignette weight or intensity of the vignette effect.
  94373. */
  94374. /**
  94375. * Sets Vignette weight or intensity of the vignette effect.
  94376. */
  94377. vignetteWeight: number;
  94378. /**
  94379. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94380. * if vignetteEnabled is set to true.
  94381. */
  94382. /**
  94383. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94384. * if vignetteEnabled is set to true.
  94385. */
  94386. vignetteColor: Color4;
  94387. /**
  94388. * Gets Camera field of view used by the Vignette effect.
  94389. */
  94390. /**
  94391. * Sets Camera field of view used by the Vignette effect.
  94392. */
  94393. vignetteCameraFov: number;
  94394. /**
  94395. * Gets the vignette blend mode allowing different kind of effect.
  94396. */
  94397. /**
  94398. * Sets the vignette blend mode allowing different kind of effect.
  94399. */
  94400. vignetteBlendMode: number;
  94401. /**
  94402. * Gets wether the vignette effect is enabled.
  94403. */
  94404. /**
  94405. * Sets wether the vignette effect is enabled.
  94406. */
  94407. vignetteEnabled: boolean;
  94408. private _fromLinearSpace;
  94409. /**
  94410. * Gets wether the input of the processing is in Gamma or Linear Space.
  94411. */
  94412. /**
  94413. * Sets wether the input of the processing is in Gamma or Linear Space.
  94414. */
  94415. fromLinearSpace: boolean;
  94416. /**
  94417. * Defines cache preventing GC.
  94418. */
  94419. private _defines;
  94420. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94421. /**
  94422. * "ImageProcessingPostProcess"
  94423. * @returns "ImageProcessingPostProcess"
  94424. */
  94425. getClassName(): string;
  94426. protected _updateParameters(): void;
  94427. dispose(camera?: Camera): void;
  94428. }
  94429. }
  94430. declare module BABYLON {
  94431. /**
  94432. * Class containing static functions to help procedurally build meshes
  94433. */
  94434. export class GroundBuilder {
  94435. /**
  94436. * Creates a ground mesh
  94437. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94438. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94440. * @param name defines the name of the mesh
  94441. * @param options defines the options used to create the mesh
  94442. * @param scene defines the hosting scene
  94443. * @returns the ground mesh
  94444. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94445. */
  94446. static CreateGround(name: string, options: {
  94447. width?: number;
  94448. height?: number;
  94449. subdivisions?: number;
  94450. subdivisionsX?: number;
  94451. subdivisionsY?: number;
  94452. updatable?: boolean;
  94453. }, scene: any): Mesh;
  94454. /**
  94455. * Creates a tiled ground mesh
  94456. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94457. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94458. * * 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
  94459. * * 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
  94460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94461. * @param name defines the name of the mesh
  94462. * @param options defines the options used to create the mesh
  94463. * @param scene defines the hosting scene
  94464. * @returns the tiled ground mesh
  94465. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94466. */
  94467. static CreateTiledGround(name: string, options: {
  94468. xmin: number;
  94469. zmin: number;
  94470. xmax: number;
  94471. zmax: number;
  94472. subdivisions?: {
  94473. w: number;
  94474. h: number;
  94475. };
  94476. precision?: {
  94477. w: number;
  94478. h: number;
  94479. };
  94480. updatable?: boolean;
  94481. }, scene: Scene): Mesh;
  94482. /**
  94483. * Creates a ground mesh from a height map
  94484. * * The parameter `url` sets the URL of the height map image resource.
  94485. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94486. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94487. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94488. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94489. * * 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.
  94490. * * 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).
  94491. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94493. * @param name defines the name of the mesh
  94494. * @param url defines the url to the height map
  94495. * @param options defines the options used to create the mesh
  94496. * @param scene defines the hosting scene
  94497. * @returns the ground mesh
  94498. * @see https://doc.babylonjs.com/babylon101/height_map
  94499. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94500. */
  94501. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94502. width?: number;
  94503. height?: number;
  94504. subdivisions?: number;
  94505. minHeight?: number;
  94506. maxHeight?: number;
  94507. colorFilter?: Color3;
  94508. alphaFilter?: number;
  94509. updatable?: boolean;
  94510. onReady?: (mesh: GroundMesh) => void;
  94511. }, scene: Scene): GroundMesh;
  94512. }
  94513. }
  94514. declare module BABYLON {
  94515. /**
  94516. * Class containing static functions to help procedurally build meshes
  94517. */
  94518. export class TorusBuilder {
  94519. /**
  94520. * Creates a torus mesh
  94521. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94522. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94523. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94527. * @param name defines the name of the mesh
  94528. * @param options defines the options used to create the mesh
  94529. * @param scene defines the hosting scene
  94530. * @returns the torus mesh
  94531. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94532. */
  94533. static CreateTorus(name: string, options: {
  94534. diameter?: number;
  94535. thickness?: number;
  94536. tessellation?: number;
  94537. updatable?: boolean;
  94538. sideOrientation?: number;
  94539. frontUVs?: Vector4;
  94540. backUVs?: Vector4;
  94541. }, scene: any): Mesh;
  94542. }
  94543. }
  94544. declare module BABYLON {
  94545. /**
  94546. * Class containing static functions to help procedurally build meshes
  94547. */
  94548. export class CylinderBuilder {
  94549. /**
  94550. * Creates a cylinder or a cone mesh
  94551. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94552. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94553. * * 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.
  94554. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94555. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94556. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94557. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94558. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94559. * * 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).
  94560. * * 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
  94561. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94562. * * 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
  94563. * * 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.
  94564. * * If `enclose` is false, a ring surface is one element.
  94565. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94566. * * 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
  94567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94570. * @param name defines the name of the mesh
  94571. * @param options defines the options used to create the mesh
  94572. * @param scene defines the hosting scene
  94573. * @returns the cylinder mesh
  94574. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94575. */
  94576. static CreateCylinder(name: string, options: {
  94577. height?: number;
  94578. diameterTop?: number;
  94579. diameterBottom?: number;
  94580. diameter?: number;
  94581. tessellation?: number;
  94582. subdivisions?: number;
  94583. arc?: number;
  94584. faceColors?: Color4[];
  94585. faceUV?: Vector4[];
  94586. updatable?: boolean;
  94587. hasRings?: boolean;
  94588. enclose?: boolean;
  94589. sideOrientation?: number;
  94590. frontUVs?: Vector4;
  94591. backUVs?: Vector4;
  94592. }, scene: any): Mesh;
  94593. }
  94594. }
  94595. declare module BABYLON {
  94596. /**
  94597. * Options to modify the vr teleportation behavior.
  94598. */
  94599. export interface VRTeleportationOptions {
  94600. /**
  94601. * The name of the mesh which should be used as the teleportation floor. (default: null)
  94602. */
  94603. floorMeshName?: string;
  94604. /**
  94605. * A list of meshes to be used as the teleportation floor. (default: empty)
  94606. */
  94607. floorMeshes?: Mesh[];
  94608. }
  94609. /**
  94610. * Options to modify the vr experience helper's behavior.
  94611. */
  94612. export interface VRExperienceHelperOptions extends WebVROptions {
  94613. /**
  94614. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  94615. */
  94616. createDeviceOrientationCamera?: boolean;
  94617. /**
  94618. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  94619. */
  94620. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  94621. /**
  94622. * Uses the main button on the controller to toggle the laser casted. (default: true)
  94623. */
  94624. laserToggle?: boolean;
  94625. /**
  94626. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  94627. */
  94628. floorMeshes?: Mesh[];
  94629. }
  94630. /**
  94631. * Helps to quickly add VR support to an existing scene.
  94632. * See http://doc.babylonjs.com/how_to/webvr_helper
  94633. */
  94634. export class VRExperienceHelper {
  94635. /** Options to modify the vr experience helper's behavior. */
  94636. webVROptions: VRExperienceHelperOptions;
  94637. private _scene;
  94638. private _position;
  94639. private _btnVR;
  94640. private _btnVRDisplayed;
  94641. private _webVRsupported;
  94642. private _webVRready;
  94643. private _webVRrequesting;
  94644. private _webVRpresenting;
  94645. private _hasEnteredVR;
  94646. private _fullscreenVRpresenting;
  94647. private _canvas;
  94648. private _webVRCamera;
  94649. private _vrDeviceOrientationCamera;
  94650. private _deviceOrientationCamera;
  94651. private _existingCamera;
  94652. private _onKeyDown;
  94653. private _onVrDisplayPresentChange;
  94654. private _onVRDisplayChanged;
  94655. private _onVRRequestPresentStart;
  94656. private _onVRRequestPresentComplete;
  94657. /**
  94658. * Observable raised when entering VR.
  94659. */
  94660. onEnteringVRObservable: Observable<VRExperienceHelper>;
  94661. /**
  94662. * Observable raised when exiting VR.
  94663. */
  94664. onExitingVRObservable: Observable<VRExperienceHelper>;
  94665. /**
  94666. * Observable raised when controller mesh is loaded.
  94667. */
  94668. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94669. /** Return this.onEnteringVRObservable
  94670. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  94671. */
  94672. readonly onEnteringVR: Observable<VRExperienceHelper>;
  94673. /** Return this.onExitingVRObservable
  94674. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  94675. */
  94676. readonly onExitingVR: Observable<VRExperienceHelper>;
  94677. /** Return this.onControllerMeshLoadedObservable
  94678. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  94679. */
  94680. readonly onControllerMeshLoaded: Observable<WebVRController>;
  94681. private _rayLength;
  94682. private _useCustomVRButton;
  94683. private _teleportationRequested;
  94684. private _teleportActive;
  94685. private _floorMeshName;
  94686. private _floorMeshesCollection;
  94687. private _rotationAllowed;
  94688. private _teleportBackwardsVector;
  94689. private _teleportationTarget;
  94690. private _isDefaultTeleportationTarget;
  94691. private _postProcessMove;
  94692. private _teleportationFillColor;
  94693. private _teleportationBorderColor;
  94694. private _rotationAngle;
  94695. private _haloCenter;
  94696. private _cameraGazer;
  94697. private _padSensibilityUp;
  94698. private _padSensibilityDown;
  94699. private _leftController;
  94700. private _rightController;
  94701. /**
  94702. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  94703. */
  94704. onNewMeshSelected: Observable<AbstractMesh>;
  94705. /**
  94706. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  94707. */
  94708. onNewMeshPicked: Observable<PickingInfo>;
  94709. private _circleEase;
  94710. /**
  94711. * Observable raised before camera teleportation
  94712. */
  94713. onBeforeCameraTeleport: Observable<Vector3>;
  94714. /**
  94715. * Observable raised after camera teleportation
  94716. */
  94717. onAfterCameraTeleport: Observable<Vector3>;
  94718. /**
  94719. * Observable raised when current selected mesh gets unselected
  94720. */
  94721. onSelectedMeshUnselected: Observable<AbstractMesh>;
  94722. private _raySelectionPredicate;
  94723. /**
  94724. * To be optionaly changed by user to define custom ray selection
  94725. */
  94726. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  94727. /**
  94728. * To be optionaly changed by user to define custom selection logic (after ray selection)
  94729. */
  94730. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  94731. /**
  94732. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  94733. */
  94734. teleportationEnabled: boolean;
  94735. private _defaultHeight;
  94736. private _teleportationInitialized;
  94737. private _interactionsEnabled;
  94738. private _interactionsRequested;
  94739. private _displayGaze;
  94740. private _displayLaserPointer;
  94741. /**
  94742. * The mesh used to display where the user is going to teleport.
  94743. */
  94744. /**
  94745. * Sets the mesh to be used to display where the user is going to teleport.
  94746. */
  94747. teleportationTarget: Mesh;
  94748. /**
  94749. * 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
  94750. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  94751. * See http://doc.babylonjs.com/resources/baking_transformations
  94752. */
  94753. gazeTrackerMesh: Mesh;
  94754. /**
  94755. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  94756. */
  94757. updateGazeTrackerScale: boolean;
  94758. /**
  94759. * If the gaze trackers color should be updated when selecting meshes
  94760. */
  94761. updateGazeTrackerColor: boolean;
  94762. /**
  94763. * The gaze tracking mesh corresponding to the left controller
  94764. */
  94765. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  94766. /**
  94767. * The gaze tracking mesh corresponding to the right controller
  94768. */
  94769. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  94770. /**
  94771. * If the ray of the gaze should be displayed.
  94772. */
  94773. /**
  94774. * Sets if the ray of the gaze should be displayed.
  94775. */
  94776. displayGaze: boolean;
  94777. /**
  94778. * If the ray of the LaserPointer should be displayed.
  94779. */
  94780. /**
  94781. * Sets if the ray of the LaserPointer should be displayed.
  94782. */
  94783. displayLaserPointer: boolean;
  94784. /**
  94785. * The deviceOrientationCamera used as the camera when not in VR.
  94786. */
  94787. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  94788. /**
  94789. * Based on the current WebVR support, returns the current VR camera used.
  94790. */
  94791. readonly currentVRCamera: Nullable<Camera>;
  94792. /**
  94793. * The webVRCamera which is used when in VR.
  94794. */
  94795. readonly webVRCamera: WebVRFreeCamera;
  94796. /**
  94797. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  94798. */
  94799. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  94800. private readonly _teleportationRequestInitiated;
  94801. /**
  94802. * Instantiates a VRExperienceHelper.
  94803. * Helps to quickly add VR support to an existing scene.
  94804. * @param scene The scene the VRExperienceHelper belongs to.
  94805. * @param webVROptions Options to modify the vr experience helper's behavior.
  94806. */
  94807. constructor(scene: Scene,
  94808. /** Options to modify the vr experience helper's behavior. */
  94809. webVROptions?: VRExperienceHelperOptions);
  94810. private _onDefaultMeshLoaded;
  94811. private _onResize;
  94812. private _onFullscreenChange;
  94813. /**
  94814. * Gets a value indicating if we are currently in VR mode.
  94815. */
  94816. readonly isInVRMode: boolean;
  94817. private onVrDisplayPresentChange;
  94818. private onVRDisplayChanged;
  94819. private moveButtonToBottomRight;
  94820. private displayVRButton;
  94821. private updateButtonVisibility;
  94822. private _cachedAngularSensibility;
  94823. /**
  94824. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  94825. * Otherwise, will use the fullscreen API.
  94826. */
  94827. enterVR(): void;
  94828. /**
  94829. * Attempt to exit VR, or fullscreen.
  94830. */
  94831. exitVR(): void;
  94832. /**
  94833. * The position of the vr experience helper.
  94834. */
  94835. /**
  94836. * Sets the position of the vr experience helper.
  94837. */
  94838. position: Vector3;
  94839. /**
  94840. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  94841. */
  94842. enableInteractions(): void;
  94843. private readonly _noControllerIsActive;
  94844. private beforeRender;
  94845. private _isTeleportationFloor;
  94846. /**
  94847. * Adds a floor mesh to be used for teleportation.
  94848. * @param floorMesh the mesh to be used for teleportation.
  94849. */
  94850. addFloorMesh(floorMesh: Mesh): void;
  94851. /**
  94852. * Removes a floor mesh from being used for teleportation.
  94853. * @param floorMesh the mesh to be removed.
  94854. */
  94855. removeFloorMesh(floorMesh: Mesh): void;
  94856. /**
  94857. * Enables interactions and teleportation using the VR controllers and gaze.
  94858. * @param vrTeleportationOptions options to modify teleportation behavior.
  94859. */
  94860. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  94861. private _onNewGamepadConnected;
  94862. private _tryEnableInteractionOnController;
  94863. private _onNewGamepadDisconnected;
  94864. private _enableInteractionOnController;
  94865. private _checkTeleportWithRay;
  94866. private _checkRotate;
  94867. private _checkTeleportBackwards;
  94868. private _enableTeleportationOnController;
  94869. private _createTeleportationCircles;
  94870. private _displayTeleportationTarget;
  94871. private _hideTeleportationTarget;
  94872. private _rotateCamera;
  94873. private _moveTeleportationSelectorTo;
  94874. private _workingVector;
  94875. private _workingQuaternion;
  94876. private _workingMatrix;
  94877. /**
  94878. * Teleports the users feet to the desired location
  94879. * @param location The location where the user's feet should be placed
  94880. */
  94881. teleportCamera(location: Vector3): void;
  94882. private _convertNormalToDirectionOfRay;
  94883. private _castRayAndSelectObject;
  94884. private _notifySelectedMeshUnselected;
  94885. /**
  94886. * Sets the color of the laser ray from the vr controllers.
  94887. * @param color new color for the ray.
  94888. */
  94889. changeLaserColor(color: Color3): void;
  94890. /**
  94891. * Sets the color of the ray from the vr headsets gaze.
  94892. * @param color new color for the ray.
  94893. */
  94894. changeGazeColor(color: Color3): void;
  94895. /**
  94896. * Exits VR and disposes of the vr experience helper
  94897. */
  94898. dispose(): void;
  94899. /**
  94900. * Gets the name of the VRExperienceHelper class
  94901. * @returns "VRExperienceHelper"
  94902. */
  94903. getClassName(): string;
  94904. }
  94905. }
  94906. declare module BABYLON {
  94907. /**
  94908. * Manages an XRSession
  94909. * @see https://doc.babylonjs.com/how_to/webxr
  94910. */
  94911. export class WebXRSessionManager implements IDisposable {
  94912. private scene;
  94913. /**
  94914. * Fires every time a new xrFrame arrives which can be used to update the camera
  94915. */
  94916. onXRFrameObservable: Observable<any>;
  94917. /**
  94918. * Fires when the xr session is ended either by the device or manually done
  94919. */
  94920. onXRSessionEnded: Observable<any>;
  94921. /** @hidden */
  94922. _xrSession: XRSession;
  94923. /** @hidden */
  94924. _frameOfReference: XRFrameOfReference;
  94925. /** @hidden */
  94926. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  94927. /** @hidden */
  94928. _currentXRFrame: Nullable<XRFrame>;
  94929. private _xrNavigator;
  94930. private _xrDevice;
  94931. private _tmpMatrix;
  94932. /**
  94933. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  94934. * @param scene The scene which the session should be created for
  94935. */
  94936. constructor(scene: Scene);
  94937. /**
  94938. * Initializes the manager
  94939. * After initialization enterXR can be called to start an XR session
  94940. * @returns Promise which resolves after it is initialized
  94941. */
  94942. initializeAsync(): Promise<void>;
  94943. /**
  94944. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  94945. * @param sessionCreationOptions xr options to create the session with
  94946. * @param frameOfReferenceType option to configure how the xr pose is expressed
  94947. * @returns Promise which resolves after it enters XR
  94948. */
  94949. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  94950. /**
  94951. * Stops the xrSession and restores the renderloop
  94952. * @returns Promise which resolves after it exits XR
  94953. */
  94954. exitXRAsync(): Promise<void>;
  94955. /**
  94956. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  94957. * @param ray ray to cast into the environment
  94958. * @returns Promise which resolves with a collision point in the environment if it exists
  94959. */
  94960. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  94961. /**
  94962. * Checks if a session would be supported for the creation options specified
  94963. * @param options creation options to check if they are supported
  94964. * @returns true if supported
  94965. */
  94966. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  94967. /**
  94968. * @hidden
  94969. * Converts the render layer of xrSession to a render target
  94970. * @param session session to create render target for
  94971. * @param scene scene the new render target should be created for
  94972. */
  94973. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  94974. /**
  94975. * Disposes of the session manager
  94976. */
  94977. dispose(): void;
  94978. }
  94979. }
  94980. declare module BABYLON {
  94981. /**
  94982. * WebXR Camera which holds the views for the xrSession
  94983. * @see https://doc.babylonjs.com/how_to/webxr
  94984. */
  94985. export class WebXRCamera extends FreeCamera {
  94986. private static _TmpMatrix;
  94987. /**
  94988. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  94989. * @param name the name of the camera
  94990. * @param scene the scene to add the camera to
  94991. */
  94992. constructor(name: string, scene: Scene);
  94993. private _updateNumberOfRigCameras;
  94994. /** @hidden */
  94995. _updateForDualEyeDebugging(pupilDistance?: number): void;
  94996. /**
  94997. * Updates the cameras position from the current pose information of the XR session
  94998. * @param xrSessionManager the session containing pose information
  94999. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95000. */
  95001. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95002. }
  95003. }
  95004. declare module BABYLON {
  95005. /**
  95006. * States of the webXR experience
  95007. */
  95008. export enum WebXRState {
  95009. /**
  95010. * Transitioning to being in XR mode
  95011. */
  95012. ENTERING_XR = 0,
  95013. /**
  95014. * Transitioning to non XR mode
  95015. */
  95016. EXITING_XR = 1,
  95017. /**
  95018. * In XR mode and presenting
  95019. */
  95020. IN_XR = 2,
  95021. /**
  95022. * Not entered XR mode
  95023. */
  95024. NOT_IN_XR = 3
  95025. }
  95026. /**
  95027. * Helper class used to enable XR
  95028. * @see https://doc.babylonjs.com/how_to/webxr
  95029. */
  95030. export class WebXRExperienceHelper implements IDisposable {
  95031. private scene;
  95032. /**
  95033. * 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
  95034. */
  95035. container: AbstractMesh;
  95036. /**
  95037. * Camera used to render xr content
  95038. */
  95039. camera: WebXRCamera;
  95040. /**
  95041. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95042. */
  95043. state: WebXRState;
  95044. private _setState;
  95045. private static _TmpVector;
  95046. /**
  95047. * Fires when the state of the experience helper has changed
  95048. */
  95049. onStateChangedObservable: Observable<WebXRState>;
  95050. /** @hidden */
  95051. _sessionManager: WebXRSessionManager;
  95052. private _nonVRCamera;
  95053. private _originalSceneAutoClear;
  95054. private _supported;
  95055. /**
  95056. * Creates the experience helper
  95057. * @param scene the scene to attach the experience helper to
  95058. * @returns a promise for the experience helper
  95059. */
  95060. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95061. /**
  95062. * Creates a WebXRExperienceHelper
  95063. * @param scene The scene the helper should be created in
  95064. */
  95065. private constructor();
  95066. /**
  95067. * Exits XR mode and returns the scene to its original state
  95068. * @returns promise that resolves after xr mode has exited
  95069. */
  95070. exitXRAsync(): Promise<void>;
  95071. /**
  95072. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95073. * @param sessionCreationOptions options for the XR session
  95074. * @param frameOfReference frame of reference of the XR session
  95075. * @returns promise that resolves after xr mode has entered
  95076. */
  95077. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95078. /**
  95079. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95080. * @param ray ray to cast into the environment
  95081. * @returns Promise which resolves with a collision point in the environment if it exists
  95082. */
  95083. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95084. /**
  95085. * Updates the global position of the camera by moving the camera's container
  95086. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95087. * @param position The desired global position of the camera
  95088. */
  95089. setPositionOfCameraUsingContainer(position: Vector3): void;
  95090. /**
  95091. * Rotates the xr camera by rotating the camera's container around the camera's position
  95092. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95093. * @param rotation the desired quaternion rotation to apply to the camera
  95094. */
  95095. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95096. /**
  95097. * Checks if the creation options are supported by the xr session
  95098. * @param options creation options
  95099. * @returns true if supported
  95100. */
  95101. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95102. /**
  95103. * Disposes of the experience helper
  95104. */
  95105. dispose(): void;
  95106. }
  95107. }
  95108. declare module BABYLON {
  95109. /**
  95110. * Button which can be used to enter a different mode of XR
  95111. */
  95112. export class WebXREnterExitUIButton {
  95113. /** button element */
  95114. element: HTMLElement;
  95115. /** XR initialization options for the button */
  95116. initializationOptions: XRSessionCreationOptions;
  95117. /**
  95118. * Creates a WebXREnterExitUIButton
  95119. * @param element button element
  95120. * @param initializationOptions XR initialization options for the button
  95121. */
  95122. constructor(
  95123. /** button element */
  95124. element: HTMLElement,
  95125. /** XR initialization options for the button */
  95126. initializationOptions: XRSessionCreationOptions);
  95127. /**
  95128. * Overwritable function which can be used to update the button's visuals when the state changes
  95129. * @param activeButton the current active button in the UI
  95130. */
  95131. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95132. }
  95133. /**
  95134. * Options to create the webXR UI
  95135. */
  95136. export class WebXREnterExitUIOptions {
  95137. /**
  95138. * Context to enter xr with
  95139. */
  95140. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95141. /**
  95142. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95143. */
  95144. customButtons?: Array<WebXREnterExitUIButton>;
  95145. }
  95146. /**
  95147. * UI to allow the user to enter/exit XR mode
  95148. */
  95149. export class WebXREnterExitUI implements IDisposable {
  95150. private scene;
  95151. private _overlay;
  95152. private _buttons;
  95153. private _activeButton;
  95154. /**
  95155. * Fired every time the active button is changed.
  95156. *
  95157. * When xr is entered via a button that launches xr that button will be the callback parameter
  95158. *
  95159. * When exiting xr the callback parameter will be null)
  95160. */
  95161. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95162. /**
  95163. * Creates UI to allow the user to enter/exit XR mode
  95164. * @param scene the scene to add the ui to
  95165. * @param helper the xr experience helper to enter/exit xr with
  95166. * @param options options to configure the UI
  95167. * @returns the created ui
  95168. */
  95169. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95170. private constructor();
  95171. private _updateButtons;
  95172. /**
  95173. * Disposes of the object
  95174. */
  95175. dispose(): void;
  95176. }
  95177. }
  95178. declare module BABYLON {
  95179. /**
  95180. * Represents an XR input
  95181. */
  95182. export class WebXRController {
  95183. /**
  95184. * 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
  95185. */
  95186. grip?: AbstractMesh;
  95187. /**
  95188. * Pointer which can be used to select objects or attach a visible laser to
  95189. */
  95190. pointer: AbstractMesh;
  95191. /**
  95192. * Creates the controller
  95193. * @see https://doc.babylonjs.com/how_to/webxr
  95194. * @param scene the scene which the controller should be associated to
  95195. */
  95196. constructor(scene: Scene);
  95197. /**
  95198. * Disposes of the object
  95199. */
  95200. dispose(): void;
  95201. }
  95202. /**
  95203. * XR input used to track XR inputs such as controllers/rays
  95204. */
  95205. export class WebXRInput implements IDisposable {
  95206. private helper;
  95207. /**
  95208. * XR controllers being tracked
  95209. */
  95210. controllers: Array<WebXRController>;
  95211. private _tmpMatrix;
  95212. private _frameObserver;
  95213. /**
  95214. * Initializes the WebXRInput
  95215. * @param helper experience helper which the input should be created for
  95216. */
  95217. constructor(helper: WebXRExperienceHelper);
  95218. /**
  95219. * Disposes of the object
  95220. */
  95221. dispose(): void;
  95222. }
  95223. }
  95224. declare module BABYLON {
  95225. /**
  95226. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95227. */
  95228. export class WebXRManagedOutputCanvas implements IDisposable {
  95229. private _canvas;
  95230. /**
  95231. * xrpresent context of the canvas which can be used to display/mirror xr content
  95232. */
  95233. canvasContext: Nullable<WebGLRenderingContext>;
  95234. /**
  95235. * Initializes the canvas to be added/removed upon entering/exiting xr
  95236. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95237. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95238. */
  95239. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95240. /**
  95241. * Disposes of the object
  95242. */
  95243. dispose(): void;
  95244. private _setManagedOutputCanvas;
  95245. private _addCanvas;
  95246. private _removeCanvas;
  95247. }
  95248. }
  95249. declare module BABYLON {
  95250. /**
  95251. * Contains an array of blocks representing the octree
  95252. */
  95253. export interface IOctreeContainer<T> {
  95254. /**
  95255. * Blocks within the octree
  95256. */
  95257. blocks: Array<OctreeBlock<T>>;
  95258. }
  95259. /**
  95260. * Class used to store a cell in an octree
  95261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95262. */
  95263. export class OctreeBlock<T> {
  95264. /**
  95265. * Gets the content of the current block
  95266. */
  95267. entries: T[];
  95268. /**
  95269. * Gets the list of block children
  95270. */
  95271. blocks: Array<OctreeBlock<T>>;
  95272. private _depth;
  95273. private _maxDepth;
  95274. private _capacity;
  95275. private _minPoint;
  95276. private _maxPoint;
  95277. private _boundingVectors;
  95278. private _creationFunc;
  95279. /**
  95280. * Creates a new block
  95281. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95282. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95283. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95284. * @param depth defines the current depth of this block in the octree
  95285. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95286. * @param creationFunc defines a callback to call when an element is added to the block
  95287. */
  95288. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95289. /**
  95290. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95291. */
  95292. readonly capacity: number;
  95293. /**
  95294. * Gets the minimum vector (in world space) of the block's bounding box
  95295. */
  95296. readonly minPoint: Vector3;
  95297. /**
  95298. * Gets the maximum vector (in world space) of the block's bounding box
  95299. */
  95300. readonly maxPoint: Vector3;
  95301. /**
  95302. * Add a new element to this block
  95303. * @param entry defines the element to add
  95304. */
  95305. addEntry(entry: T): void;
  95306. /**
  95307. * Remove an element from this block
  95308. * @param entry defines the element to remove
  95309. */
  95310. removeEntry(entry: T): void;
  95311. /**
  95312. * Add an array of elements to this block
  95313. * @param entries defines the array of elements to add
  95314. */
  95315. addEntries(entries: T[]): void;
  95316. /**
  95317. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95318. * @param frustumPlanes defines the frustum planes to test
  95319. * @param selection defines the array to store current content if selection is positive
  95320. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95321. */
  95322. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95323. /**
  95324. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95325. * @param sphereCenter defines the bounding sphere center
  95326. * @param sphereRadius defines the bounding sphere radius
  95327. * @param selection defines the array to store current content if selection is positive
  95328. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95329. */
  95330. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95331. /**
  95332. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95333. * @param ray defines the ray to test with
  95334. * @param selection defines the array to store current content if selection is positive
  95335. */
  95336. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95337. /**
  95338. * Subdivide the content into child blocks (this block will then be empty)
  95339. */
  95340. createInnerBlocks(): void;
  95341. /**
  95342. * @hidden
  95343. */
  95344. 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;
  95345. }
  95346. }
  95347. declare module BABYLON {
  95348. /**
  95349. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95350. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95351. */
  95352. export class Octree<T> {
  95353. /** 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.) */
  95354. maxDepth: number;
  95355. /**
  95356. * Blocks within the octree containing objects
  95357. */
  95358. blocks: Array<OctreeBlock<T>>;
  95359. /**
  95360. * Content stored in the octree
  95361. */
  95362. dynamicContent: T[];
  95363. private _maxBlockCapacity;
  95364. private _selectionContent;
  95365. private _creationFunc;
  95366. /**
  95367. * Creates a octree
  95368. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95369. * @param creationFunc function to be used to instatiate the octree
  95370. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95371. * @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.)
  95372. */
  95373. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95374. /** 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.) */
  95375. maxDepth?: number);
  95376. /**
  95377. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95378. * @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);
  95379. * @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);
  95380. * @param entries meshes to be added to the octree blocks
  95381. */
  95382. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95383. /**
  95384. * Adds a mesh to the octree
  95385. * @param entry Mesh to add to the octree
  95386. */
  95387. addMesh(entry: T): void;
  95388. /**
  95389. * Remove an element from the octree
  95390. * @param entry defines the element to remove
  95391. */
  95392. removeMesh(entry: T): void;
  95393. /**
  95394. * Selects an array of meshes within the frustum
  95395. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95396. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95397. * @returns array of meshes within the frustum
  95398. */
  95399. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95400. /**
  95401. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95402. * @param sphereCenter defines the bounding sphere center
  95403. * @param sphereRadius defines the bounding sphere radius
  95404. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95405. * @returns an array of objects that intersect the sphere
  95406. */
  95407. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95408. /**
  95409. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95410. * @param ray defines the ray to test with
  95411. * @returns array of intersected objects
  95412. */
  95413. intersectsRay(ray: Ray): SmartArray<T>;
  95414. /**
  95415. * Adds a mesh into the octree block if it intersects the block
  95416. */
  95417. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95418. /**
  95419. * Adds a submesh into the octree block if it intersects the block
  95420. */
  95421. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95422. }
  95423. }
  95424. declare module BABYLON {
  95425. interface Scene {
  95426. /**
  95427. * @hidden
  95428. * Backing Filed
  95429. */
  95430. _selectionOctree: Octree<AbstractMesh>;
  95431. /**
  95432. * Gets the octree used to boost mesh selection (picking)
  95433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95434. */
  95435. selectionOctree: Octree<AbstractMesh>;
  95436. /**
  95437. * Creates or updates the octree used to boost selection (picking)
  95438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95439. * @param maxCapacity defines the maximum capacity per leaf
  95440. * @param maxDepth defines the maximum depth of the octree
  95441. * @returns an octree of AbstractMesh
  95442. */
  95443. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95444. }
  95445. interface AbstractMesh {
  95446. /**
  95447. * @hidden
  95448. * Backing Field
  95449. */
  95450. _submeshesOctree: Octree<SubMesh>;
  95451. /**
  95452. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95454. * @param maxCapacity defines the maximum size of each block (64 by default)
  95455. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95456. * @returns the new octree
  95457. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95459. */
  95460. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95461. }
  95462. /**
  95463. * Defines the octree scene component responsible to manage any octrees
  95464. * in a given scene.
  95465. */
  95466. export class OctreeSceneComponent {
  95467. /**
  95468. * The component name helpfull to identify the component in the list of scene components.
  95469. */
  95470. readonly name: string;
  95471. /**
  95472. * The scene the component belongs to.
  95473. */
  95474. scene: Scene;
  95475. /**
  95476. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95477. */
  95478. readonly checksIsEnabled: boolean;
  95479. /**
  95480. * Creates a new instance of the component for the given scene
  95481. * @param scene Defines the scene to register the component in
  95482. */
  95483. constructor(scene: Scene);
  95484. /**
  95485. * Registers the component in a given scene
  95486. */
  95487. register(): void;
  95488. /**
  95489. * Return the list of active meshes
  95490. * @returns the list of active meshes
  95491. */
  95492. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95493. /**
  95494. * Return the list of active sub meshes
  95495. * @param mesh The mesh to get the candidates sub meshes from
  95496. * @returns the list of active sub meshes
  95497. */
  95498. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95499. private _tempRay;
  95500. /**
  95501. * Return the list of sub meshes intersecting with a given local ray
  95502. * @param mesh defines the mesh to find the submesh for
  95503. * @param localRay defines the ray in local space
  95504. * @returns the list of intersecting sub meshes
  95505. */
  95506. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95507. /**
  95508. * Return the list of sub meshes colliding with a collider
  95509. * @param mesh defines the mesh to find the submesh for
  95510. * @param collider defines the collider to evaluate the collision against
  95511. * @returns the list of colliding sub meshes
  95512. */
  95513. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  95514. /**
  95515. * Rebuilds the elements related to this component in case of
  95516. * context lost for instance.
  95517. */
  95518. rebuild(): void;
  95519. /**
  95520. * Disposes the component and the associated ressources.
  95521. */
  95522. dispose(): void;
  95523. }
  95524. }
  95525. declare module BABYLON {
  95526. /**
  95527. * Class containing static functions to help procedurally build meshes
  95528. */
  95529. export class LinesBuilder {
  95530. /**
  95531. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  95532. * * 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
  95533. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  95534. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  95535. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  95536. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  95537. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  95538. * * 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
  95539. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  95540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  95542. * @param name defines the name of the new line system
  95543. * @param options defines the options used to create the line system
  95544. * @param scene defines the hosting scene
  95545. * @returns a new line system mesh
  95546. */
  95547. static CreateLineSystem(name: string, options: {
  95548. lines: Vector3[][];
  95549. updatable?: boolean;
  95550. instance?: Nullable<LinesMesh>;
  95551. colors?: Nullable<Color4[][]>;
  95552. useVertexAlpha?: boolean;
  95553. }, scene: Nullable<Scene>): LinesMesh;
  95554. /**
  95555. * Creates a line mesh
  95556. * 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
  95557. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95558. * * The parameter `points` is an array successive Vector3
  95559. * * 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
  95560. * * The optional parameter `colors` is an array of successive Color4, one per line point
  95561. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  95562. * * When updating an instance, remember that only point positions can change, not the number of points
  95563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  95565. * @param name defines the name of the new line system
  95566. * @param options defines the options used to create the line system
  95567. * @param scene defines the hosting scene
  95568. * @returns a new line mesh
  95569. */
  95570. static CreateLines(name: string, options: {
  95571. points: Vector3[];
  95572. updatable?: boolean;
  95573. instance?: Nullable<LinesMesh>;
  95574. colors?: Color4[];
  95575. useVertexAlpha?: boolean;
  95576. }, scene?: Nullable<Scene>): LinesMesh;
  95577. /**
  95578. * Creates a dashed line mesh
  95579. * * 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
  95580. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95581. * * The parameter `points` is an array successive Vector3
  95582. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  95583. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  95584. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95585. * * 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
  95586. * * When updating an instance, remember that only point positions can change, not the number of points
  95587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95588. * @param name defines the name of the mesh
  95589. * @param options defines the options used to create the mesh
  95590. * @param scene defines the hosting scene
  95591. * @returns the dashed line mesh
  95592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  95593. */
  95594. static CreateDashedLines(name: string, options: {
  95595. points: Vector3[];
  95596. dashSize?: number;
  95597. gapSize?: number;
  95598. dashNb?: number;
  95599. updatable?: boolean;
  95600. instance?: LinesMesh;
  95601. }, scene?: Nullable<Scene>): LinesMesh;
  95602. }
  95603. }
  95604. declare module BABYLON {
  95605. /**
  95606. * Renders a layer on top of an existing scene
  95607. */
  95608. export class UtilityLayerRenderer implements IDisposable {
  95609. /** the original scene that will be rendered on top of */
  95610. originalScene: Scene;
  95611. private _pointerCaptures;
  95612. private _lastPointerEvents;
  95613. private static _DefaultUtilityLayer;
  95614. private static _DefaultKeepDepthUtilityLayer;
  95615. /**
  95616. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  95617. */
  95618. pickUtilitySceneFirst: boolean;
  95619. /**
  95620. * 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)
  95621. */
  95622. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  95623. /**
  95624. * 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)
  95625. */
  95626. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  95627. /**
  95628. * The scene that is rendered on top of the original scene
  95629. */
  95630. utilityLayerScene: Scene;
  95631. /**
  95632. * If the utility layer should automatically be rendered on top of existing scene
  95633. */
  95634. shouldRender: boolean;
  95635. /**
  95636. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  95637. */
  95638. onlyCheckPointerDownEvents: boolean;
  95639. /**
  95640. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  95641. */
  95642. processAllEvents: boolean;
  95643. /**
  95644. * Observable raised when the pointer move from the utility layer scene to the main scene
  95645. */
  95646. onPointerOutObservable: Observable<number>;
  95647. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  95648. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  95649. private _afterRenderObserver;
  95650. private _sceneDisposeObserver;
  95651. private _originalPointerObserver;
  95652. /**
  95653. * Instantiates a UtilityLayerRenderer
  95654. * @param originalScene the original scene that will be rendered on top of
  95655. * @param handleEvents boolean indicating if the utility layer should handle events
  95656. */
  95657. constructor(
  95658. /** the original scene that will be rendered on top of */
  95659. originalScene: Scene, handleEvents?: boolean);
  95660. private _notifyObservers;
  95661. /**
  95662. * Renders the utility layers scene on top of the original scene
  95663. */
  95664. render(): void;
  95665. /**
  95666. * Disposes of the renderer
  95667. */
  95668. dispose(): void;
  95669. private _updateCamera;
  95670. }
  95671. }
  95672. declare module BABYLON {
  95673. /**
  95674. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  95675. */
  95676. export class Gizmo implements IDisposable {
  95677. /** The utility layer the gizmo will be added to */
  95678. gizmoLayer: UtilityLayerRenderer;
  95679. /**
  95680. * The root mesh of the gizmo
  95681. */
  95682. protected _rootMesh: Mesh;
  95683. private _attachedMesh;
  95684. /**
  95685. * Ratio for the scale of the gizmo (Default: 1)
  95686. */
  95687. scaleRatio: number;
  95688. private _tmpMatrix;
  95689. /**
  95690. * If a custom mesh has been set (Default: false)
  95691. */
  95692. protected _customMeshSet: boolean;
  95693. /**
  95694. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  95695. * * When set, interactions will be enabled
  95696. */
  95697. attachedMesh: Nullable<AbstractMesh>;
  95698. /**
  95699. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  95700. * @param mesh The mesh to replace the default mesh of the gizmo
  95701. */
  95702. setCustomMesh(mesh: Mesh): void;
  95703. /**
  95704. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  95705. */
  95706. updateGizmoRotationToMatchAttachedMesh: boolean;
  95707. /**
  95708. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  95709. */
  95710. updateGizmoPositionToMatchAttachedMesh: boolean;
  95711. /**
  95712. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  95713. */
  95714. protected _updateScale: boolean;
  95715. protected _interactionsEnabled: boolean;
  95716. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95717. private _beforeRenderObserver;
  95718. /**
  95719. * Creates a gizmo
  95720. * @param gizmoLayer The utility layer the gizmo will be added to
  95721. */
  95722. constructor(
  95723. /** The utility layer the gizmo will be added to */
  95724. gizmoLayer?: UtilityLayerRenderer);
  95725. private _tempVector;
  95726. /**
  95727. * @hidden
  95728. * Updates the gizmo to match the attached mesh's position/rotation
  95729. */
  95730. protected _update(): void;
  95731. /**
  95732. * Disposes of the gizmo
  95733. */
  95734. dispose(): void;
  95735. }
  95736. }
  95737. declare module BABYLON {
  95738. /**
  95739. * Single axis drag gizmo
  95740. */
  95741. export class AxisDragGizmo extends Gizmo {
  95742. /**
  95743. * Drag behavior responsible for the gizmos dragging interactions
  95744. */
  95745. dragBehavior: PointerDragBehavior;
  95746. private _pointerObserver;
  95747. /**
  95748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  95749. */
  95750. snapDistance: number;
  95751. /**
  95752. * Event that fires each time the gizmo snaps to a new location.
  95753. * * snapDistance is the the change in distance
  95754. */
  95755. onSnapObservable: Observable<{
  95756. snapDistance: number;
  95757. }>;
  95758. /** @hidden */
  95759. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  95760. /** @hidden */
  95761. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  95762. /**
  95763. * Creates an AxisDragGizmo
  95764. * @param gizmoLayer The utility layer the gizmo will be added to
  95765. * @param dragAxis The axis which the gizmo will be able to drag on
  95766. * @param color The color of the gizmo
  95767. */
  95768. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  95769. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95770. /**
  95771. * Disposes of the gizmo
  95772. */
  95773. dispose(): void;
  95774. }
  95775. }
  95776. declare module BABYLON.Debug {
  95777. /**
  95778. * The Axes viewer will show 3 axes in a specific point in space
  95779. */
  95780. export class AxesViewer {
  95781. private _xAxis;
  95782. private _yAxis;
  95783. private _zAxis;
  95784. private _scaleLinesFactor;
  95785. private _instanced;
  95786. /**
  95787. * Gets the hosting scene
  95788. */
  95789. scene: Scene;
  95790. /**
  95791. * Gets or sets a number used to scale line length
  95792. */
  95793. scaleLines: number;
  95794. /** Gets the node hierarchy used to render x-axis */
  95795. readonly xAxis: TransformNode;
  95796. /** Gets the node hierarchy used to render y-axis */
  95797. readonly yAxis: TransformNode;
  95798. /** Gets the node hierarchy used to render z-axis */
  95799. readonly zAxis: TransformNode;
  95800. /**
  95801. * Creates a new AxesViewer
  95802. * @param scene defines the hosting scene
  95803. * @param scaleLines defines a number used to scale line length (1 by default)
  95804. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  95805. * @param xAxis defines the node hierarchy used to render the x-axis
  95806. * @param yAxis defines the node hierarchy used to render the y-axis
  95807. * @param zAxis defines the node hierarchy used to render the z-axis
  95808. */
  95809. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  95810. /**
  95811. * Force the viewer to update
  95812. * @param position defines the position of the viewer
  95813. * @param xaxis defines the x axis of the viewer
  95814. * @param yaxis defines the y axis of the viewer
  95815. * @param zaxis defines the z axis of the viewer
  95816. */
  95817. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  95818. /**
  95819. * Creates an instance of this axes viewer.
  95820. * @returns a new axes viewer with instanced meshes
  95821. */
  95822. createInstance(): AxesViewer;
  95823. /** Releases resources */
  95824. dispose(): void;
  95825. private static _SetRenderingGroupId;
  95826. }
  95827. }
  95828. declare module BABYLON.Debug {
  95829. /**
  95830. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  95831. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  95832. */
  95833. export class BoneAxesViewer extends AxesViewer {
  95834. /**
  95835. * Gets or sets the target mesh where to display the axes viewer
  95836. */
  95837. mesh: Nullable<Mesh>;
  95838. /**
  95839. * Gets or sets the target bone where to display the axes viewer
  95840. */
  95841. bone: Nullable<Bone>;
  95842. /** Gets current position */
  95843. pos: Vector3;
  95844. /** Gets direction of X axis */
  95845. xaxis: Vector3;
  95846. /** Gets direction of Y axis */
  95847. yaxis: Vector3;
  95848. /** Gets direction of Z axis */
  95849. zaxis: Vector3;
  95850. /**
  95851. * Creates a new BoneAxesViewer
  95852. * @param scene defines the hosting scene
  95853. * @param bone defines the target bone
  95854. * @param mesh defines the target mesh
  95855. * @param scaleLines defines a scaling factor for line length (1 by default)
  95856. */
  95857. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  95858. /**
  95859. * Force the viewer to update
  95860. */
  95861. update(): void;
  95862. /** Releases resources */
  95863. dispose(): void;
  95864. }
  95865. }
  95866. declare module BABYLON {
  95867. /**
  95868. * Interface used to define scene explorer extensibility option
  95869. */
  95870. export interface IExplorerExtensibilityOption {
  95871. /**
  95872. * Define the option label
  95873. */
  95874. label: string;
  95875. /**
  95876. * Defines the action to execute on click
  95877. */
  95878. action: (entity: any) => void;
  95879. }
  95880. /**
  95881. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  95882. */
  95883. export interface IExplorerExtensibilityGroup {
  95884. /**
  95885. * Defines a predicate to test if a given type mut be extended
  95886. */
  95887. predicate: (entity: any) => boolean;
  95888. /**
  95889. * Gets the list of options added to a type
  95890. */
  95891. entries: IExplorerExtensibilityOption[];
  95892. }
  95893. /**
  95894. * Interface used to define the options to use to create the Inspector
  95895. */
  95896. export interface IInspectorOptions {
  95897. /**
  95898. * Display in overlay mode (default: false)
  95899. */
  95900. overlay?: boolean;
  95901. /**
  95902. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  95903. */
  95904. globalRoot?: HTMLElement;
  95905. /**
  95906. * Display the Scene explorer
  95907. */
  95908. showExplorer?: boolean;
  95909. /**
  95910. * Display the property inspector
  95911. */
  95912. showInspector?: boolean;
  95913. /**
  95914. * Display in embed mode (both panes on the right)
  95915. */
  95916. embedMode?: boolean;
  95917. /**
  95918. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  95919. */
  95920. handleResize?: boolean;
  95921. /**
  95922. * Allow the panes to popup (default: true)
  95923. */
  95924. enablePopup?: boolean;
  95925. /**
  95926. * Allow the panes to be closed by users (default: true)
  95927. */
  95928. enableClose?: boolean;
  95929. /**
  95930. * Optional list of extensibility entries
  95931. */
  95932. explorerExtensibility?: IExplorerExtensibilityGroup[];
  95933. }
  95934. interface Scene {
  95935. /**
  95936. * @hidden
  95937. * Backing field
  95938. */
  95939. _debugLayer: DebugLayer;
  95940. /**
  95941. * Gets the debug layer (aka Inspector) associated with the scene
  95942. * @see http://doc.babylonjs.com/features/playground_debuglayer
  95943. */
  95944. debugLayer: DebugLayer;
  95945. }
  95946. /**
  95947. * The debug layer (aka Inspector) is the go to tool in order to better understand
  95948. * what is happening in your scene
  95949. * @see http://doc.babylonjs.com/features/playground_debuglayer
  95950. */
  95951. export class DebugLayer {
  95952. /**
  95953. * Define the url to get the inspector script from.
  95954. * By default it uses the babylonjs CDN.
  95955. * @ignoreNaming
  95956. */
  95957. static InspectorURL: string;
  95958. private _scene;
  95959. private BJSINSPECTOR;
  95960. /**
  95961. * Observable triggered when a property is changed through the inspector.
  95962. */
  95963. onPropertyChangedObservable: Observable<{
  95964. object: any;
  95965. property: string;
  95966. value: any;
  95967. initialValue: any;
  95968. }>;
  95969. /**
  95970. * Instantiates a new debug layer.
  95971. * The debug layer (aka Inspector) is the go to tool in order to better understand
  95972. * what is happening in your scene
  95973. * @see http://doc.babylonjs.com/features/playground_debuglayer
  95974. * @param scene Defines the scene to inspect
  95975. */
  95976. constructor(scene: Scene);
  95977. /** Creates the inspector window. */
  95978. private _createInspector;
  95979. /** Get the inspector from bundle or global */
  95980. private _getGlobalInspector;
  95981. /**
  95982. * Get if the inspector is visible or not.
  95983. * @returns true if visible otherwise, false
  95984. */
  95985. isVisible(): boolean;
  95986. /**
  95987. * Hide the inspector and close its window.
  95988. */
  95989. hide(): void;
  95990. /**
  95991. * Launch the debugLayer.
  95992. * @param config Define the configuration of the inspector
  95993. */
  95994. show(config?: IInspectorOptions): void;
  95995. }
  95996. }
  95997. declare module BABYLON {
  95998. /**
  95999. * Class containing static functions to help procedurally build meshes
  96000. */
  96001. export class BoxBuilder {
  96002. /**
  96003. * Creates a box mesh
  96004. * * The parameter `size` sets the size (float) of each box side (default 1)
  96005. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96006. * * 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)
  96007. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96011. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96012. * @param name defines the name of the mesh
  96013. * @param options defines the options used to create the mesh
  96014. * @param scene defines the hosting scene
  96015. * @returns the box mesh
  96016. */
  96017. static CreateBox(name: string, options: {
  96018. size?: number;
  96019. width?: number;
  96020. height?: number;
  96021. depth?: number;
  96022. faceUV?: Vector4[];
  96023. faceColors?: Color4[];
  96024. sideOrientation?: number;
  96025. frontUVs?: Vector4;
  96026. backUVs?: Vector4;
  96027. updatable?: boolean;
  96028. }, scene?: Nullable<Scene>): Mesh;
  96029. }
  96030. }
  96031. declare module BABYLON {
  96032. /**
  96033. * Class containing static functions to help procedurally build meshes
  96034. */
  96035. export class SphereBuilder {
  96036. /**
  96037. * Creates a sphere mesh
  96038. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96039. * * 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`)
  96040. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96041. * * 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
  96042. * * 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)
  96043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96046. * @param name defines the name of the mesh
  96047. * @param options defines the options used to create the mesh
  96048. * @param scene defines the hosting scene
  96049. * @returns the sphere mesh
  96050. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96051. */
  96052. static CreateSphere(name: string, options: {
  96053. segments?: number;
  96054. diameter?: number;
  96055. diameterX?: number;
  96056. diameterY?: number;
  96057. diameterZ?: number;
  96058. arc?: number;
  96059. slice?: number;
  96060. sideOrientation?: number;
  96061. frontUVs?: Vector4;
  96062. backUVs?: Vector4;
  96063. updatable?: boolean;
  96064. }, scene: any): Mesh;
  96065. }
  96066. }
  96067. declare module BABYLON.Debug {
  96068. /**
  96069. * Used to show the physics impostor around the specific mesh
  96070. */
  96071. export class PhysicsViewer {
  96072. /** @hidden */
  96073. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96074. /** @hidden */
  96075. protected _meshes: Array<Nullable<AbstractMesh>>;
  96076. /** @hidden */
  96077. protected _scene: Nullable<Scene>;
  96078. /** @hidden */
  96079. protected _numMeshes: number;
  96080. /** @hidden */
  96081. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96082. private _renderFunction;
  96083. private _utilityLayer;
  96084. private _debugBoxMesh;
  96085. private _debugSphereMesh;
  96086. private _debugMaterial;
  96087. /**
  96088. * Creates a new PhysicsViewer
  96089. * @param scene defines the hosting scene
  96090. */
  96091. constructor(scene: Scene);
  96092. /** @hidden */
  96093. protected _updateDebugMeshes(): void;
  96094. /**
  96095. * Renders a specified physic impostor
  96096. * @param impostor defines the impostor to render
  96097. * @returns the new debug mesh used to render the impostor
  96098. */
  96099. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96100. /**
  96101. * Hides a specified physic impostor
  96102. * @param impostor defines the impostor to hide
  96103. */
  96104. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96105. private _getDebugMaterial;
  96106. private _getDebugBoxMesh;
  96107. private _getDebugSphereMesh;
  96108. private _getDebugMesh;
  96109. /** Releases all resources */
  96110. dispose(): void;
  96111. }
  96112. }
  96113. declare module BABYLON {
  96114. /**
  96115. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96116. * in order to better appreciate the issue one might have.
  96117. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96118. */
  96119. export class RayHelper {
  96120. /**
  96121. * Defines the ray we are currently tryin to visualize.
  96122. */
  96123. ray: Nullable<Ray>;
  96124. private _renderPoints;
  96125. private _renderLine;
  96126. private _renderFunction;
  96127. private _scene;
  96128. private _updateToMeshFunction;
  96129. private _attachedToMesh;
  96130. private _meshSpaceDirection;
  96131. private _meshSpaceOrigin;
  96132. /**
  96133. * Helper function to create a colored helper in a scene in one line.
  96134. * @param ray Defines the ray we are currently tryin to visualize
  96135. * @param scene Defines the scene the ray is used in
  96136. * @param color Defines the color we want to see the ray in
  96137. * @returns The newly created ray helper.
  96138. */
  96139. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96140. /**
  96141. * Instantiate a new ray helper.
  96142. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96143. * in order to better appreciate the issue one might have.
  96144. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96145. * @param ray Defines the ray we are currently tryin to visualize
  96146. */
  96147. constructor(ray: Ray);
  96148. /**
  96149. * Shows the ray we are willing to debug.
  96150. * @param scene Defines the scene the ray needs to be rendered in
  96151. * @param color Defines the color the ray needs to be rendered in
  96152. */
  96153. show(scene: Scene, color?: Color3): void;
  96154. /**
  96155. * Hides the ray we are debugging.
  96156. */
  96157. hide(): void;
  96158. private _render;
  96159. /**
  96160. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96161. * @param mesh Defines the mesh we want the helper attached to
  96162. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96163. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96164. * @param length Defines the length of the ray
  96165. */
  96166. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96167. /**
  96168. * Detach the ray helper from the mesh it has previously been attached to.
  96169. */
  96170. detachFromMesh(): void;
  96171. private _updateToMesh;
  96172. /**
  96173. * Dispose the helper and release its associated resources.
  96174. */
  96175. dispose(): void;
  96176. }
  96177. }
  96178. declare module BABYLON.Debug {
  96179. /**
  96180. * Class used to render a debug view of a given skeleton
  96181. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96182. */
  96183. export class SkeletonViewer {
  96184. /** defines the skeleton to render */
  96185. skeleton: Skeleton;
  96186. /** defines the mesh attached to the skeleton */
  96187. mesh: AbstractMesh;
  96188. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96189. autoUpdateBonesMatrices: boolean;
  96190. /** defines the rendering group id to use with the viewer */
  96191. renderingGroupId: number;
  96192. /** Gets or sets the color used to render the skeleton */
  96193. color: Color3;
  96194. private _scene;
  96195. private _debugLines;
  96196. private _debugMesh;
  96197. private _isEnabled;
  96198. private _renderFunction;
  96199. private _utilityLayer;
  96200. /**
  96201. * Returns the mesh used to render the bones
  96202. */
  96203. readonly debugMesh: Nullable<LinesMesh>;
  96204. /**
  96205. * Creates a new SkeletonViewer
  96206. * @param skeleton defines the skeleton to render
  96207. * @param mesh defines the mesh attached to the skeleton
  96208. * @param scene defines the hosting scene
  96209. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96210. * @param renderingGroupId defines the rendering group id to use with the viewer
  96211. */
  96212. constructor(
  96213. /** defines the skeleton to render */
  96214. skeleton: Skeleton,
  96215. /** defines the mesh attached to the skeleton */
  96216. mesh: AbstractMesh, scene: Scene,
  96217. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96218. autoUpdateBonesMatrices?: boolean,
  96219. /** defines the rendering group id to use with the viewer */
  96220. renderingGroupId?: number);
  96221. /** Gets or sets a boolean indicating if the viewer is enabled */
  96222. isEnabled: boolean;
  96223. private _getBonePosition;
  96224. private _getLinesForBonesWithLength;
  96225. private _getLinesForBonesNoLength;
  96226. /** Update the viewer to sync with current skeleton state */
  96227. update(): void;
  96228. /** Release associated resources */
  96229. dispose(): void;
  96230. }
  96231. }
  96232. declare module BABYLON {
  96233. /**
  96234. * Options to create the null engine
  96235. */
  96236. export class NullEngineOptions {
  96237. /**
  96238. * Render width (Default: 512)
  96239. */
  96240. renderWidth: number;
  96241. /**
  96242. * Render height (Default: 256)
  96243. */
  96244. renderHeight: number;
  96245. /**
  96246. * Texture size (Default: 512)
  96247. */
  96248. textureSize: number;
  96249. /**
  96250. * If delta time between frames should be constant
  96251. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96252. */
  96253. deterministicLockstep: boolean;
  96254. /**
  96255. * Maximum about of steps between frames (Default: 4)
  96256. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96257. */
  96258. lockstepMaxSteps: number;
  96259. }
  96260. /**
  96261. * The null engine class provides support for headless version of babylon.js.
  96262. * This can be used in server side scenario or for testing purposes
  96263. */
  96264. export class NullEngine extends Engine {
  96265. private _options;
  96266. /**
  96267. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96268. */
  96269. isDeterministicLockStep(): boolean;
  96270. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96271. getLockstepMaxSteps(): number;
  96272. /**
  96273. * Sets hardware scaling, used to save performance if needed
  96274. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96275. */
  96276. getHardwareScalingLevel(): number;
  96277. constructor(options?: NullEngineOptions);
  96278. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96279. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96280. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96281. getRenderWidth(useScreen?: boolean): number;
  96282. getRenderHeight(useScreen?: boolean): number;
  96283. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96284. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96285. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96286. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96287. bindSamplers(effect: Effect): void;
  96288. enableEffect(effect: Effect): void;
  96289. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96290. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96291. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96292. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96293. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96294. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96295. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96296. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96297. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96298. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96299. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96300. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96301. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96302. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96303. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96304. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96305. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96306. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96307. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96308. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96309. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96310. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96311. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96312. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96313. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96314. bindBuffers(vertexBuffers: {
  96315. [key: string]: VertexBuffer;
  96316. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96317. wipeCaches(bruteForce?: boolean): void;
  96318. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96319. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96320. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96321. /** @hidden */
  96322. _createTexture(): WebGLTexture;
  96323. /** @hidden */
  96324. _releaseTexture(texture: InternalTexture): void;
  96325. 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;
  96326. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96327. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96328. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96329. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96330. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96331. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96332. areAllEffectsReady(): boolean;
  96333. /**
  96334. * @hidden
  96335. * Get the current error code of the webGL context
  96336. * @returns the error code
  96337. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96338. */
  96339. getError(): number;
  96340. /** @hidden */
  96341. _getUnpackAlignement(): number;
  96342. /** @hidden */
  96343. _unpackFlipY(value: boolean): void;
  96344. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96345. /**
  96346. * Updates a dynamic vertex buffer.
  96347. * @param vertexBuffer the vertex buffer to update
  96348. * @param data the data used to update the vertex buffer
  96349. * @param byteOffset the byte offset of the data (optional)
  96350. * @param byteLength the byte length of the data (optional)
  96351. */
  96352. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96353. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96354. /** @hidden */
  96355. _bindTexture(channel: number, texture: InternalTexture): void;
  96356. /** @hidden */
  96357. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96358. releaseEffects(): void;
  96359. displayLoadingUI(): void;
  96360. hideLoadingUI(): void;
  96361. /** @hidden */
  96362. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96363. /** @hidden */
  96364. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96365. /** @hidden */
  96366. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96367. /** @hidden */
  96368. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96369. }
  96370. }
  96371. declare module BABYLON {
  96372. /** @hidden */
  96373. export class _OcclusionDataStorage {
  96374. /** @hidden */
  96375. occlusionInternalRetryCounter: number;
  96376. /** @hidden */
  96377. isOcclusionQueryInProgress: boolean;
  96378. /** @hidden */
  96379. isOccluded: boolean;
  96380. /** @hidden */
  96381. occlusionRetryCount: number;
  96382. /** @hidden */
  96383. occlusionType: number;
  96384. /** @hidden */
  96385. occlusionQueryAlgorithmType: number;
  96386. }
  96387. interface Engine {
  96388. /**
  96389. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96390. * @return the new query
  96391. */
  96392. createQuery(): WebGLQuery;
  96393. /**
  96394. * Delete and release a webGL query
  96395. * @param query defines the query to delete
  96396. * @return the current engine
  96397. */
  96398. deleteQuery(query: WebGLQuery): Engine;
  96399. /**
  96400. * Check if a given query has resolved and got its value
  96401. * @param query defines the query to check
  96402. * @returns true if the query got its value
  96403. */
  96404. isQueryResultAvailable(query: WebGLQuery): boolean;
  96405. /**
  96406. * Gets the value of a given query
  96407. * @param query defines the query to check
  96408. * @returns the value of the query
  96409. */
  96410. getQueryResult(query: WebGLQuery): number;
  96411. /**
  96412. * Initiates an occlusion query
  96413. * @param algorithmType defines the algorithm to use
  96414. * @param query defines the query to use
  96415. * @returns the current engine
  96416. * @see http://doc.babylonjs.com/features/occlusionquery
  96417. */
  96418. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96419. /**
  96420. * Ends an occlusion query
  96421. * @see http://doc.babylonjs.com/features/occlusionquery
  96422. * @param algorithmType defines the algorithm to use
  96423. * @returns the current engine
  96424. */
  96425. endOcclusionQuery(algorithmType: number): Engine;
  96426. /**
  96427. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96428. * Please note that only one query can be issued at a time
  96429. * @returns a time token used to track the time span
  96430. */
  96431. startTimeQuery(): Nullable<_TimeToken>;
  96432. /**
  96433. * Ends a time query
  96434. * @param token defines the token used to measure the time span
  96435. * @returns the time spent (in ns)
  96436. */
  96437. endTimeQuery(token: _TimeToken): int;
  96438. /** @hidden */
  96439. _currentNonTimestampToken: Nullable<_TimeToken>;
  96440. /** @hidden */
  96441. _createTimeQuery(): WebGLQuery;
  96442. /** @hidden */
  96443. _deleteTimeQuery(query: WebGLQuery): void;
  96444. /** @hidden */
  96445. _getGlAlgorithmType(algorithmType: number): number;
  96446. /** @hidden */
  96447. _getTimeQueryResult(query: WebGLQuery): any;
  96448. /** @hidden */
  96449. _getTimeQueryAvailability(query: WebGLQuery): any;
  96450. }
  96451. interface AbstractMesh {
  96452. /**
  96453. * Backing filed
  96454. * @hidden
  96455. */
  96456. __occlusionDataStorage: _OcclusionDataStorage;
  96457. /**
  96458. * Access property
  96459. * @hidden
  96460. */
  96461. _occlusionDataStorage: _OcclusionDataStorage;
  96462. /**
  96463. * 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.
  96464. * The default value is -1 which means don't break the query and wait till the result
  96465. * @see http://doc.babylonjs.com/features/occlusionquery
  96466. */
  96467. occlusionRetryCount: number;
  96468. /**
  96469. * 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:
  96470. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96471. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96472. * * 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.
  96473. * @see http://doc.babylonjs.com/features/occlusionquery
  96474. */
  96475. occlusionType: number;
  96476. /**
  96477. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96478. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96479. * * 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.
  96480. * @see http://doc.babylonjs.com/features/occlusionquery
  96481. */
  96482. occlusionQueryAlgorithmType: number;
  96483. /**
  96484. * 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
  96485. * @see http://doc.babylonjs.com/features/occlusionquery
  96486. */
  96487. isOccluded: boolean;
  96488. /**
  96489. * Flag to check the progress status of the query
  96490. * @see http://doc.babylonjs.com/features/occlusionquery
  96491. */
  96492. isOcclusionQueryInProgress: boolean;
  96493. }
  96494. }
  96495. declare module BABYLON {
  96496. /** @hidden */
  96497. export var _forceTransformFeedbackToBundle: boolean;
  96498. interface Engine {
  96499. /**
  96500. * Creates a webGL transform feedback object
  96501. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96502. * @returns the webGL transform feedback object
  96503. */
  96504. createTransformFeedback(): WebGLTransformFeedback;
  96505. /**
  96506. * Delete a webGL transform feedback object
  96507. * @param value defines the webGL transform feedback object to delete
  96508. */
  96509. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96510. /**
  96511. * Bind a webGL transform feedback object to the webgl context
  96512. * @param value defines the webGL transform feedback object to bind
  96513. */
  96514. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96515. /**
  96516. * Begins a transform feedback operation
  96517. * @param usePoints defines if points or triangles must be used
  96518. */
  96519. beginTransformFeedback(usePoints: boolean): void;
  96520. /**
  96521. * Ends a transform feedback operation
  96522. */
  96523. endTransformFeedback(): void;
  96524. /**
  96525. * Specify the varyings to use with transform feedback
  96526. * @param program defines the associated webGL program
  96527. * @param value defines the list of strings representing the varying names
  96528. */
  96529. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96530. /**
  96531. * Bind a webGL buffer for a transform feedback operation
  96532. * @param value defines the webGL buffer to bind
  96533. */
  96534. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96535. }
  96536. }
  96537. declare module BABYLON {
  96538. /**
  96539. * Gather the list of clipboard event types as constants.
  96540. */
  96541. export class ClipboardEventTypes {
  96542. /**
  96543. * The clipboard event is fired when a copy command is active (pressed).
  96544. */
  96545. static readonly COPY: number;
  96546. /**
  96547. * The clipboard event is fired when a cut command is active (pressed).
  96548. */
  96549. static readonly CUT: number;
  96550. /**
  96551. * The clipboard event is fired when a paste command is active (pressed).
  96552. */
  96553. static readonly PASTE: number;
  96554. }
  96555. /**
  96556. * This class is used to store clipboard related info for the onClipboardObservable event.
  96557. */
  96558. export class ClipboardInfo {
  96559. /**
  96560. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96561. */
  96562. type: number;
  96563. /**
  96564. * Defines the related dom event
  96565. */
  96566. event: ClipboardEvent;
  96567. /**
  96568. *Creates an instance of ClipboardInfo.
  96569. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  96570. * @param event Defines the related dom event
  96571. */
  96572. constructor(
  96573. /**
  96574. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96575. */
  96576. type: number,
  96577. /**
  96578. * Defines the related dom event
  96579. */
  96580. event: ClipboardEvent);
  96581. /**
  96582. * Get the clipboard event's type from the keycode.
  96583. * @param keyCode Defines the keyCode for the current keyboard event.
  96584. * @return {number}
  96585. */
  96586. static GetTypeFromCharacter(keyCode: number): number;
  96587. }
  96588. }
  96589. declare module BABYLON {
  96590. /**
  96591. * Class used to represent data loading progression
  96592. */
  96593. export class SceneLoaderProgressEvent {
  96594. /** defines if data length to load can be evaluated */
  96595. readonly lengthComputable: boolean;
  96596. /** defines the loaded data length */
  96597. readonly loaded: number;
  96598. /** defines the data length to load */
  96599. readonly total: number;
  96600. /**
  96601. * Create a new progress event
  96602. * @param lengthComputable defines if data length to load can be evaluated
  96603. * @param loaded defines the loaded data length
  96604. * @param total defines the data length to load
  96605. */
  96606. constructor(
  96607. /** defines if data length to load can be evaluated */
  96608. lengthComputable: boolean,
  96609. /** defines the loaded data length */
  96610. loaded: number,
  96611. /** defines the data length to load */
  96612. total: number);
  96613. /**
  96614. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96615. * @param event defines the source event
  96616. * @returns a new SceneLoaderProgressEvent
  96617. */
  96618. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96619. }
  96620. /**
  96621. * Interface used by SceneLoader plugins to define supported file extensions
  96622. */
  96623. export interface ISceneLoaderPluginExtensions {
  96624. /**
  96625. * Defines the list of supported extensions
  96626. */
  96627. [extension: string]: {
  96628. isBinary: boolean;
  96629. };
  96630. }
  96631. /**
  96632. * Interface used by SceneLoader plugin factory
  96633. */
  96634. export interface ISceneLoaderPluginFactory {
  96635. /**
  96636. * Defines the name of the factory
  96637. */
  96638. name: string;
  96639. /**
  96640. * Function called to create a new plugin
  96641. * @return the new plugin
  96642. */
  96643. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96644. /**
  96645. * Boolean indicating if the plugin can direct load specific data
  96646. */
  96647. canDirectLoad?: (data: string) => boolean;
  96648. }
  96649. /**
  96650. * Interface used to define a SceneLoader plugin
  96651. */
  96652. export interface ISceneLoaderPlugin {
  96653. /**
  96654. * The friendly name of this plugin.
  96655. */
  96656. name: string;
  96657. /**
  96658. * The file extensions supported by this plugin.
  96659. */
  96660. extensions: string | ISceneLoaderPluginExtensions;
  96661. /**
  96662. * Import meshes into a scene.
  96663. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96664. * @param scene The scene to import into
  96665. * @param data The data to import
  96666. * @param rootUrl The root url for scene and resources
  96667. * @param meshes The meshes array to import into
  96668. * @param particleSystems The particle systems array to import into
  96669. * @param skeletons The skeletons array to import into
  96670. * @param onError The callback when import fails
  96671. * @returns True if successful or false otherwise
  96672. */
  96673. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  96674. /**
  96675. * Load into a scene.
  96676. * @param scene The scene to load into
  96677. * @param data The data to import
  96678. * @param rootUrl The root url for scene and resources
  96679. * @param onError The callback when import fails
  96680. * @returns true if successful or false otherwise
  96681. */
  96682. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  96683. /**
  96684. * The callback that returns true if the data can be directly loaded.
  96685. */
  96686. canDirectLoad?: (data: string) => boolean;
  96687. /**
  96688. * The callback that allows custom handling of the root url based on the response url.
  96689. */
  96690. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96691. /**
  96692. * Load into an asset container.
  96693. * @param scene The scene to load into
  96694. * @param data The data to import
  96695. * @param rootUrl The root url for scene and resources
  96696. * @param onError The callback when import fails
  96697. * @returns The loaded asset container
  96698. */
  96699. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  96700. }
  96701. /**
  96702. * Interface used to define an async SceneLoader plugin
  96703. */
  96704. export interface ISceneLoaderPluginAsync {
  96705. /**
  96706. * The friendly name of this plugin.
  96707. */
  96708. name: string;
  96709. /**
  96710. * The file extensions supported by this plugin.
  96711. */
  96712. extensions: string | ISceneLoaderPluginExtensions;
  96713. /**
  96714. * Import meshes into a scene.
  96715. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96716. * @param scene The scene to import into
  96717. * @param data The data to import
  96718. * @param rootUrl The root url for scene and resources
  96719. * @param onProgress The callback when the load progresses
  96720. * @param fileName Defines the name of the file to load
  96721. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  96722. */
  96723. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  96724. meshes: AbstractMesh[];
  96725. particleSystems: IParticleSystem[];
  96726. skeletons: Skeleton[];
  96727. animationGroups: AnimationGroup[];
  96728. }>;
  96729. /**
  96730. * Load into a scene.
  96731. * @param scene The scene to load into
  96732. * @param data The data to import
  96733. * @param rootUrl The root url for scene and resources
  96734. * @param onProgress The callback when the load progresses
  96735. * @param fileName Defines the name of the file to load
  96736. * @returns Nothing
  96737. */
  96738. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  96739. /**
  96740. * The callback that returns true if the data can be directly loaded.
  96741. */
  96742. canDirectLoad?: (data: string) => boolean;
  96743. /**
  96744. * The callback that allows custom handling of the root url based on the response url.
  96745. */
  96746. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96747. /**
  96748. * Load into an asset container.
  96749. * @param scene The scene to load into
  96750. * @param data The data to import
  96751. * @param rootUrl The root url for scene and resources
  96752. * @param onProgress The callback when the load progresses
  96753. * @param fileName Defines the name of the file to load
  96754. * @returns The loaded asset container
  96755. */
  96756. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  96757. }
  96758. /**
  96759. * Class used to load scene from various file formats using registered plugins
  96760. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  96761. */
  96762. export class SceneLoader {
  96763. /**
  96764. * No logging while loading
  96765. */
  96766. static readonly NO_LOGGING: number;
  96767. /**
  96768. * Minimal logging while loading
  96769. */
  96770. static readonly MINIMAL_LOGGING: number;
  96771. /**
  96772. * Summary logging while loading
  96773. */
  96774. static readonly SUMMARY_LOGGING: number;
  96775. /**
  96776. * Detailled logging while loading
  96777. */
  96778. static readonly DETAILED_LOGGING: number;
  96779. /**
  96780. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96781. */
  96782. static ForceFullSceneLoadingForIncremental: boolean;
  96783. /**
  96784. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96785. */
  96786. static ShowLoadingScreen: boolean;
  96787. /**
  96788. * Defines the current logging level (while loading the scene)
  96789. * @ignorenaming
  96790. */
  96791. static loggingLevel: number;
  96792. /**
  96793. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96794. */
  96795. static CleanBoneMatrixWeights: boolean;
  96796. /**
  96797. * Event raised when a plugin is used to load a scene
  96798. */
  96799. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  96800. private static _registeredPlugins;
  96801. private static _getDefaultPlugin;
  96802. private static _getPluginForExtension;
  96803. private static _getPluginForDirectLoad;
  96804. private static _getPluginForFilename;
  96805. private static _getDirectLoad;
  96806. private static _loadData;
  96807. private static _getFileInfo;
  96808. /**
  96809. * Gets a plugin that can load the given extension
  96810. * @param extension defines the extension to load
  96811. * @returns a plugin or null if none works
  96812. */
  96813. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  96814. /**
  96815. * Gets a boolean indicating that the given extension can be loaded
  96816. * @param extension defines the extension to load
  96817. * @returns true if the extension is supported
  96818. */
  96819. static IsPluginForExtensionAvailable(extension: string): boolean;
  96820. /**
  96821. * Adds a new plugin to the list of registered plugins
  96822. * @param plugin defines the plugin to add
  96823. */
  96824. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  96825. /**
  96826. * Import meshes into a scene
  96827. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96828. * @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)
  96829. * @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)
  96830. * @param scene the instance of BABYLON.Scene to append to
  96831. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  96832. * @param onProgress a callback with a progress event for each file being loaded
  96833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96834. * @param pluginExtension the extension used to determine the plugin
  96835. * @returns The loaded plugin
  96836. */
  96837. 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>;
  96838. /**
  96839. * Import meshes into a scene
  96840. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96841. * @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)
  96842. * @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)
  96843. * @param scene the instance of BABYLON.Scene to append to
  96844. * @param onProgress a callback with a progress event for each file being loaded
  96845. * @param pluginExtension the extension used to determine the plugin
  96846. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  96847. */
  96848. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  96849. meshes: AbstractMesh[];
  96850. particleSystems: IParticleSystem[];
  96851. skeletons: Skeleton[];
  96852. animationGroups: AnimationGroup[];
  96853. }>;
  96854. /**
  96855. * Load a scene
  96856. * @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)
  96857. * @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)
  96858. * @param engine is the instance of BABYLON.Engine to use to create the scene
  96859. * @param onSuccess a callback with the scene when import succeeds
  96860. * @param onProgress a callback with a progress event for each file being loaded
  96861. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96862. * @param pluginExtension the extension used to determine the plugin
  96863. * @returns The loaded plugin
  96864. */
  96865. 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>;
  96866. /**
  96867. * Load a scene
  96868. * @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)
  96869. * @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)
  96870. * @param engine is the instance of BABYLON.Engine to use to create the scene
  96871. * @param onProgress a callback with a progress event for each file being loaded
  96872. * @param pluginExtension the extension used to determine the plugin
  96873. * @returns The loaded scene
  96874. */
  96875. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  96876. /**
  96877. * Append a scene
  96878. * @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)
  96879. * @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)
  96880. * @param scene is the instance of BABYLON.Scene to append to
  96881. * @param onSuccess a callback with the scene when import succeeds
  96882. * @param onProgress a callback with a progress event for each file being loaded
  96883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96884. * @param pluginExtension the extension used to determine the plugin
  96885. * @returns The loaded plugin
  96886. */
  96887. 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>;
  96888. /**
  96889. * Append a scene
  96890. * @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)
  96891. * @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)
  96892. * @param scene is the instance of BABYLON.Scene to append to
  96893. * @param onProgress a callback with a progress event for each file being loaded
  96894. * @param pluginExtension the extension used to determine the plugin
  96895. * @returns The given scene
  96896. */
  96897. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  96898. /**
  96899. * Load a scene into an asset container
  96900. * @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)
  96901. * @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)
  96902. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  96903. * @param onSuccess a callback with the scene when import succeeds
  96904. * @param onProgress a callback with a progress event for each file being loaded
  96905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96906. * @param pluginExtension the extension used to determine the plugin
  96907. * @returns The loaded plugin
  96908. */
  96909. 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>;
  96910. /**
  96911. * Load a scene into an asset container
  96912. * @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)
  96913. * @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)
  96914. * @param scene is the instance of Scene to append to
  96915. * @param onProgress a callback with a progress event for each file being loaded
  96916. * @param pluginExtension the extension used to determine the plugin
  96917. * @returns The loaded asset container
  96918. */
  96919. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  96920. }
  96921. }
  96922. declare module BABYLON {
  96923. /**
  96924. * Google Daydream controller
  96925. */
  96926. export class DaydreamController extends WebVRController {
  96927. /**
  96928. * Base Url for the controller model.
  96929. */
  96930. static MODEL_BASE_URL: string;
  96931. /**
  96932. * File name for the controller model.
  96933. */
  96934. static MODEL_FILENAME: string;
  96935. /**
  96936. * Gamepad Id prefix used to identify Daydream Controller.
  96937. */
  96938. static readonly GAMEPAD_ID_PREFIX: string;
  96939. /**
  96940. * Creates a new DaydreamController from a gamepad
  96941. * @param vrGamepad the gamepad that the controller should be created from
  96942. */
  96943. constructor(vrGamepad: any);
  96944. /**
  96945. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  96946. * @param scene scene in which to add meshes
  96947. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  96948. */
  96949. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96950. /**
  96951. * Called once for each button that changed state since the last frame
  96952. * @param buttonIdx Which button index changed
  96953. * @param state New state of the button
  96954. * @param changes Which properties on the state changed since last frame
  96955. */
  96956. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96957. }
  96958. }
  96959. declare module BABYLON {
  96960. /**
  96961. * Gear VR Controller
  96962. */
  96963. export class GearVRController extends WebVRController {
  96964. /**
  96965. * Base Url for the controller model.
  96966. */
  96967. static MODEL_BASE_URL: string;
  96968. /**
  96969. * File name for the controller model.
  96970. */
  96971. static MODEL_FILENAME: string;
  96972. /**
  96973. * Gamepad Id prefix used to identify this controller.
  96974. */
  96975. static readonly GAMEPAD_ID_PREFIX: string;
  96976. private readonly _buttonIndexToObservableNameMap;
  96977. /**
  96978. * Creates a new GearVRController from a gamepad
  96979. * @param vrGamepad the gamepad that the controller should be created from
  96980. */
  96981. constructor(vrGamepad: any);
  96982. /**
  96983. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  96984. * @param scene scene in which to add meshes
  96985. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  96986. */
  96987. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96988. /**
  96989. * Called once for each button that changed state since the last frame
  96990. * @param buttonIdx Which button index changed
  96991. * @param state New state of the button
  96992. * @param changes Which properties on the state changed since last frame
  96993. */
  96994. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96995. }
  96996. }
  96997. declare module BABYLON {
  96998. /**
  96999. * Generic Controller
  97000. */
  97001. export class GenericController extends WebVRController {
  97002. /**
  97003. * Base Url for the controller model.
  97004. */
  97005. static readonly MODEL_BASE_URL: string;
  97006. /**
  97007. * File name for the controller model.
  97008. */
  97009. static readonly MODEL_FILENAME: string;
  97010. /**
  97011. * Creates a new GenericController from a gamepad
  97012. * @param vrGamepad the gamepad that the controller should be created from
  97013. */
  97014. constructor(vrGamepad: any);
  97015. /**
  97016. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97017. * @param scene scene in which to add meshes
  97018. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97019. */
  97020. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97021. /**
  97022. * Called once for each button that changed state since the last frame
  97023. * @param buttonIdx Which button index changed
  97024. * @param state New state of the button
  97025. * @param changes Which properties on the state changed since last frame
  97026. */
  97027. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97028. }
  97029. }
  97030. declare module BABYLON {
  97031. /**
  97032. * Oculus Touch Controller
  97033. */
  97034. export class OculusTouchController extends WebVRController {
  97035. /**
  97036. * Base Url for the controller model.
  97037. */
  97038. static MODEL_BASE_URL: string;
  97039. /**
  97040. * File name for the left controller model.
  97041. */
  97042. static MODEL_LEFT_FILENAME: string;
  97043. /**
  97044. * File name for the right controller model.
  97045. */
  97046. static MODEL_RIGHT_FILENAME: string;
  97047. /**
  97048. * Fired when the secondary trigger on this controller is modified
  97049. */
  97050. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97051. /**
  97052. * Fired when the thumb rest on this controller is modified
  97053. */
  97054. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97055. /**
  97056. * Creates a new OculusTouchController from a gamepad
  97057. * @param vrGamepad the gamepad that the controller should be created from
  97058. */
  97059. constructor(vrGamepad: any);
  97060. /**
  97061. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97062. * @param scene scene in which to add meshes
  97063. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97064. */
  97065. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97066. /**
  97067. * Fired when the A button on this controller is modified
  97068. */
  97069. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97070. /**
  97071. * Fired when the B button on this controller is modified
  97072. */
  97073. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97074. /**
  97075. * Fired when the X button on this controller is modified
  97076. */
  97077. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97078. /**
  97079. * Fired when the Y button on this controller is modified
  97080. */
  97081. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97082. /**
  97083. * Called once for each button that changed state since the last frame
  97084. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97085. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97086. * 2) secondary trigger (same)
  97087. * 3) A (right) X (left), touch, pressed = value
  97088. * 4) B / Y
  97089. * 5) thumb rest
  97090. * @param buttonIdx Which button index changed
  97091. * @param state New state of the button
  97092. * @param changes Which properties on the state changed since last frame
  97093. */
  97094. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97095. }
  97096. }
  97097. declare module BABYLON {
  97098. /**
  97099. * Vive Controller
  97100. */
  97101. export class ViveController extends WebVRController {
  97102. /**
  97103. * Base Url for the controller model.
  97104. */
  97105. static MODEL_BASE_URL: string;
  97106. /**
  97107. * File name for the controller model.
  97108. */
  97109. static MODEL_FILENAME: string;
  97110. /**
  97111. * Creates a new ViveController from a gamepad
  97112. * @param vrGamepad the gamepad that the controller should be created from
  97113. */
  97114. constructor(vrGamepad: any);
  97115. /**
  97116. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97117. * @param scene scene in which to add meshes
  97118. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97119. */
  97120. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97121. /**
  97122. * Fired when the left button on this controller is modified
  97123. */
  97124. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97125. /**
  97126. * Fired when the right button on this controller is modified
  97127. */
  97128. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97129. /**
  97130. * Fired when the menu button on this controller is modified
  97131. */
  97132. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97133. /**
  97134. * Called once for each button that changed state since the last frame
  97135. * Vive mapping:
  97136. * 0: touchpad
  97137. * 1: trigger
  97138. * 2: left AND right buttons
  97139. * 3: menu button
  97140. * @param buttonIdx Which button index changed
  97141. * @param state New state of the button
  97142. * @param changes Which properties on the state changed since last frame
  97143. */
  97144. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97145. }
  97146. }
  97147. declare module BABYLON {
  97148. /**
  97149. * Defines the WindowsMotionController object that the state of the windows motion controller
  97150. */
  97151. export class WindowsMotionController extends WebVRController {
  97152. /**
  97153. * The base url used to load the left and right controller models
  97154. */
  97155. static MODEL_BASE_URL: string;
  97156. /**
  97157. * The name of the left controller model file
  97158. */
  97159. static MODEL_LEFT_FILENAME: string;
  97160. /**
  97161. * The name of the right controller model file
  97162. */
  97163. static MODEL_RIGHT_FILENAME: string;
  97164. /**
  97165. * The controller name prefix for this controller type
  97166. */
  97167. static readonly GAMEPAD_ID_PREFIX: string;
  97168. /**
  97169. * The controller id pattern for this controller type
  97170. */
  97171. private static readonly GAMEPAD_ID_PATTERN;
  97172. private _loadedMeshInfo;
  97173. private readonly _mapping;
  97174. /**
  97175. * Fired when the trackpad on this controller is clicked
  97176. */
  97177. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97178. /**
  97179. * Fired when the trackpad on this controller is modified
  97180. */
  97181. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97182. /**
  97183. * The current x and y values of this controller's trackpad
  97184. */
  97185. trackpad: StickValues;
  97186. /**
  97187. * Creates a new WindowsMotionController from a gamepad
  97188. * @param vrGamepad the gamepad that the controller should be created from
  97189. */
  97190. constructor(vrGamepad: any);
  97191. /**
  97192. * Fired when the trigger on this controller is modified
  97193. */
  97194. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97195. /**
  97196. * Fired when the menu button on this controller is modified
  97197. */
  97198. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97199. /**
  97200. * Fired when the grip button on this controller is modified
  97201. */
  97202. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97203. /**
  97204. * Fired when the thumbstick button on this controller is modified
  97205. */
  97206. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97207. /**
  97208. * Fired when the touchpad button on this controller is modified
  97209. */
  97210. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97211. /**
  97212. * Fired when the touchpad values on this controller are modified
  97213. */
  97214. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97215. private _updateTrackpad;
  97216. /**
  97217. * Called once per frame by the engine.
  97218. */
  97219. update(): void;
  97220. /**
  97221. * Called once for each button that changed state since the last frame
  97222. * @param buttonIdx Which button index changed
  97223. * @param state New state of the button
  97224. * @param changes Which properties on the state changed since last frame
  97225. */
  97226. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97227. /**
  97228. * Moves the buttons on the controller mesh based on their current state
  97229. * @param buttonName the name of the button to move
  97230. * @param buttonValue the value of the button which determines the buttons new position
  97231. */
  97232. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97233. /**
  97234. * Moves the axis on the controller mesh based on its current state
  97235. * @param axis the index of the axis
  97236. * @param axisValue the value of the axis which determines the meshes new position
  97237. * @hidden
  97238. */
  97239. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97240. /**
  97241. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97242. * @param scene scene in which to add meshes
  97243. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97244. */
  97245. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97246. /**
  97247. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97248. * can be transformed by button presses and axes values, based on this._mapping.
  97249. *
  97250. * @param scene scene in which the meshes exist
  97251. * @param meshes list of meshes that make up the controller model to process
  97252. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97253. */
  97254. private processModel;
  97255. private createMeshInfo;
  97256. /**
  97257. * Gets the ray of the controller in the direction the controller is pointing
  97258. * @param length the length the resulting ray should be
  97259. * @returns a ray in the direction the controller is pointing
  97260. */
  97261. getForwardRay(length?: number): Ray;
  97262. /**
  97263. * Disposes of the controller
  97264. */
  97265. dispose(): void;
  97266. }
  97267. }
  97268. declare module BABYLON {
  97269. /**
  97270. * Manager for handling gamepads
  97271. */
  97272. export class GamepadManager {
  97273. private _scene?;
  97274. private _babylonGamepads;
  97275. private _oneGamepadConnected;
  97276. /** @hidden */
  97277. _isMonitoring: boolean;
  97278. private _gamepadEventSupported;
  97279. private _gamepadSupport;
  97280. /**
  97281. * observable to be triggered when the gamepad controller has been connected
  97282. */
  97283. onGamepadConnectedObservable: Observable<Gamepad>;
  97284. /**
  97285. * observable to be triggered when the gamepad controller has been disconnected
  97286. */
  97287. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97288. private _onGamepadConnectedEvent;
  97289. private _onGamepadDisconnectedEvent;
  97290. /**
  97291. * Initializes the gamepad manager
  97292. * @param _scene BabylonJS scene
  97293. */
  97294. constructor(_scene?: Scene | undefined);
  97295. /**
  97296. * The gamepads in the game pad manager
  97297. */
  97298. readonly gamepads: Gamepad[];
  97299. /**
  97300. * Get the gamepad controllers based on type
  97301. * @param type The type of gamepad controller
  97302. * @returns Nullable gamepad
  97303. */
  97304. getGamepadByType(type?: number): Nullable<Gamepad>;
  97305. /**
  97306. * Disposes the gamepad manager
  97307. */
  97308. dispose(): void;
  97309. private _addNewGamepad;
  97310. private _startMonitoringGamepads;
  97311. private _stopMonitoringGamepads;
  97312. /** @hidden */
  97313. _checkGamepadsStatus(): void;
  97314. private _updateGamepadObjects;
  97315. }
  97316. }
  97317. declare module BABYLON {
  97318. interface Scene {
  97319. /** @hidden */
  97320. _gamepadManager: Nullable<GamepadManager>;
  97321. /**
  97322. * Gets the gamepad manager associated with the scene
  97323. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97324. */
  97325. gamepadManager: GamepadManager;
  97326. }
  97327. /**
  97328. * Interface representing a free camera inputs manager
  97329. */
  97330. interface FreeCameraInputsManager {
  97331. /**
  97332. * Adds gamepad input support to the FreeCameraInputsManager.
  97333. * @returns the FreeCameraInputsManager
  97334. */
  97335. addGamepad(): FreeCameraInputsManager;
  97336. }
  97337. /**
  97338. * Interface representing an arc rotate camera inputs manager
  97339. */
  97340. interface ArcRotateCameraInputsManager {
  97341. /**
  97342. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97343. * @returns the camera inputs manager
  97344. */
  97345. addGamepad(): ArcRotateCameraInputsManager;
  97346. }
  97347. /**
  97348. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97349. */
  97350. export class GamepadSystemSceneComponent implements ISceneComponent {
  97351. /**
  97352. * The component name helpfull to identify the component in the list of scene components.
  97353. */
  97354. readonly name: string;
  97355. /**
  97356. * The scene the component belongs to.
  97357. */
  97358. scene: Scene;
  97359. /**
  97360. * Creates a new instance of the component for the given scene
  97361. * @param scene Defines the scene to register the component in
  97362. */
  97363. constructor(scene: Scene);
  97364. /**
  97365. * Registers the component in a given scene
  97366. */
  97367. register(): void;
  97368. /**
  97369. * Rebuilds the elements related to this component in case of
  97370. * context lost for instance.
  97371. */
  97372. rebuild(): void;
  97373. /**
  97374. * Disposes the component and the associated ressources
  97375. */
  97376. dispose(): void;
  97377. private _beforeCameraUpdate;
  97378. }
  97379. }
  97380. declare module BABYLON {
  97381. /**
  97382. * Single axis scale gizmo
  97383. */
  97384. export class AxisScaleGizmo extends Gizmo {
  97385. private _coloredMaterial;
  97386. /**
  97387. * Drag behavior responsible for the gizmos dragging interactions
  97388. */
  97389. dragBehavior: PointerDragBehavior;
  97390. private _pointerObserver;
  97391. /**
  97392. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97393. */
  97394. snapDistance: number;
  97395. /**
  97396. * Event that fires each time the gizmo snaps to a new location.
  97397. * * snapDistance is the the change in distance
  97398. */
  97399. onSnapObservable: Observable<{
  97400. snapDistance: number;
  97401. }>;
  97402. /**
  97403. * If the scaling operation should be done on all axis (default: false)
  97404. */
  97405. uniformScaling: boolean;
  97406. /**
  97407. * Creates an AxisScaleGizmo
  97408. * @param gizmoLayer The utility layer the gizmo will be added to
  97409. * @param dragAxis The axis which the gizmo will be able to scale on
  97410. * @param color The color of the gizmo
  97411. */
  97412. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97413. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97414. /**
  97415. * Disposes of the gizmo
  97416. */
  97417. dispose(): void;
  97418. /**
  97419. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97420. * @param mesh The mesh to replace the default mesh of the gizmo
  97421. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97422. */
  97423. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97424. }
  97425. }
  97426. declare module BABYLON {
  97427. /**
  97428. * Bounding box gizmo
  97429. */
  97430. export class BoundingBoxGizmo extends Gizmo {
  97431. private _lineBoundingBox;
  97432. private _rotateSpheresParent;
  97433. private _scaleBoxesParent;
  97434. private _boundingDimensions;
  97435. private _renderObserver;
  97436. private _pointerObserver;
  97437. private _scaleDragSpeed;
  97438. private _tmpQuaternion;
  97439. private _tmpVector;
  97440. private _tmpRotationMatrix;
  97441. /**
  97442. * 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)
  97443. */
  97444. ignoreChildren: boolean;
  97445. /**
  97446. * 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)
  97447. */
  97448. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97449. /**
  97450. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97451. */
  97452. rotationSphereSize: number;
  97453. /**
  97454. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97455. */
  97456. scaleBoxSize: number;
  97457. /**
  97458. * 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)
  97459. */
  97460. fixedDragMeshScreenSize: boolean;
  97461. /**
  97462. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97463. */
  97464. fixedDragMeshScreenSizeDistanceFactor: number;
  97465. /**
  97466. * Fired when a rotation sphere or scale box is dragged
  97467. */
  97468. onDragStartObservable: Observable<{}>;
  97469. /**
  97470. * Fired when a scale box is dragged
  97471. */
  97472. onScaleBoxDragObservable: Observable<{}>;
  97473. /**
  97474. * Fired when a scale box drag is ended
  97475. */
  97476. onScaleBoxDragEndObservable: Observable<{}>;
  97477. /**
  97478. * Fired when a rotation sphere is dragged
  97479. */
  97480. onRotationSphereDragObservable: Observable<{}>;
  97481. /**
  97482. * Fired when a rotation sphere drag is ended
  97483. */
  97484. onRotationSphereDragEndObservable: Observable<{}>;
  97485. /**
  97486. * 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)
  97487. */
  97488. scalePivot: Nullable<Vector3>;
  97489. private _anchorMesh;
  97490. private _existingMeshScale;
  97491. private _dragMesh;
  97492. private pointerDragBehavior;
  97493. /**
  97494. * Creates an BoundingBoxGizmo
  97495. * @param gizmoLayer The utility layer the gizmo will be added to
  97496. * @param color The color of the gizmo
  97497. */
  97498. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97499. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97500. private _selectNode;
  97501. /**
  97502. * Updates the bounding box information for the Gizmo
  97503. */
  97504. updateBoundingBox(): void;
  97505. private _updateRotationSpheres;
  97506. private _updateScaleBoxes;
  97507. /**
  97508. * Enables rotation on the specified axis and disables rotation on the others
  97509. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97510. */
  97511. setEnabledRotationAxis(axis: string): void;
  97512. /**
  97513. * Enables/disables scaling
  97514. * @param enable if scaling should be enabled
  97515. */
  97516. setEnabledScaling(enable: boolean): void;
  97517. private _updateDummy;
  97518. /**
  97519. * Enables a pointer drag behavior on the bounding box of the gizmo
  97520. */
  97521. enableDragBehavior(): void;
  97522. /**
  97523. * Disposes of the gizmo
  97524. */
  97525. dispose(): void;
  97526. /**
  97527. * 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)
  97528. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97529. * @returns the bounding box mesh with the passed in mesh as a child
  97530. */
  97531. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97532. /**
  97533. * CustomMeshes are not supported by this gizmo
  97534. * @param mesh The mesh to replace the default mesh of the gizmo
  97535. */
  97536. setCustomMesh(mesh: Mesh): void;
  97537. }
  97538. }
  97539. declare module BABYLON {
  97540. /**
  97541. * Single plane rotation gizmo
  97542. */
  97543. export class PlaneRotationGizmo extends Gizmo {
  97544. /**
  97545. * Drag behavior responsible for the gizmos dragging interactions
  97546. */
  97547. dragBehavior: PointerDragBehavior;
  97548. private _pointerObserver;
  97549. /**
  97550. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97551. */
  97552. snapDistance: number;
  97553. /**
  97554. * Event that fires each time the gizmo snaps to a new location.
  97555. * * snapDistance is the the change in distance
  97556. */
  97557. onSnapObservable: Observable<{
  97558. snapDistance: number;
  97559. }>;
  97560. /**
  97561. * Creates a PlaneRotationGizmo
  97562. * @param gizmoLayer The utility layer the gizmo will be added to
  97563. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97564. * @param color The color of the gizmo
  97565. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97566. */
  97567. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97568. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97569. /**
  97570. * Disposes of the gizmo
  97571. */
  97572. dispose(): void;
  97573. }
  97574. }
  97575. declare module BABYLON {
  97576. /**
  97577. * Gizmo that enables rotating a mesh along 3 axis
  97578. */
  97579. export class RotationGizmo extends Gizmo {
  97580. /**
  97581. * Internal gizmo used for interactions on the x axis
  97582. */
  97583. xGizmo: PlaneRotationGizmo;
  97584. /**
  97585. * Internal gizmo used for interactions on the y axis
  97586. */
  97587. yGizmo: PlaneRotationGizmo;
  97588. /**
  97589. * Internal gizmo used for interactions on the z axis
  97590. */
  97591. zGizmo: PlaneRotationGizmo;
  97592. /** Fires an event when any of it's sub gizmos are dragged */
  97593. onDragStartObservable: Observable<{}>;
  97594. /** Fires an event when any of it's sub gizmos are released from dragging */
  97595. onDragEndObservable: Observable<{}>;
  97596. attachedMesh: Nullable<AbstractMesh>;
  97597. /**
  97598. * Creates a RotationGizmo
  97599. * @param gizmoLayer The utility layer the gizmo will be added to
  97600. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97601. */
  97602. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97603. updateGizmoRotationToMatchAttachedMesh: boolean;
  97604. /**
  97605. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97606. */
  97607. snapDistance: number;
  97608. /**
  97609. * Ratio for the scale of the gizmo (Default: 1)
  97610. */
  97611. scaleRatio: number;
  97612. /**
  97613. * Disposes of the gizmo
  97614. */
  97615. dispose(): void;
  97616. /**
  97617. * CustomMeshes are not supported by this gizmo
  97618. * @param mesh The mesh to replace the default mesh of the gizmo
  97619. */
  97620. setCustomMesh(mesh: Mesh): void;
  97621. }
  97622. }
  97623. declare module BABYLON {
  97624. /**
  97625. * Gizmo that enables dragging a mesh along 3 axis
  97626. */
  97627. export class PositionGizmo extends Gizmo {
  97628. /**
  97629. * Internal gizmo used for interactions on the x axis
  97630. */
  97631. xGizmo: AxisDragGizmo;
  97632. /**
  97633. * Internal gizmo used for interactions on the y axis
  97634. */
  97635. yGizmo: AxisDragGizmo;
  97636. /**
  97637. * Internal gizmo used for interactions on the z axis
  97638. */
  97639. zGizmo: AxisDragGizmo;
  97640. /** Fires an event when any of it's sub gizmos are dragged */
  97641. onDragStartObservable: Observable<{}>;
  97642. /** Fires an event when any of it's sub gizmos are released from dragging */
  97643. onDragEndObservable: Observable<{}>;
  97644. attachedMesh: Nullable<AbstractMesh>;
  97645. /**
  97646. * Creates a PositionGizmo
  97647. * @param gizmoLayer The utility layer the gizmo will be added to
  97648. */
  97649. constructor(gizmoLayer?: UtilityLayerRenderer);
  97650. updateGizmoRotationToMatchAttachedMesh: boolean;
  97651. /**
  97652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97653. */
  97654. snapDistance: number;
  97655. /**
  97656. * Ratio for the scale of the gizmo (Default: 1)
  97657. */
  97658. scaleRatio: number;
  97659. /**
  97660. * Disposes of the gizmo
  97661. */
  97662. dispose(): void;
  97663. /**
  97664. * CustomMeshes are not supported by this gizmo
  97665. * @param mesh The mesh to replace the default mesh of the gizmo
  97666. */
  97667. setCustomMesh(mesh: Mesh): void;
  97668. }
  97669. }
  97670. declare module BABYLON {
  97671. /**
  97672. * Class containing static functions to help procedurally build meshes
  97673. */
  97674. export class PolyhedronBuilder {
  97675. /**
  97676. * Creates a polyhedron mesh
  97677. * * 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
  97678. * * The parameter `size` (positive float, default 1) sets the polygon size
  97679. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97680. * * 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`
  97681. * * 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
  97682. * * 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)`)
  97683. * * 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
  97684. * * 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
  97685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97688. * @param name defines the name of the mesh
  97689. * @param options defines the options used to create the mesh
  97690. * @param scene defines the hosting scene
  97691. * @returns the polyhedron mesh
  97692. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  97693. */
  97694. static CreatePolyhedron(name: string, options: {
  97695. type?: number;
  97696. size?: number;
  97697. sizeX?: number;
  97698. sizeY?: number;
  97699. sizeZ?: number;
  97700. custom?: any;
  97701. faceUV?: Vector4[];
  97702. faceColors?: Color4[];
  97703. flat?: boolean;
  97704. updatable?: boolean;
  97705. sideOrientation?: number;
  97706. frontUVs?: Vector4;
  97707. backUVs?: Vector4;
  97708. }, scene: Scene): Mesh;
  97709. }
  97710. }
  97711. declare module BABYLON {
  97712. /**
  97713. * Gizmo that enables scaling a mesh along 3 axis
  97714. */
  97715. export class ScaleGizmo extends Gizmo {
  97716. /**
  97717. * Internal gizmo used for interactions on the x axis
  97718. */
  97719. xGizmo: AxisScaleGizmo;
  97720. /**
  97721. * Internal gizmo used for interactions on the y axis
  97722. */
  97723. yGizmo: AxisScaleGizmo;
  97724. /**
  97725. * Internal gizmo used for interactions on the z axis
  97726. */
  97727. zGizmo: AxisScaleGizmo;
  97728. /**
  97729. * Internal gizmo used to scale all axis equally
  97730. */
  97731. uniformScaleGizmo: AxisScaleGizmo;
  97732. /** Fires an event when any of it's sub gizmos are dragged */
  97733. onDragStartObservable: Observable<{}>;
  97734. /** Fires an event when any of it's sub gizmos are released from dragging */
  97735. onDragEndObservable: Observable<{}>;
  97736. attachedMesh: Nullable<AbstractMesh>;
  97737. /**
  97738. * Creates a ScaleGizmo
  97739. * @param gizmoLayer The utility layer the gizmo will be added to
  97740. */
  97741. constructor(gizmoLayer?: UtilityLayerRenderer);
  97742. updateGizmoRotationToMatchAttachedMesh: boolean;
  97743. /**
  97744. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97745. */
  97746. snapDistance: number;
  97747. /**
  97748. * Ratio for the scale of the gizmo (Default: 1)
  97749. */
  97750. scaleRatio: number;
  97751. /**
  97752. * Disposes of the gizmo
  97753. */
  97754. dispose(): void;
  97755. }
  97756. }
  97757. declare module BABYLON {
  97758. /**
  97759. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  97760. */
  97761. export class GizmoManager implements IDisposable {
  97762. private scene;
  97763. /**
  97764. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  97765. */
  97766. gizmos: {
  97767. positionGizmo: Nullable<PositionGizmo>;
  97768. rotationGizmo: Nullable<RotationGizmo>;
  97769. scaleGizmo: Nullable<ScaleGizmo>;
  97770. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  97771. };
  97772. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  97773. clearGizmoOnEmptyPointerEvent: boolean;
  97774. /** Fires an event when the manager is attached to a mesh */
  97775. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  97776. private _gizmosEnabled;
  97777. private _pointerObserver;
  97778. private _attachedMesh;
  97779. private _boundingBoxColor;
  97780. private _defaultUtilityLayer;
  97781. private _defaultKeepDepthUtilityLayer;
  97782. /**
  97783. * When bounding box gizmo is enabled, this can be used to track drag/end events
  97784. */
  97785. boundingBoxDragBehavior: SixDofDragBehavior;
  97786. /**
  97787. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  97788. */
  97789. attachableMeshes: Nullable<Array<AbstractMesh>>;
  97790. /**
  97791. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  97792. */
  97793. usePointerToAttachGizmos: boolean;
  97794. /**
  97795. * Instatiates a gizmo manager
  97796. * @param scene the scene to overlay the gizmos on top of
  97797. */
  97798. constructor(scene: Scene);
  97799. /**
  97800. * Attaches a set of gizmos to the specified mesh
  97801. * @param mesh The mesh the gizmo's should be attached to
  97802. */
  97803. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  97804. /**
  97805. * If the position gizmo is enabled
  97806. */
  97807. positionGizmoEnabled: boolean;
  97808. /**
  97809. * If the rotation gizmo is enabled
  97810. */
  97811. rotationGizmoEnabled: boolean;
  97812. /**
  97813. * If the scale gizmo is enabled
  97814. */
  97815. scaleGizmoEnabled: boolean;
  97816. /**
  97817. * If the boundingBox gizmo is enabled
  97818. */
  97819. boundingBoxGizmoEnabled: boolean;
  97820. /**
  97821. * Disposes of the gizmo manager
  97822. */
  97823. dispose(): void;
  97824. }
  97825. }
  97826. declare module BABYLON {
  97827. /** @hidden */
  97828. export var backgroundFragmentDeclaration: {
  97829. name: string;
  97830. shader: string;
  97831. };
  97832. }
  97833. declare module BABYLON {
  97834. /** @hidden */
  97835. export var backgroundUboDeclaration: {
  97836. name: string;
  97837. shader: string;
  97838. };
  97839. }
  97840. declare module BABYLON {
  97841. /** @hidden */
  97842. export var backgroundPixelShader: {
  97843. name: string;
  97844. shader: string;
  97845. };
  97846. }
  97847. declare module BABYLON {
  97848. /** @hidden */
  97849. export var backgroundVertexDeclaration: {
  97850. name: string;
  97851. shader: string;
  97852. };
  97853. }
  97854. declare module BABYLON {
  97855. /** @hidden */
  97856. export var backgroundVertexShader: {
  97857. name: string;
  97858. shader: string;
  97859. };
  97860. }
  97861. declare module BABYLON {
  97862. /**
  97863. * Background material used to create an efficient environement around your scene.
  97864. */
  97865. export class BackgroundMaterial extends PushMaterial {
  97866. /**
  97867. * Standard reflectance value at parallel view angle.
  97868. */
  97869. static StandardReflectance0: number;
  97870. /**
  97871. * Standard reflectance value at grazing angle.
  97872. */
  97873. static StandardReflectance90: number;
  97874. protected _primaryColor: Color3;
  97875. /**
  97876. * Key light Color (multiply against the environement texture)
  97877. */
  97878. primaryColor: Color3;
  97879. protected __perceptualColor: Nullable<Color3>;
  97880. /**
  97881. * Experimental Internal Use Only.
  97882. *
  97883. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  97884. * This acts as a helper to set the primary color to a more "human friendly" value.
  97885. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  97886. * output color as close as possible from the chosen value.
  97887. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  97888. * part of lighting setup.)
  97889. */
  97890. _perceptualColor: Nullable<Color3>;
  97891. protected _primaryColorShadowLevel: float;
  97892. /**
  97893. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  97894. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  97895. */
  97896. primaryColorShadowLevel: float;
  97897. protected _primaryColorHighlightLevel: float;
  97898. /**
  97899. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  97900. * The primary color is used at the level chosen to define what the white area would look.
  97901. */
  97902. primaryColorHighlightLevel: float;
  97903. protected _reflectionTexture: Nullable<BaseTexture>;
  97904. /**
  97905. * Reflection Texture used in the material.
  97906. * Should be author in a specific way for the best result (refer to the documentation).
  97907. */
  97908. reflectionTexture: Nullable<BaseTexture>;
  97909. protected _reflectionBlur: float;
  97910. /**
  97911. * Reflection Texture level of blur.
  97912. *
  97913. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  97914. * texture twice.
  97915. */
  97916. reflectionBlur: float;
  97917. protected _diffuseTexture: Nullable<BaseTexture>;
  97918. /**
  97919. * Diffuse Texture used in the material.
  97920. * Should be author in a specific way for the best result (refer to the documentation).
  97921. */
  97922. diffuseTexture: Nullable<BaseTexture>;
  97923. protected _shadowLights: Nullable<IShadowLight[]>;
  97924. /**
  97925. * Specify the list of lights casting shadow on the material.
  97926. * All scene shadow lights will be included if null.
  97927. */
  97928. shadowLights: Nullable<IShadowLight[]>;
  97929. protected _shadowLevel: float;
  97930. /**
  97931. * Helps adjusting the shadow to a softer level if required.
  97932. * 0 means black shadows and 1 means no shadows.
  97933. */
  97934. shadowLevel: float;
  97935. protected _sceneCenter: Vector3;
  97936. /**
  97937. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  97938. * It is usually zero but might be interesting to modify according to your setup.
  97939. */
  97940. sceneCenter: Vector3;
  97941. protected _opacityFresnel: boolean;
  97942. /**
  97943. * This helps specifying that the material is falling off to the sky box at grazing angle.
  97944. * This helps ensuring a nice transition when the camera goes under the ground.
  97945. */
  97946. opacityFresnel: boolean;
  97947. protected _reflectionFresnel: boolean;
  97948. /**
  97949. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  97950. * This helps adding a mirror texture on the ground.
  97951. */
  97952. reflectionFresnel: boolean;
  97953. protected _reflectionFalloffDistance: number;
  97954. /**
  97955. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  97956. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  97957. */
  97958. reflectionFalloffDistance: number;
  97959. protected _reflectionAmount: number;
  97960. /**
  97961. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  97962. */
  97963. reflectionAmount: number;
  97964. protected _reflectionReflectance0: number;
  97965. /**
  97966. * This specifies the weight of the reflection at grazing angle.
  97967. */
  97968. reflectionReflectance0: number;
  97969. protected _reflectionReflectance90: number;
  97970. /**
  97971. * This specifies the weight of the reflection at a perpendicular point of view.
  97972. */
  97973. reflectionReflectance90: number;
  97974. /**
  97975. * Sets the reflection reflectance fresnel values according to the default standard
  97976. * empirically know to work well :-)
  97977. */
  97978. reflectionStandardFresnelWeight: number;
  97979. protected _useRGBColor: boolean;
  97980. /**
  97981. * Helps to directly use the maps channels instead of their level.
  97982. */
  97983. useRGBColor: boolean;
  97984. protected _enableNoise: boolean;
  97985. /**
  97986. * This helps reducing the banding effect that could occur on the background.
  97987. */
  97988. enableNoise: boolean;
  97989. /**
  97990. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  97991. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  97992. * Recommended to be keep at 1.0 except for special cases.
  97993. */
  97994. fovMultiplier: number;
  97995. private _fovMultiplier;
  97996. /**
  97997. * Enable the FOV adjustment feature controlled by fovMultiplier.
  97998. */
  97999. useEquirectangularFOV: boolean;
  98000. private _maxSimultaneousLights;
  98001. /**
  98002. * Number of Simultaneous lights allowed on the material.
  98003. */
  98004. maxSimultaneousLights: int;
  98005. /**
  98006. * Default configuration related to image processing available in the Background Material.
  98007. */
  98008. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98009. /**
  98010. * Keep track of the image processing observer to allow dispose and replace.
  98011. */
  98012. private _imageProcessingObserver;
  98013. /**
  98014. * Attaches a new image processing configuration to the PBR Material.
  98015. * @param configuration (if null the scene configuration will be use)
  98016. */
  98017. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98018. /**
  98019. * Gets the image processing configuration used either in this material.
  98020. */
  98021. /**
  98022. * Sets the Default image processing configuration used either in the this material.
  98023. *
  98024. * If sets to null, the scene one is in use.
  98025. */
  98026. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98027. /**
  98028. * Gets wether the color curves effect is enabled.
  98029. */
  98030. /**
  98031. * Sets wether the color curves effect is enabled.
  98032. */
  98033. cameraColorCurvesEnabled: boolean;
  98034. /**
  98035. * Gets wether the color grading effect is enabled.
  98036. */
  98037. /**
  98038. * Gets wether the color grading effect is enabled.
  98039. */
  98040. cameraColorGradingEnabled: boolean;
  98041. /**
  98042. * Gets wether tonemapping is enabled or not.
  98043. */
  98044. /**
  98045. * Sets wether tonemapping is enabled or not
  98046. */
  98047. cameraToneMappingEnabled: boolean;
  98048. /**
  98049. * The camera exposure used on this material.
  98050. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98051. * This corresponds to a photographic exposure.
  98052. */
  98053. /**
  98054. * The camera exposure used on this material.
  98055. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98056. * This corresponds to a photographic exposure.
  98057. */
  98058. cameraExposure: float;
  98059. /**
  98060. * Gets The camera contrast used on this material.
  98061. */
  98062. /**
  98063. * Sets The camera contrast used on this material.
  98064. */
  98065. cameraContrast: float;
  98066. /**
  98067. * Gets the Color Grading 2D Lookup Texture.
  98068. */
  98069. /**
  98070. * Sets the Color Grading 2D Lookup Texture.
  98071. */
  98072. cameraColorGradingTexture: Nullable<BaseTexture>;
  98073. /**
  98074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98076. * 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;
  98077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98078. */
  98079. /**
  98080. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98081. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98082. * 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;
  98083. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98084. */
  98085. cameraColorCurves: Nullable<ColorCurves>;
  98086. /**
  98087. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98088. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98089. */
  98090. switchToBGR: boolean;
  98091. private _renderTargets;
  98092. private _reflectionControls;
  98093. private _white;
  98094. private _primaryShadowColor;
  98095. private _primaryHighlightColor;
  98096. /**
  98097. * Instantiates a Background Material in the given scene
  98098. * @param name The friendly name of the material
  98099. * @param scene The scene to add the material to
  98100. */
  98101. constructor(name: string, scene: Scene);
  98102. /**
  98103. * Gets a boolean indicating that current material needs to register RTT
  98104. */
  98105. readonly hasRenderTargetTextures: boolean;
  98106. /**
  98107. * The entire material has been created in order to prevent overdraw.
  98108. * @returns false
  98109. */
  98110. needAlphaTesting(): boolean;
  98111. /**
  98112. * The entire material has been created in order to prevent overdraw.
  98113. * @returns true if blending is enable
  98114. */
  98115. needAlphaBlending(): boolean;
  98116. /**
  98117. * Checks wether the material is ready to be rendered for a given mesh.
  98118. * @param mesh The mesh to render
  98119. * @param subMesh The submesh to check against
  98120. * @param useInstances Specify wether or not the material is used with instances
  98121. * @returns true if all the dependencies are ready (Textures, Effects...)
  98122. */
  98123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98124. /**
  98125. * Compute the primary color according to the chosen perceptual color.
  98126. */
  98127. private _computePrimaryColorFromPerceptualColor;
  98128. /**
  98129. * Compute the highlights and shadow colors according to their chosen levels.
  98130. */
  98131. private _computePrimaryColors;
  98132. /**
  98133. * Build the uniform buffer used in the material.
  98134. */
  98135. buildUniformLayout(): void;
  98136. /**
  98137. * Unbind the material.
  98138. */
  98139. unbind(): void;
  98140. /**
  98141. * Bind only the world matrix to the material.
  98142. * @param world The world matrix to bind.
  98143. */
  98144. bindOnlyWorldMatrix(world: Matrix): void;
  98145. /**
  98146. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98147. * @param world The world matrix to bind.
  98148. * @param subMesh The submesh to bind for.
  98149. */
  98150. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98151. /**
  98152. * Dispose the material.
  98153. * @param forceDisposeEffect Force disposal of the associated effect.
  98154. * @param forceDisposeTextures Force disposal of the associated textures.
  98155. */
  98156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98157. /**
  98158. * Clones the material.
  98159. * @param name The cloned name.
  98160. * @returns The cloned material.
  98161. */
  98162. clone(name: string): BackgroundMaterial;
  98163. /**
  98164. * Serializes the current material to its JSON representation.
  98165. * @returns The JSON representation.
  98166. */
  98167. serialize(): any;
  98168. /**
  98169. * Gets the class name of the material
  98170. * @returns "BackgroundMaterial"
  98171. */
  98172. getClassName(): string;
  98173. /**
  98174. * Parse a JSON input to create back a background material.
  98175. * @param source The JSON data to parse
  98176. * @param scene The scene to create the parsed material in
  98177. * @param rootUrl The root url of the assets the material depends upon
  98178. * @returns the instantiated BackgroundMaterial.
  98179. */
  98180. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98181. }
  98182. }
  98183. declare module BABYLON {
  98184. /**
  98185. * Represents the different options available during the creation of
  98186. * a Environment helper.
  98187. *
  98188. * This can control the default ground, skybox and image processing setup of your scene.
  98189. */
  98190. export interface IEnvironmentHelperOptions {
  98191. /**
  98192. * Specifies wether or not to create a ground.
  98193. * True by default.
  98194. */
  98195. createGround: boolean;
  98196. /**
  98197. * Specifies the ground size.
  98198. * 15 by default.
  98199. */
  98200. groundSize: number;
  98201. /**
  98202. * The texture used on the ground for the main color.
  98203. * Comes from the BabylonJS CDN by default.
  98204. *
  98205. * Remarks: Can be either a texture or a url.
  98206. */
  98207. groundTexture: string | BaseTexture;
  98208. /**
  98209. * The color mixed in the ground texture by default.
  98210. * BabylonJS clearColor by default.
  98211. */
  98212. groundColor: Color3;
  98213. /**
  98214. * Specifies the ground opacity.
  98215. * 1 by default.
  98216. */
  98217. groundOpacity: number;
  98218. /**
  98219. * Enables the ground to receive shadows.
  98220. * True by default.
  98221. */
  98222. enableGroundShadow: boolean;
  98223. /**
  98224. * Helps preventing the shadow to be fully black on the ground.
  98225. * 0.5 by default.
  98226. */
  98227. groundShadowLevel: number;
  98228. /**
  98229. * Creates a mirror texture attach to the ground.
  98230. * false by default.
  98231. */
  98232. enableGroundMirror: boolean;
  98233. /**
  98234. * Specifies the ground mirror size ratio.
  98235. * 0.3 by default as the default kernel is 64.
  98236. */
  98237. groundMirrorSizeRatio: number;
  98238. /**
  98239. * Specifies the ground mirror blur kernel size.
  98240. * 64 by default.
  98241. */
  98242. groundMirrorBlurKernel: number;
  98243. /**
  98244. * Specifies the ground mirror visibility amount.
  98245. * 1 by default
  98246. */
  98247. groundMirrorAmount: number;
  98248. /**
  98249. * Specifies the ground mirror reflectance weight.
  98250. * This uses the standard weight of the background material to setup the fresnel effect
  98251. * of the mirror.
  98252. * 1 by default.
  98253. */
  98254. groundMirrorFresnelWeight: number;
  98255. /**
  98256. * Specifies the ground mirror Falloff distance.
  98257. * This can helps reducing the size of the reflection.
  98258. * 0 by Default.
  98259. */
  98260. groundMirrorFallOffDistance: number;
  98261. /**
  98262. * Specifies the ground mirror texture type.
  98263. * Unsigned Int by Default.
  98264. */
  98265. groundMirrorTextureType: number;
  98266. /**
  98267. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98268. * the shown objects.
  98269. */
  98270. groundYBias: number;
  98271. /**
  98272. * Specifies wether or not to create a skybox.
  98273. * True by default.
  98274. */
  98275. createSkybox: boolean;
  98276. /**
  98277. * Specifies the skybox size.
  98278. * 20 by default.
  98279. */
  98280. skyboxSize: number;
  98281. /**
  98282. * The texture used on the skybox for the main color.
  98283. * Comes from the BabylonJS CDN by default.
  98284. *
  98285. * Remarks: Can be either a texture or a url.
  98286. */
  98287. skyboxTexture: string | BaseTexture;
  98288. /**
  98289. * The color mixed in the skybox texture by default.
  98290. * BabylonJS clearColor by default.
  98291. */
  98292. skyboxColor: Color3;
  98293. /**
  98294. * The background rotation around the Y axis of the scene.
  98295. * This helps aligning the key lights of your scene with the background.
  98296. * 0 by default.
  98297. */
  98298. backgroundYRotation: number;
  98299. /**
  98300. * Compute automatically the size of the elements to best fit with the scene.
  98301. */
  98302. sizeAuto: boolean;
  98303. /**
  98304. * Default position of the rootMesh if autoSize is not true.
  98305. */
  98306. rootPosition: Vector3;
  98307. /**
  98308. * Sets up the image processing in the scene.
  98309. * true by default.
  98310. */
  98311. setupImageProcessing: boolean;
  98312. /**
  98313. * The texture used as your environment texture in the scene.
  98314. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98315. *
  98316. * Remarks: Can be either a texture or a url.
  98317. */
  98318. environmentTexture: string | BaseTexture;
  98319. /**
  98320. * The value of the exposure to apply to the scene.
  98321. * 0.6 by default if setupImageProcessing is true.
  98322. */
  98323. cameraExposure: number;
  98324. /**
  98325. * The value of the contrast to apply to the scene.
  98326. * 1.6 by default if setupImageProcessing is true.
  98327. */
  98328. cameraContrast: number;
  98329. /**
  98330. * Specifies wether or not tonemapping should be enabled in the scene.
  98331. * true by default if setupImageProcessing is true.
  98332. */
  98333. toneMappingEnabled: boolean;
  98334. }
  98335. /**
  98336. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98337. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98338. * It also helps with the default setup of your imageProcessing configuration.
  98339. */
  98340. export class EnvironmentHelper {
  98341. /**
  98342. * Default ground texture URL.
  98343. */
  98344. private static _groundTextureCDNUrl;
  98345. /**
  98346. * Default skybox texture URL.
  98347. */
  98348. private static _skyboxTextureCDNUrl;
  98349. /**
  98350. * Default environment texture URL.
  98351. */
  98352. private static _environmentTextureCDNUrl;
  98353. /**
  98354. * Creates the default options for the helper.
  98355. */
  98356. private static _getDefaultOptions;
  98357. private _rootMesh;
  98358. /**
  98359. * Gets the root mesh created by the helper.
  98360. */
  98361. readonly rootMesh: Mesh;
  98362. private _skybox;
  98363. /**
  98364. * Gets the skybox created by the helper.
  98365. */
  98366. readonly skybox: Nullable<Mesh>;
  98367. private _skyboxTexture;
  98368. /**
  98369. * Gets the skybox texture created by the helper.
  98370. */
  98371. readonly skyboxTexture: Nullable<BaseTexture>;
  98372. private _skyboxMaterial;
  98373. /**
  98374. * Gets the skybox material created by the helper.
  98375. */
  98376. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98377. private _ground;
  98378. /**
  98379. * Gets the ground mesh created by the helper.
  98380. */
  98381. readonly ground: Nullable<Mesh>;
  98382. private _groundTexture;
  98383. /**
  98384. * Gets the ground texture created by the helper.
  98385. */
  98386. readonly groundTexture: Nullable<BaseTexture>;
  98387. private _groundMirror;
  98388. /**
  98389. * Gets the ground mirror created by the helper.
  98390. */
  98391. readonly groundMirror: Nullable<MirrorTexture>;
  98392. /**
  98393. * Gets the ground mirror render list to helps pushing the meshes
  98394. * you wish in the ground reflection.
  98395. */
  98396. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98397. private _groundMaterial;
  98398. /**
  98399. * Gets the ground material created by the helper.
  98400. */
  98401. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98402. /**
  98403. * Stores the creation options.
  98404. */
  98405. private readonly _scene;
  98406. private _options;
  98407. /**
  98408. * This observable will be notified with any error during the creation of the environment,
  98409. * mainly texture creation errors.
  98410. */
  98411. onErrorObservable: Observable<{
  98412. message?: string;
  98413. exception?: any;
  98414. }>;
  98415. /**
  98416. * constructor
  98417. * @param options Defines the options we want to customize the helper
  98418. * @param scene The scene to add the material to
  98419. */
  98420. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98421. /**
  98422. * Updates the background according to the new options
  98423. * @param options
  98424. */
  98425. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98426. /**
  98427. * Sets the primary color of all the available elements.
  98428. * @param color the main color to affect to the ground and the background
  98429. */
  98430. setMainColor(color: Color3): void;
  98431. /**
  98432. * Setup the image processing according to the specified options.
  98433. */
  98434. private _setupImageProcessing;
  98435. /**
  98436. * Setup the environment texture according to the specified options.
  98437. */
  98438. private _setupEnvironmentTexture;
  98439. /**
  98440. * Setup the background according to the specified options.
  98441. */
  98442. private _setupBackground;
  98443. /**
  98444. * Get the scene sizes according to the setup.
  98445. */
  98446. private _getSceneSize;
  98447. /**
  98448. * Setup the ground according to the specified options.
  98449. */
  98450. private _setupGround;
  98451. /**
  98452. * Setup the ground material according to the specified options.
  98453. */
  98454. private _setupGroundMaterial;
  98455. /**
  98456. * Setup the ground diffuse texture according to the specified options.
  98457. */
  98458. private _setupGroundDiffuseTexture;
  98459. /**
  98460. * Setup the ground mirror texture according to the specified options.
  98461. */
  98462. private _setupGroundMirrorTexture;
  98463. /**
  98464. * Setup the ground to receive the mirror texture.
  98465. */
  98466. private _setupMirrorInGroundMaterial;
  98467. /**
  98468. * Setup the skybox according to the specified options.
  98469. */
  98470. private _setupSkybox;
  98471. /**
  98472. * Setup the skybox material according to the specified options.
  98473. */
  98474. private _setupSkyboxMaterial;
  98475. /**
  98476. * Setup the skybox reflection texture according to the specified options.
  98477. */
  98478. private _setupSkyboxReflectionTexture;
  98479. private _errorHandler;
  98480. /**
  98481. * Dispose all the elements created by the Helper.
  98482. */
  98483. dispose(): void;
  98484. }
  98485. }
  98486. declare module BABYLON {
  98487. /**
  98488. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98489. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98490. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98491. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98492. */
  98493. export class PhotoDome extends TransformNode {
  98494. private _useDirectMapping;
  98495. /**
  98496. * The texture being displayed on the sphere
  98497. */
  98498. protected _photoTexture: Texture;
  98499. /**
  98500. * Gets or sets the texture being displayed on the sphere
  98501. */
  98502. photoTexture: Texture;
  98503. /**
  98504. * Observable raised when an error occured while loading the 360 image
  98505. */
  98506. onLoadErrorObservable: Observable<string>;
  98507. /**
  98508. * The skybox material
  98509. */
  98510. protected _material: BackgroundMaterial;
  98511. /**
  98512. * The surface used for the skybox
  98513. */
  98514. protected _mesh: Mesh;
  98515. /**
  98516. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98517. * Also see the options.resolution property.
  98518. */
  98519. fovMultiplier: number;
  98520. /**
  98521. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98522. * @param name Element's name, child elements will append suffixes for their own names.
  98523. * @param urlsOfPhoto defines the url of the photo to display
  98524. * @param options defines an object containing optional or exposed sub element properties
  98525. * @param onError defines a callback called when an error occured while loading the texture
  98526. */
  98527. constructor(name: string, urlOfPhoto: string, options: {
  98528. resolution?: number;
  98529. size?: number;
  98530. useDirectMapping?: boolean;
  98531. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98532. /**
  98533. * Releases resources associated with this node.
  98534. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98535. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98536. */
  98537. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98538. }
  98539. }
  98540. declare module BABYLON {
  98541. /**
  98542. * Class used to host texture specific utilities
  98543. */
  98544. export class TextureTools {
  98545. /**
  98546. * Uses the GPU to create a copy texture rescaled at a given size
  98547. * @param texture Texture to copy from
  98548. * @param width defines the desired width
  98549. * @param height defines the desired height
  98550. * @param useBilinearMode defines if bilinear mode has to be used
  98551. * @return the generated texture
  98552. */
  98553. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98554. /**
  98555. * Gets an environment BRDF texture for a given scene
  98556. * @param scene defines the hosting scene
  98557. * @returns the environment BRDF texture
  98558. */
  98559. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98560. private static _environmentBRDFBase64Texture;
  98561. }
  98562. }
  98563. declare module BABYLON {
  98564. /** @hidden */
  98565. export var pbrFragmentDeclaration: {
  98566. name: string;
  98567. shader: string;
  98568. };
  98569. }
  98570. declare module BABYLON {
  98571. /** @hidden */
  98572. export var pbrUboDeclaration: {
  98573. name: string;
  98574. shader: string;
  98575. };
  98576. }
  98577. declare module BABYLON {
  98578. /** @hidden */
  98579. export var pbrFunctions: {
  98580. name: string;
  98581. shader: string;
  98582. };
  98583. }
  98584. declare module BABYLON {
  98585. /** @hidden */
  98586. export var harmonicsFunctions: {
  98587. name: string;
  98588. shader: string;
  98589. };
  98590. }
  98591. declare module BABYLON {
  98592. /** @hidden */
  98593. export var pbrLightFunctions: {
  98594. name: string;
  98595. shader: string;
  98596. };
  98597. }
  98598. declare module BABYLON {
  98599. /** @hidden */
  98600. export var pbrPixelShader: {
  98601. name: string;
  98602. shader: string;
  98603. };
  98604. }
  98605. declare module BABYLON {
  98606. /** @hidden */
  98607. export var pbrVertexDeclaration: {
  98608. name: string;
  98609. shader: string;
  98610. };
  98611. }
  98612. declare module BABYLON {
  98613. /** @hidden */
  98614. export var pbrVertexShader: {
  98615. name: string;
  98616. shader: string;
  98617. };
  98618. }
  98619. declare module BABYLON {
  98620. /**
  98621. * The Physically based material base class of BJS.
  98622. *
  98623. * This offers the main features of a standard PBR material.
  98624. * For more information, please refer to the documentation :
  98625. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98626. */
  98627. export abstract class PBRBaseMaterial extends PushMaterial {
  98628. /**
  98629. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98630. */
  98631. static readonly PBRMATERIAL_OPAQUE: number;
  98632. /**
  98633. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98634. */
  98635. static readonly PBRMATERIAL_ALPHATEST: number;
  98636. /**
  98637. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98638. */
  98639. static readonly PBRMATERIAL_ALPHABLEND: number;
  98640. /**
  98641. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98642. * They are also discarded below the alpha cutoff threshold to improve performances.
  98643. */
  98644. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98645. /**
  98646. * Defines the default value of how much AO map is occluding the analytical lights
  98647. * (point spot...).
  98648. */
  98649. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98650. /**
  98651. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98652. */
  98653. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98654. /**
  98655. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98656. * to enhance interoperability with other engines.
  98657. */
  98658. static readonly LIGHTFALLOFF_GLTF: number;
  98659. /**
  98660. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98661. * to enhance interoperability with other materials.
  98662. */
  98663. static readonly LIGHTFALLOFF_STANDARD: number;
  98664. /**
  98665. * Intensity of the direct lights e.g. the four lights available in your scene.
  98666. * This impacts both the direct diffuse and specular highlights.
  98667. */
  98668. protected _directIntensity: number;
  98669. /**
  98670. * Intensity of the emissive part of the material.
  98671. * This helps controlling the emissive effect without modifying the emissive color.
  98672. */
  98673. protected _emissiveIntensity: number;
  98674. /**
  98675. * Intensity of the environment e.g. how much the environment will light the object
  98676. * either through harmonics for rough material or through the refelction for shiny ones.
  98677. */
  98678. protected _environmentIntensity: number;
  98679. /**
  98680. * This is a special control allowing the reduction of the specular highlights coming from the
  98681. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98682. */
  98683. protected _specularIntensity: number;
  98684. /**
  98685. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98686. */
  98687. private _lightingInfos;
  98688. /**
  98689. * Debug Control allowing disabling the bump map on this material.
  98690. */
  98691. protected _disableBumpMap: boolean;
  98692. /**
  98693. * AKA Diffuse Texture in standard nomenclature.
  98694. */
  98695. protected _albedoTexture: BaseTexture;
  98696. /**
  98697. * AKA Occlusion Texture in other nomenclature.
  98698. */
  98699. protected _ambientTexture: BaseTexture;
  98700. /**
  98701. * AKA Occlusion Texture Intensity in other nomenclature.
  98702. */
  98703. protected _ambientTextureStrength: number;
  98704. /**
  98705. * Defines how much the AO map is occluding the analytical lights (point spot...).
  98706. * 1 means it completely occludes it
  98707. * 0 mean it has no impact
  98708. */
  98709. protected _ambientTextureImpactOnAnalyticalLights: number;
  98710. /**
  98711. * Stores the alpha values in a texture.
  98712. */
  98713. protected _opacityTexture: BaseTexture;
  98714. /**
  98715. * Stores the reflection values in a texture.
  98716. */
  98717. protected _reflectionTexture: BaseTexture;
  98718. /**
  98719. * Stores the refraction values in a texture.
  98720. */
  98721. protected _refractionTexture: BaseTexture;
  98722. /**
  98723. * Stores the emissive values in a texture.
  98724. */
  98725. protected _emissiveTexture: BaseTexture;
  98726. /**
  98727. * AKA Specular texture in other nomenclature.
  98728. */
  98729. protected _reflectivityTexture: BaseTexture;
  98730. /**
  98731. * Used to switch from specular/glossiness to metallic/roughness workflow.
  98732. */
  98733. protected _metallicTexture: BaseTexture;
  98734. /**
  98735. * Specifies the metallic scalar of the metallic/roughness workflow.
  98736. * Can also be used to scale the metalness values of the metallic texture.
  98737. */
  98738. protected _metallic: Nullable<number>;
  98739. /**
  98740. * Specifies the roughness scalar of the metallic/roughness workflow.
  98741. * Can also be used to scale the roughness values of the metallic texture.
  98742. */
  98743. protected _roughness: Nullable<number>;
  98744. /**
  98745. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  98746. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  98747. */
  98748. protected _microSurfaceTexture: BaseTexture;
  98749. /**
  98750. * Stores surface normal data used to displace a mesh in a texture.
  98751. */
  98752. protected _bumpTexture: BaseTexture;
  98753. /**
  98754. * Stores the pre-calculated light information of a mesh in a texture.
  98755. */
  98756. protected _lightmapTexture: BaseTexture;
  98757. /**
  98758. * The color of a material in ambient lighting.
  98759. */
  98760. protected _ambientColor: Color3;
  98761. /**
  98762. * AKA Diffuse Color in other nomenclature.
  98763. */
  98764. protected _albedoColor: Color3;
  98765. /**
  98766. * AKA Specular Color in other nomenclature.
  98767. */
  98768. protected _reflectivityColor: Color3;
  98769. /**
  98770. * The color applied when light is reflected from a material.
  98771. */
  98772. protected _reflectionColor: Color3;
  98773. /**
  98774. * The color applied when light is emitted from a material.
  98775. */
  98776. protected _emissiveColor: Color3;
  98777. /**
  98778. * AKA Glossiness in other nomenclature.
  98779. */
  98780. protected _microSurface: number;
  98781. /**
  98782. * source material index of refraction (IOR)' / 'destination material IOR.
  98783. */
  98784. protected _indexOfRefraction: number;
  98785. /**
  98786. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98787. */
  98788. protected _invertRefractionY: boolean;
  98789. /**
  98790. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98791. * Materials half opaque for instance using refraction could benefit from this control.
  98792. */
  98793. protected _linkRefractionWithTransparency: boolean;
  98794. /**
  98795. * Specifies that the material will use the light map as a show map.
  98796. */
  98797. protected _useLightmapAsShadowmap: boolean;
  98798. /**
  98799. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  98800. * makes the reflect vector face the model (under horizon).
  98801. */
  98802. protected _useHorizonOcclusion: boolean;
  98803. /**
  98804. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  98805. * too much the area relying on ambient texture to define their ambient occlusion.
  98806. */
  98807. protected _useRadianceOcclusion: boolean;
  98808. /**
  98809. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  98810. */
  98811. protected _useAlphaFromAlbedoTexture: boolean;
  98812. /**
  98813. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  98814. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98815. */
  98816. protected _useSpecularOverAlpha: boolean;
  98817. /**
  98818. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  98819. */
  98820. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  98821. /**
  98822. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  98823. */
  98824. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  98825. /**
  98826. * Specifies if the metallic texture contains the roughness information in its green channel.
  98827. */
  98828. protected _useRoughnessFromMetallicTextureGreen: boolean;
  98829. /**
  98830. * Specifies if the metallic texture contains the metallness information in its blue channel.
  98831. */
  98832. protected _useMetallnessFromMetallicTextureBlue: boolean;
  98833. /**
  98834. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  98835. */
  98836. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  98837. /**
  98838. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  98839. */
  98840. protected _useAmbientInGrayScale: boolean;
  98841. /**
  98842. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  98843. * The material will try to infer what glossiness each pixel should be.
  98844. */
  98845. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  98846. /**
  98847. * Defines the falloff type used in this material.
  98848. * It by default is Physical.
  98849. */
  98850. protected _lightFalloff: number;
  98851. /**
  98852. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98853. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98854. */
  98855. protected _useRadianceOverAlpha: boolean;
  98856. /**
  98857. * Allows using an object space normal map (instead of tangent space).
  98858. */
  98859. protected _useObjectSpaceNormalMap: boolean;
  98860. /**
  98861. * Allows using the bump map in parallax mode.
  98862. */
  98863. protected _useParallax: boolean;
  98864. /**
  98865. * Allows using the bump map in parallax occlusion mode.
  98866. */
  98867. protected _useParallaxOcclusion: boolean;
  98868. /**
  98869. * Controls the scale bias of the parallax mode.
  98870. */
  98871. protected _parallaxScaleBias: number;
  98872. /**
  98873. * If sets to true, disables all the lights affecting the material.
  98874. */
  98875. protected _disableLighting: boolean;
  98876. /**
  98877. * Number of Simultaneous lights allowed on the material.
  98878. */
  98879. protected _maxSimultaneousLights: number;
  98880. /**
  98881. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  98882. */
  98883. protected _invertNormalMapX: boolean;
  98884. /**
  98885. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  98886. */
  98887. protected _invertNormalMapY: boolean;
  98888. /**
  98889. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98890. */
  98891. protected _twoSidedLighting: boolean;
  98892. /**
  98893. * Defines the alpha limits in alpha test mode.
  98894. */
  98895. protected _alphaCutOff: number;
  98896. /**
  98897. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  98898. */
  98899. protected _forceAlphaTest: boolean;
  98900. /**
  98901. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98902. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  98903. */
  98904. protected _useAlphaFresnel: boolean;
  98905. /**
  98906. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98907. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  98908. */
  98909. protected _useLinearAlphaFresnel: boolean;
  98910. /**
  98911. * The transparency mode of the material.
  98912. */
  98913. protected _transparencyMode: Nullable<number>;
  98914. /**
  98915. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  98916. * from cos thetav and roughness:
  98917. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  98918. */
  98919. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  98920. /**
  98921. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  98922. */
  98923. protected _forceIrradianceInFragment: boolean;
  98924. /**
  98925. * Force normal to face away from face.
  98926. */
  98927. protected _forceNormalForward: boolean;
  98928. /**
  98929. * Enables specular anti aliasing in the PBR shader.
  98930. * It will both interacts on the Geometry for analytical and IBL lighting.
  98931. * It also prefilter the roughness map based on the bump values.
  98932. */
  98933. protected _enableSpecularAntiAliasing: boolean;
  98934. /**
  98935. * Default configuration related to image processing available in the PBR Material.
  98936. */
  98937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98938. /**
  98939. * Keep track of the image processing observer to allow dispose and replace.
  98940. */
  98941. private _imageProcessingObserver;
  98942. /**
  98943. * Attaches a new image processing configuration to the PBR Material.
  98944. * @param configuration
  98945. */
  98946. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98947. /**
  98948. * Stores the available render targets.
  98949. */
  98950. private _renderTargets;
  98951. /**
  98952. * Sets the global ambient color for the material used in lighting calculations.
  98953. */
  98954. private _globalAmbientColor;
  98955. /**
  98956. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  98957. */
  98958. private _useLogarithmicDepth;
  98959. /**
  98960. * If set to true, no lighting calculations will be applied.
  98961. */
  98962. private _unlit;
  98963. /**
  98964. * Instantiates a new PBRMaterial instance.
  98965. *
  98966. * @param name The material name
  98967. * @param scene The scene the material will be use in.
  98968. */
  98969. constructor(name: string, scene: Scene);
  98970. /**
  98971. * Gets a boolean indicating that current material needs to register RTT
  98972. */
  98973. readonly hasRenderTargetTextures: boolean;
  98974. /**
  98975. * Gets the name of the material class.
  98976. */
  98977. getClassName(): string;
  98978. /**
  98979. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  98980. */
  98981. /**
  98982. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  98983. */
  98984. useLogarithmicDepth: boolean;
  98985. /**
  98986. * Gets the current transparency mode.
  98987. */
  98988. /**
  98989. * Sets the transparency mode of the material.
  98990. *
  98991. * | Value | Type | Description |
  98992. * | ----- | ----------------------------------- | ----------- |
  98993. * | 0 | OPAQUE | |
  98994. * | 1 | ALPHATEST | |
  98995. * | 2 | ALPHABLEND | |
  98996. * | 3 | ALPHATESTANDBLEND | |
  98997. *
  98998. */
  98999. transparencyMode: Nullable<number>;
  99000. /**
  99001. * Returns true if alpha blending should be disabled.
  99002. */
  99003. private readonly _disableAlphaBlending;
  99004. /**
  99005. * Specifies whether or not this material should be rendered in alpha blend mode.
  99006. */
  99007. needAlphaBlending(): boolean;
  99008. /**
  99009. * Specifies if the mesh will require alpha blending.
  99010. * @param mesh - BJS mesh.
  99011. */
  99012. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99013. /**
  99014. * Specifies whether or not this material should be rendered in alpha test mode.
  99015. */
  99016. needAlphaTesting(): boolean;
  99017. /**
  99018. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99019. */
  99020. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99021. /**
  99022. * Gets the texture used for the alpha test.
  99023. */
  99024. getAlphaTestTexture(): BaseTexture;
  99025. /**
  99026. * Specifies that the submesh is ready to be used.
  99027. * @param mesh - BJS mesh.
  99028. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99029. * @param useInstances - Specifies that instances should be used.
  99030. * @returns - boolean indicating that the submesh is ready or not.
  99031. */
  99032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99033. /**
  99034. * Specifies if the material uses metallic roughness workflow.
  99035. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99036. */
  99037. isMetallicWorkflow(): boolean;
  99038. private _prepareEffect;
  99039. private _prepareDefines;
  99040. /**
  99041. * Force shader compilation
  99042. */
  99043. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99044. clipPlane: boolean;
  99045. }>): void;
  99046. /**
  99047. * Initializes the uniform buffer layout for the shader.
  99048. */
  99049. buildUniformLayout(): void;
  99050. /**
  99051. * Unbinds the textures.
  99052. */
  99053. unbind(): void;
  99054. /**
  99055. * Binds the submesh data.
  99056. * @param world - The world matrix.
  99057. * @param mesh - The BJS mesh.
  99058. * @param subMesh - A submesh of the BJS mesh.
  99059. */
  99060. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99061. /**
  99062. * Returns the animatable textures.
  99063. * @returns - Array of animatable textures.
  99064. */
  99065. getAnimatables(): IAnimatable[];
  99066. /**
  99067. * Returns the texture used for reflections.
  99068. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99069. */
  99070. private _getReflectionTexture;
  99071. /**
  99072. * Returns the texture used for refraction or null if none is used.
  99073. * @returns - Refection texture if present. If no refraction texture and refraction
  99074. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99075. */
  99076. private _getRefractionTexture;
  99077. /**
  99078. * Disposes the resources of the material.
  99079. * @param forceDisposeEffect - Forces the disposal of effects.
  99080. * @param forceDisposeTextures - Forces the disposal of all textures.
  99081. */
  99082. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99083. }
  99084. }
  99085. declare module BABYLON {
  99086. /**
  99087. * The Physically based material of BJS.
  99088. *
  99089. * This offers the main features of a standard PBR material.
  99090. * For more information, please refer to the documentation :
  99091. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99092. */
  99093. export class PBRMaterial extends PBRBaseMaterial {
  99094. /**
  99095. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99096. */
  99097. static readonly PBRMATERIAL_OPAQUE: number;
  99098. /**
  99099. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99100. */
  99101. static readonly PBRMATERIAL_ALPHATEST: number;
  99102. /**
  99103. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99104. */
  99105. static readonly PBRMATERIAL_ALPHABLEND: number;
  99106. /**
  99107. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99108. * They are also discarded below the alpha cutoff threshold to improve performances.
  99109. */
  99110. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99111. /**
  99112. * Defines the default value of how much AO map is occluding the analytical lights
  99113. * (point spot...).
  99114. */
  99115. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99116. /**
  99117. * Intensity of the direct lights e.g. the four lights available in your scene.
  99118. * This impacts both the direct diffuse and specular highlights.
  99119. */
  99120. directIntensity: number;
  99121. /**
  99122. * Intensity of the emissive part of the material.
  99123. * This helps controlling the emissive effect without modifying the emissive color.
  99124. */
  99125. emissiveIntensity: number;
  99126. /**
  99127. * Intensity of the environment e.g. how much the environment will light the object
  99128. * either through harmonics for rough material or through the refelction for shiny ones.
  99129. */
  99130. environmentIntensity: number;
  99131. /**
  99132. * This is a special control allowing the reduction of the specular highlights coming from the
  99133. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99134. */
  99135. specularIntensity: number;
  99136. /**
  99137. * Debug Control allowing disabling the bump map on this material.
  99138. */
  99139. disableBumpMap: boolean;
  99140. /**
  99141. * AKA Diffuse Texture in standard nomenclature.
  99142. */
  99143. albedoTexture: BaseTexture;
  99144. /**
  99145. * AKA Occlusion Texture in other nomenclature.
  99146. */
  99147. ambientTexture: BaseTexture;
  99148. /**
  99149. * AKA Occlusion Texture Intensity in other nomenclature.
  99150. */
  99151. ambientTextureStrength: number;
  99152. /**
  99153. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99154. * 1 means it completely occludes it
  99155. * 0 mean it has no impact
  99156. */
  99157. ambientTextureImpactOnAnalyticalLights: number;
  99158. /**
  99159. * Stores the alpha values in a texture.
  99160. */
  99161. opacityTexture: BaseTexture;
  99162. /**
  99163. * Stores the reflection values in a texture.
  99164. */
  99165. reflectionTexture: Nullable<BaseTexture>;
  99166. /**
  99167. * Stores the emissive values in a texture.
  99168. */
  99169. emissiveTexture: BaseTexture;
  99170. /**
  99171. * AKA Specular texture in other nomenclature.
  99172. */
  99173. reflectivityTexture: BaseTexture;
  99174. /**
  99175. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99176. */
  99177. metallicTexture: BaseTexture;
  99178. /**
  99179. * Specifies the metallic scalar of the metallic/roughness workflow.
  99180. * Can also be used to scale the metalness values of the metallic texture.
  99181. */
  99182. metallic: Nullable<number>;
  99183. /**
  99184. * Specifies the roughness scalar of the metallic/roughness workflow.
  99185. * Can also be used to scale the roughness values of the metallic texture.
  99186. */
  99187. roughness: Nullable<number>;
  99188. /**
  99189. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99190. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99191. */
  99192. microSurfaceTexture: BaseTexture;
  99193. /**
  99194. * Stores surface normal data used to displace a mesh in a texture.
  99195. */
  99196. bumpTexture: BaseTexture;
  99197. /**
  99198. * Stores the pre-calculated light information of a mesh in a texture.
  99199. */
  99200. lightmapTexture: BaseTexture;
  99201. /**
  99202. * Stores the refracted light information in a texture.
  99203. */
  99204. refractionTexture: BaseTexture;
  99205. /**
  99206. * The color of a material in ambient lighting.
  99207. */
  99208. ambientColor: Color3;
  99209. /**
  99210. * AKA Diffuse Color in other nomenclature.
  99211. */
  99212. albedoColor: Color3;
  99213. /**
  99214. * AKA Specular Color in other nomenclature.
  99215. */
  99216. reflectivityColor: Color3;
  99217. /**
  99218. * The color reflected from the material.
  99219. */
  99220. reflectionColor: Color3;
  99221. /**
  99222. * The color emitted from the material.
  99223. */
  99224. emissiveColor: Color3;
  99225. /**
  99226. * AKA Glossiness in other nomenclature.
  99227. */
  99228. microSurface: number;
  99229. /**
  99230. * source material index of refraction (IOR)' / 'destination material IOR.
  99231. */
  99232. indexOfRefraction: number;
  99233. /**
  99234. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99235. */
  99236. invertRefractionY: boolean;
  99237. /**
  99238. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99239. * Materials half opaque for instance using refraction could benefit from this control.
  99240. */
  99241. linkRefractionWithTransparency: boolean;
  99242. /**
  99243. * If true, the light map contains occlusion information instead of lighting info.
  99244. */
  99245. useLightmapAsShadowmap: boolean;
  99246. /**
  99247. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99248. */
  99249. useAlphaFromAlbedoTexture: boolean;
  99250. /**
  99251. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99252. */
  99253. forceAlphaTest: boolean;
  99254. /**
  99255. * Defines the alpha limits in alpha test mode.
  99256. */
  99257. alphaCutOff: number;
  99258. /**
  99259. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99260. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99261. */
  99262. useSpecularOverAlpha: boolean;
  99263. /**
  99264. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99265. */
  99266. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99267. /**
  99268. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99269. */
  99270. useRoughnessFromMetallicTextureAlpha: boolean;
  99271. /**
  99272. * Specifies if the metallic texture contains the roughness information in its green channel.
  99273. */
  99274. useRoughnessFromMetallicTextureGreen: boolean;
  99275. /**
  99276. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99277. */
  99278. useMetallnessFromMetallicTextureBlue: boolean;
  99279. /**
  99280. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99281. */
  99282. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99283. /**
  99284. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99285. */
  99286. useAmbientInGrayScale: boolean;
  99287. /**
  99288. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99289. * The material will try to infer what glossiness each pixel should be.
  99290. */
  99291. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99292. /**
  99293. * BJS is using an harcoded light falloff based on a manually sets up range.
  99294. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99295. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99296. */
  99297. /**
  99298. * BJS is using an harcoded light falloff based on a manually sets up range.
  99299. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99300. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99301. */
  99302. usePhysicalLightFalloff: boolean;
  99303. /**
  99304. * In order to support the falloff compatibility with gltf, a special mode has been added
  99305. * to reproduce the gltf light falloff.
  99306. */
  99307. /**
  99308. * In order to support the falloff compatibility with gltf, a special mode has been added
  99309. * to reproduce the gltf light falloff.
  99310. */
  99311. useGLTFLightFalloff: boolean;
  99312. /**
  99313. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99314. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99315. */
  99316. useRadianceOverAlpha: boolean;
  99317. /**
  99318. * Allows using an object space normal map (instead of tangent space).
  99319. */
  99320. useObjectSpaceNormalMap: boolean;
  99321. /**
  99322. * Allows using the bump map in parallax mode.
  99323. */
  99324. useParallax: boolean;
  99325. /**
  99326. * Allows using the bump map in parallax occlusion mode.
  99327. */
  99328. useParallaxOcclusion: boolean;
  99329. /**
  99330. * Controls the scale bias of the parallax mode.
  99331. */
  99332. parallaxScaleBias: number;
  99333. /**
  99334. * If sets to true, disables all the lights affecting the material.
  99335. */
  99336. disableLighting: boolean;
  99337. /**
  99338. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99339. */
  99340. forceIrradianceInFragment: boolean;
  99341. /**
  99342. * Number of Simultaneous lights allowed on the material.
  99343. */
  99344. maxSimultaneousLights: number;
  99345. /**
  99346. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99347. */
  99348. invertNormalMapX: boolean;
  99349. /**
  99350. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99351. */
  99352. invertNormalMapY: boolean;
  99353. /**
  99354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99355. */
  99356. twoSidedLighting: boolean;
  99357. /**
  99358. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99359. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99360. */
  99361. useAlphaFresnel: boolean;
  99362. /**
  99363. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99364. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99365. */
  99366. useLinearAlphaFresnel: boolean;
  99367. /**
  99368. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99369. * And/Or occlude the blended part.
  99370. */
  99371. environmentBRDFTexture: Nullable<BaseTexture>;
  99372. /**
  99373. * Force normal to face away from face.
  99374. */
  99375. forceNormalForward: boolean;
  99376. /**
  99377. * Enables specular anti aliasing in the PBR shader.
  99378. * It will both interacts on the Geometry for analytical and IBL lighting.
  99379. * It also prefilter the roughness map based on the bump values.
  99380. */
  99381. enableSpecularAntiAliasing: boolean;
  99382. /**
  99383. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99384. * makes the reflect vector face the model (under horizon).
  99385. */
  99386. useHorizonOcclusion: boolean;
  99387. /**
  99388. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99389. * too much the area relying on ambient texture to define their ambient occlusion.
  99390. */
  99391. useRadianceOcclusion: boolean;
  99392. /**
  99393. * If set to true, no lighting calculations will be applied.
  99394. */
  99395. unlit: boolean;
  99396. /**
  99397. * Gets the image processing configuration used either in this material.
  99398. */
  99399. /**
  99400. * Sets the Default image processing configuration used either in the this material.
  99401. *
  99402. * If sets to null, the scene one is in use.
  99403. */
  99404. imageProcessingConfiguration: ImageProcessingConfiguration;
  99405. /**
  99406. * Gets wether the color curves effect is enabled.
  99407. */
  99408. /**
  99409. * Sets wether the color curves effect is enabled.
  99410. */
  99411. cameraColorCurvesEnabled: boolean;
  99412. /**
  99413. * Gets wether the color grading effect is enabled.
  99414. */
  99415. /**
  99416. * Gets wether the color grading effect is enabled.
  99417. */
  99418. cameraColorGradingEnabled: boolean;
  99419. /**
  99420. * Gets wether tonemapping is enabled or not.
  99421. */
  99422. /**
  99423. * Sets wether tonemapping is enabled or not
  99424. */
  99425. cameraToneMappingEnabled: boolean;
  99426. /**
  99427. * The camera exposure used on this material.
  99428. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99429. * This corresponds to a photographic exposure.
  99430. */
  99431. /**
  99432. * The camera exposure used on this material.
  99433. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99434. * This corresponds to a photographic exposure.
  99435. */
  99436. cameraExposure: number;
  99437. /**
  99438. * Gets The camera contrast used on this material.
  99439. */
  99440. /**
  99441. * Sets The camera contrast used on this material.
  99442. */
  99443. cameraContrast: number;
  99444. /**
  99445. * Gets the Color Grading 2D Lookup Texture.
  99446. */
  99447. /**
  99448. * Sets the Color Grading 2D Lookup Texture.
  99449. */
  99450. cameraColorGradingTexture: Nullable<BaseTexture>;
  99451. /**
  99452. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99453. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99454. * 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;
  99455. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99456. */
  99457. /**
  99458. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99459. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99460. * 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;
  99461. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99462. */
  99463. cameraColorCurves: Nullable<ColorCurves>;
  99464. /**
  99465. * Instantiates a new PBRMaterial instance.
  99466. *
  99467. * @param name The material name
  99468. * @param scene The scene the material will be use in.
  99469. */
  99470. constructor(name: string, scene: Scene);
  99471. /**
  99472. * Returns the name of this material class.
  99473. */
  99474. getClassName(): string;
  99475. /**
  99476. * Returns an array of the actively used textures.
  99477. * @returns - Array of BaseTextures
  99478. */
  99479. getActiveTextures(): BaseTexture[];
  99480. /**
  99481. * Checks to see if a texture is used in the material.
  99482. * @param texture - Base texture to use.
  99483. * @returns - Boolean specifying if a texture is used in the material.
  99484. */
  99485. hasTexture(texture: BaseTexture): boolean;
  99486. /**
  99487. * Makes a duplicate of the current material.
  99488. * @param name - name to use for the new material.
  99489. */
  99490. clone(name: string): PBRMaterial;
  99491. /**
  99492. * Serializes this PBR Material.
  99493. * @returns - An object with the serialized material.
  99494. */
  99495. serialize(): any;
  99496. /**
  99497. * Parses a PBR Material from a serialized object.
  99498. * @param source - Serialized object.
  99499. * @param scene - BJS scene instance.
  99500. * @param rootUrl - url for the scene object
  99501. * @returns - PBRMaterial
  99502. */
  99503. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99504. }
  99505. }
  99506. declare module BABYLON {
  99507. /** @hidden */
  99508. export var _forceSceneHelpersToBundle: boolean;
  99509. interface Scene {
  99510. /**
  99511. * Creates a default light for the scene.
  99512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99513. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99514. */
  99515. createDefaultLight(replace?: boolean): void;
  99516. /**
  99517. * Creates a default camera for the scene.
  99518. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99519. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99520. * @param replace has default false, when true replaces the active camera in the scene
  99521. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99522. */
  99523. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99524. /**
  99525. * Creates a default camera and a default light.
  99526. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99527. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99528. * @param replace has the default false, when true replaces the active camera/light in the scene
  99529. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99530. */
  99531. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99532. /**
  99533. * Creates a new sky box
  99534. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99535. * @param environmentTexture defines the texture to use as environment texture
  99536. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99537. * @param scale defines the overall scale of the skybox
  99538. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99539. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99540. * @returns a new mesh holding the sky box
  99541. */
  99542. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99543. /**
  99544. * Creates a new environment
  99545. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99546. * @param options defines the options you can use to configure the environment
  99547. * @returns the new EnvironmentHelper
  99548. */
  99549. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99550. /**
  99551. * Creates a new VREXperienceHelper
  99552. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99553. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99554. * @returns a new VREXperienceHelper
  99555. */
  99556. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99557. /**
  99558. * Creates a new XREXperienceHelper
  99559. * @see http://doc.babylonjs.com/how_to/webxr
  99560. * @returns a promise for a new XREXperienceHelper
  99561. */
  99562. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99563. }
  99564. }
  99565. declare module BABYLON {
  99566. /**
  99567. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99568. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99569. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99570. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99571. */
  99572. export class VideoDome extends TransformNode {
  99573. private _useDirectMapping;
  99574. /**
  99575. * The video texture being displayed on the sphere
  99576. */
  99577. protected _videoTexture: VideoTexture;
  99578. /**
  99579. * Gets the video texture being displayed on the sphere
  99580. */
  99581. readonly videoTexture: VideoTexture;
  99582. /**
  99583. * The skybox material
  99584. */
  99585. protected _material: BackgroundMaterial;
  99586. /**
  99587. * The surface used for the skybox
  99588. */
  99589. protected _mesh: Mesh;
  99590. /**
  99591. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99592. * Also see the options.resolution property.
  99593. */
  99594. fovMultiplier: number;
  99595. /**
  99596. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99597. * @param name Element's name, child elements will append suffixes for their own names.
  99598. * @param urlsOrVideo defines the url(s) or the video element to use
  99599. * @param options An object containing optional or exposed sub element properties
  99600. */
  99601. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99602. resolution?: number;
  99603. clickToPlay?: boolean;
  99604. autoPlay?: boolean;
  99605. loop?: boolean;
  99606. size?: number;
  99607. poster?: string;
  99608. useDirectMapping?: boolean;
  99609. }, scene: Scene);
  99610. /**
  99611. * Releases resources associated with this node.
  99612. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99613. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99614. */
  99615. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99616. }
  99617. }
  99618. declare module BABYLON {
  99619. /**
  99620. * This class can be used to get instrumentation data from a Babylon engine
  99621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99622. */
  99623. export class EngineInstrumentation implements IDisposable {
  99624. /**
  99625. * Define the instrumented engine.
  99626. */
  99627. engine: Engine;
  99628. private _captureGPUFrameTime;
  99629. private _gpuFrameTimeToken;
  99630. private _gpuFrameTime;
  99631. private _captureShaderCompilationTime;
  99632. private _shaderCompilationTime;
  99633. private _onBeginFrameObserver;
  99634. private _onEndFrameObserver;
  99635. private _onBeforeShaderCompilationObserver;
  99636. private _onAfterShaderCompilationObserver;
  99637. /**
  99638. * Gets the perf counter used for GPU frame time
  99639. */
  99640. readonly gpuFrameTimeCounter: PerfCounter;
  99641. /**
  99642. * Gets the GPU frame time capture status
  99643. */
  99644. /**
  99645. * Enable or disable the GPU frame time capture
  99646. */
  99647. captureGPUFrameTime: boolean;
  99648. /**
  99649. * Gets the perf counter used for shader compilation time
  99650. */
  99651. readonly shaderCompilationTimeCounter: PerfCounter;
  99652. /**
  99653. * Gets the shader compilation time capture status
  99654. */
  99655. /**
  99656. * Enable or disable the shader compilation time capture
  99657. */
  99658. captureShaderCompilationTime: boolean;
  99659. /**
  99660. * Instantiates a new engine instrumentation.
  99661. * This class can be used to get instrumentation data from a Babylon engine
  99662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99663. * @param engine Defines the engine to instrument
  99664. */
  99665. constructor(
  99666. /**
  99667. * Define the instrumented engine.
  99668. */
  99669. engine: Engine);
  99670. /**
  99671. * Dispose and release associated resources.
  99672. */
  99673. dispose(): void;
  99674. }
  99675. }
  99676. declare module BABYLON {
  99677. /**
  99678. * This class can be used to get instrumentation data from a Babylon engine
  99679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99680. */
  99681. export class SceneInstrumentation implements IDisposable {
  99682. /**
  99683. * Defines the scene to instrument
  99684. */
  99685. scene: Scene;
  99686. private _captureActiveMeshesEvaluationTime;
  99687. private _activeMeshesEvaluationTime;
  99688. private _captureRenderTargetsRenderTime;
  99689. private _renderTargetsRenderTime;
  99690. private _captureFrameTime;
  99691. private _frameTime;
  99692. private _captureRenderTime;
  99693. private _renderTime;
  99694. private _captureInterFrameTime;
  99695. private _interFrameTime;
  99696. private _captureParticlesRenderTime;
  99697. private _particlesRenderTime;
  99698. private _captureSpritesRenderTime;
  99699. private _spritesRenderTime;
  99700. private _capturePhysicsTime;
  99701. private _physicsTime;
  99702. private _captureAnimationsTime;
  99703. private _animationsTime;
  99704. private _captureCameraRenderTime;
  99705. private _cameraRenderTime;
  99706. private _onBeforeActiveMeshesEvaluationObserver;
  99707. private _onAfterActiveMeshesEvaluationObserver;
  99708. private _onBeforeRenderTargetsRenderObserver;
  99709. private _onAfterRenderTargetsRenderObserver;
  99710. private _onAfterRenderObserver;
  99711. private _onBeforeDrawPhaseObserver;
  99712. private _onAfterDrawPhaseObserver;
  99713. private _onBeforeAnimationsObserver;
  99714. private _onBeforeParticlesRenderingObserver;
  99715. private _onAfterParticlesRenderingObserver;
  99716. private _onBeforeSpritesRenderingObserver;
  99717. private _onAfterSpritesRenderingObserver;
  99718. private _onBeforePhysicsObserver;
  99719. private _onAfterPhysicsObserver;
  99720. private _onAfterAnimationsObserver;
  99721. private _onBeforeCameraRenderObserver;
  99722. private _onAfterCameraRenderObserver;
  99723. /**
  99724. * Gets the perf counter used for active meshes evaluation time
  99725. */
  99726. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  99727. /**
  99728. * Gets the active meshes evaluation time capture status
  99729. */
  99730. /**
  99731. * Enable or disable the active meshes evaluation time capture
  99732. */
  99733. captureActiveMeshesEvaluationTime: boolean;
  99734. /**
  99735. * Gets the perf counter used for render targets render time
  99736. */
  99737. readonly renderTargetsRenderTimeCounter: PerfCounter;
  99738. /**
  99739. * Gets the render targets render time capture status
  99740. */
  99741. /**
  99742. * Enable or disable the render targets render time capture
  99743. */
  99744. captureRenderTargetsRenderTime: boolean;
  99745. /**
  99746. * Gets the perf counter used for particles render time
  99747. */
  99748. readonly particlesRenderTimeCounter: PerfCounter;
  99749. /**
  99750. * Gets the particles render time capture status
  99751. */
  99752. /**
  99753. * Enable or disable the particles render time capture
  99754. */
  99755. captureParticlesRenderTime: boolean;
  99756. /**
  99757. * Gets the perf counter used for sprites render time
  99758. */
  99759. readonly spritesRenderTimeCounter: PerfCounter;
  99760. /**
  99761. * Gets the sprites render time capture status
  99762. */
  99763. /**
  99764. * Enable or disable the sprites render time capture
  99765. */
  99766. captureSpritesRenderTime: boolean;
  99767. /**
  99768. * Gets the perf counter used for physics time
  99769. */
  99770. readonly physicsTimeCounter: PerfCounter;
  99771. /**
  99772. * Gets the physics time capture status
  99773. */
  99774. /**
  99775. * Enable or disable the physics time capture
  99776. */
  99777. capturePhysicsTime: boolean;
  99778. /**
  99779. * Gets the perf counter used for animations time
  99780. */
  99781. readonly animationsTimeCounter: PerfCounter;
  99782. /**
  99783. * Gets the animations time capture status
  99784. */
  99785. /**
  99786. * Enable or disable the animations time capture
  99787. */
  99788. captureAnimationsTime: boolean;
  99789. /**
  99790. * Gets the perf counter used for frame time capture
  99791. */
  99792. readonly frameTimeCounter: PerfCounter;
  99793. /**
  99794. * Gets the frame time capture status
  99795. */
  99796. /**
  99797. * Enable or disable the frame time capture
  99798. */
  99799. captureFrameTime: boolean;
  99800. /**
  99801. * Gets the perf counter used for inter-frames time capture
  99802. */
  99803. readonly interFrameTimeCounter: PerfCounter;
  99804. /**
  99805. * Gets the inter-frames time capture status
  99806. */
  99807. /**
  99808. * Enable or disable the inter-frames time capture
  99809. */
  99810. captureInterFrameTime: boolean;
  99811. /**
  99812. * Gets the perf counter used for render time capture
  99813. */
  99814. readonly renderTimeCounter: PerfCounter;
  99815. /**
  99816. * Gets the render time capture status
  99817. */
  99818. /**
  99819. * Enable or disable the render time capture
  99820. */
  99821. captureRenderTime: boolean;
  99822. /**
  99823. * Gets the perf counter used for camera render time capture
  99824. */
  99825. readonly cameraRenderTimeCounter: PerfCounter;
  99826. /**
  99827. * Gets the camera render time capture status
  99828. */
  99829. /**
  99830. * Enable or disable the camera render time capture
  99831. */
  99832. captureCameraRenderTime: boolean;
  99833. /**
  99834. * Gets the perf counter used for draw calls
  99835. */
  99836. readonly drawCallsCounter: PerfCounter;
  99837. /**
  99838. * Gets the perf counter used for texture collisions
  99839. */
  99840. readonly textureCollisionsCounter: PerfCounter;
  99841. /**
  99842. * Instantiates a new scene instrumentation.
  99843. * This class can be used to get instrumentation data from a Babylon engine
  99844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99845. * @param scene Defines the scene to instrument
  99846. */
  99847. constructor(
  99848. /**
  99849. * Defines the scene to instrument
  99850. */
  99851. scene: Scene);
  99852. /**
  99853. * Dispose and release associated resources.
  99854. */
  99855. dispose(): void;
  99856. }
  99857. }
  99858. declare module BABYLON {
  99859. /** @hidden */
  99860. export var glowMapGenerationPixelShader: {
  99861. name: string;
  99862. shader: string;
  99863. };
  99864. }
  99865. declare module BABYLON {
  99866. /** @hidden */
  99867. export var glowMapGenerationVertexShader: {
  99868. name: string;
  99869. shader: string;
  99870. };
  99871. }
  99872. declare module BABYLON {
  99873. /**
  99874. * Effect layer options. This helps customizing the behaviour
  99875. * of the effect layer.
  99876. */
  99877. export interface IEffectLayerOptions {
  99878. /**
  99879. * Multiplication factor apply to the canvas size to compute the render target size
  99880. * used to generated the objects (the smaller the faster).
  99881. */
  99882. mainTextureRatio: number;
  99883. /**
  99884. * Enforces a fixed size texture to ensure effect stability across devices.
  99885. */
  99886. mainTextureFixedSize?: number;
  99887. /**
  99888. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  99889. */
  99890. alphaBlendingMode: number;
  99891. /**
  99892. * The camera attached to the layer.
  99893. */
  99894. camera: Nullable<Camera>;
  99895. /**
  99896. * The rendering group to draw the layer in.
  99897. */
  99898. renderingGroupId: number;
  99899. }
  99900. /**
  99901. * The effect layer Helps adding post process effect blended with the main pass.
  99902. *
  99903. * This can be for instance use to generate glow or higlight effects on the scene.
  99904. *
  99905. * The effect layer class can not be used directly and is intented to inherited from to be
  99906. * customized per effects.
  99907. */
  99908. export abstract class EffectLayer {
  99909. private _vertexBuffers;
  99910. private _indexBuffer;
  99911. private _cachedDefines;
  99912. private _effectLayerMapGenerationEffect;
  99913. private _effectLayerOptions;
  99914. private _mergeEffect;
  99915. protected _scene: Scene;
  99916. protected _engine: Engine;
  99917. protected _maxSize: number;
  99918. protected _mainTextureDesiredSize: ISize;
  99919. protected _mainTexture: RenderTargetTexture;
  99920. protected _shouldRender: boolean;
  99921. protected _postProcesses: PostProcess[];
  99922. protected _textures: BaseTexture[];
  99923. protected _emissiveTextureAndColor: {
  99924. texture: Nullable<BaseTexture>;
  99925. color: Color4;
  99926. };
  99927. /**
  99928. * The name of the layer
  99929. */
  99930. name: string;
  99931. /**
  99932. * The clear color of the texture used to generate the glow map.
  99933. */
  99934. neutralColor: Color4;
  99935. /**
  99936. * Specifies wether the highlight layer is enabled or not.
  99937. */
  99938. isEnabled: boolean;
  99939. /**
  99940. * Gets the camera attached to the layer.
  99941. */
  99942. readonly camera: Nullable<Camera>;
  99943. /**
  99944. * Gets the rendering group id the layer should render in.
  99945. */
  99946. readonly renderingGroupId: number;
  99947. /**
  99948. * An event triggered when the effect layer has been disposed.
  99949. */
  99950. onDisposeObservable: Observable<EffectLayer>;
  99951. /**
  99952. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  99953. */
  99954. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  99955. /**
  99956. * An event triggered when the generated texture is being merged in the scene.
  99957. */
  99958. onBeforeComposeObservable: Observable<EffectLayer>;
  99959. /**
  99960. * An event triggered when the generated texture has been merged in the scene.
  99961. */
  99962. onAfterComposeObservable: Observable<EffectLayer>;
  99963. /**
  99964. * An event triggered when the efffect layer changes its size.
  99965. */
  99966. onSizeChangedObservable: Observable<EffectLayer>;
  99967. /** @hidden */
  99968. static _SceneComponentInitialization: (scene: Scene) => void;
  99969. /**
  99970. * Instantiates a new effect Layer and references it in the scene.
  99971. * @param name The name of the layer
  99972. * @param scene The scene to use the layer in
  99973. */
  99974. constructor(
  99975. /** The Friendly of the effect in the scene */
  99976. name: string, scene: Scene);
  99977. /**
  99978. * Get the effect name of the layer.
  99979. * @return The effect name
  99980. */
  99981. abstract getEffectName(): string;
  99982. /**
  99983. * Checks for the readiness of the element composing the layer.
  99984. * @param subMesh the mesh to check for
  99985. * @param useInstances specify wether or not to use instances to render the mesh
  99986. * @return true if ready otherwise, false
  99987. */
  99988. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  99989. /**
  99990. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  99991. * @returns true if the effect requires stencil during the main canvas render pass.
  99992. */
  99993. abstract needStencil(): boolean;
  99994. /**
  99995. * Create the merge effect. This is the shader use to blit the information back
  99996. * to the main canvas at the end of the scene rendering.
  99997. * @returns The effect containing the shader used to merge the effect on the main canvas
  99998. */
  99999. protected abstract _createMergeEffect(): Effect;
  100000. /**
  100001. * Creates the render target textures and post processes used in the effect layer.
  100002. */
  100003. protected abstract _createTextureAndPostProcesses(): void;
  100004. /**
  100005. * Implementation specific of rendering the generating effect on the main canvas.
  100006. * @param effect The effect used to render through
  100007. */
  100008. protected abstract _internalRender(effect: Effect): void;
  100009. /**
  100010. * Sets the required values for both the emissive texture and and the main color.
  100011. */
  100012. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100013. /**
  100014. * Free any resources and references associated to a mesh.
  100015. * Internal use
  100016. * @param mesh The mesh to free.
  100017. */
  100018. abstract _disposeMesh(mesh: Mesh): void;
  100019. /**
  100020. * Serializes this layer (Glow or Highlight for example)
  100021. * @returns a serialized layer object
  100022. */
  100023. abstract serialize?(): any;
  100024. /**
  100025. * Initializes the effect layer with the required options.
  100026. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100027. */
  100028. protected _init(options: Partial<IEffectLayerOptions>): void;
  100029. /**
  100030. * Generates the index buffer of the full screen quad blending to the main canvas.
  100031. */
  100032. private _generateIndexBuffer;
  100033. /**
  100034. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100035. */
  100036. private _genrateVertexBuffer;
  100037. /**
  100038. * Sets the main texture desired size which is the closest power of two
  100039. * of the engine canvas size.
  100040. */
  100041. private _setMainTextureSize;
  100042. /**
  100043. * Creates the main texture for the effect layer.
  100044. */
  100045. protected _createMainTexture(): void;
  100046. /**
  100047. * Adds specific effects defines.
  100048. * @param defines The defines to add specifics to.
  100049. */
  100050. protected _addCustomEffectDefines(defines: string[]): void;
  100051. /**
  100052. * Checks for the readiness of the element composing the layer.
  100053. * @param subMesh the mesh to check for
  100054. * @param useInstances specify wether or not to use instances to render the mesh
  100055. * @param emissiveTexture the associated emissive texture used to generate the glow
  100056. * @return true if ready otherwise, false
  100057. */
  100058. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100059. /**
  100060. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100061. */
  100062. render(): void;
  100063. /**
  100064. * Determine if a given mesh will be used in the current effect.
  100065. * @param mesh mesh to test
  100066. * @returns true if the mesh will be used
  100067. */
  100068. hasMesh(mesh: AbstractMesh): boolean;
  100069. /**
  100070. * Returns true if the layer contains information to display, otherwise false.
  100071. * @returns true if the glow layer should be rendered
  100072. */
  100073. shouldRender(): boolean;
  100074. /**
  100075. * Returns true if the mesh should render, otherwise false.
  100076. * @param mesh The mesh to render
  100077. * @returns true if it should render otherwise false
  100078. */
  100079. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100080. /**
  100081. * Returns true if the mesh can be rendered, otherwise false.
  100082. * @param mesh The mesh to render
  100083. * @param material The material used on the mesh
  100084. * @returns true if it can be rendered otherwise false
  100085. */
  100086. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100087. /**
  100088. * Returns true if the mesh should render, otherwise false.
  100089. * @param mesh The mesh to render
  100090. * @returns true if it should render otherwise false
  100091. */
  100092. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100093. /**
  100094. * Renders the submesh passed in parameter to the generation map.
  100095. */
  100096. protected _renderSubMesh(subMesh: SubMesh): void;
  100097. /**
  100098. * Rebuild the required buffers.
  100099. * @hidden Internal use only.
  100100. */
  100101. _rebuild(): void;
  100102. /**
  100103. * Dispose only the render target textures and post process.
  100104. */
  100105. private _disposeTextureAndPostProcesses;
  100106. /**
  100107. * Dispose the highlight layer and free resources.
  100108. */
  100109. dispose(): void;
  100110. /**
  100111. * Gets the class name of the effect layer
  100112. * @returns the string with the class name of the effect layer
  100113. */
  100114. getClassName(): string;
  100115. /**
  100116. * Creates an effect layer from parsed effect layer data
  100117. * @param parsedEffectLayer defines effect layer data
  100118. * @param scene defines the current scene
  100119. * @param rootUrl defines the root URL containing the effect layer information
  100120. * @returns a parsed effect Layer
  100121. */
  100122. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100123. }
  100124. }
  100125. declare module BABYLON {
  100126. interface AbstractScene {
  100127. /**
  100128. * The list of effect layers (highlights/glow) added to the scene
  100129. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100130. * @see http://doc.babylonjs.com/how_to/glow_layer
  100131. */
  100132. effectLayers: Array<EffectLayer>;
  100133. /**
  100134. * Removes the given effect layer from this scene.
  100135. * @param toRemove defines the effect layer to remove
  100136. * @returns the index of the removed effect layer
  100137. */
  100138. removeEffectLayer(toRemove: EffectLayer): number;
  100139. /**
  100140. * Adds the given effect layer to this scene
  100141. * @param newEffectLayer defines the effect layer to add
  100142. */
  100143. addEffectLayer(newEffectLayer: EffectLayer): void;
  100144. }
  100145. /**
  100146. * Defines the layer scene component responsible to manage any effect layers
  100147. * in a given scene.
  100148. */
  100149. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100150. /**
  100151. * The component name helpfull to identify the component in the list of scene components.
  100152. */
  100153. readonly name: string;
  100154. /**
  100155. * The scene the component belongs to.
  100156. */
  100157. scene: Scene;
  100158. private _engine;
  100159. private _renderEffects;
  100160. private _needStencil;
  100161. private _previousStencilState;
  100162. /**
  100163. * Creates a new instance of the component for the given scene
  100164. * @param scene Defines the scene to register the component in
  100165. */
  100166. constructor(scene: Scene);
  100167. /**
  100168. * Registers the component in a given scene
  100169. */
  100170. register(): void;
  100171. /**
  100172. * Rebuilds the elements related to this component in case of
  100173. * context lost for instance.
  100174. */
  100175. rebuild(): void;
  100176. /**
  100177. * Serializes the component data to the specified json object
  100178. * @param serializationObject The object to serialize to
  100179. */
  100180. serialize(serializationObject: any): void;
  100181. /**
  100182. * Adds all the element from the container to the scene
  100183. * @param container the container holding the elements
  100184. */
  100185. addFromContainer(container: AbstractScene): void;
  100186. /**
  100187. * Removes all the elements in the container from the scene
  100188. * @param container contains the elements to remove
  100189. */
  100190. removeFromContainer(container: AbstractScene): void;
  100191. /**
  100192. * Disposes the component and the associated ressources.
  100193. */
  100194. dispose(): void;
  100195. private _isReadyForMesh;
  100196. private _renderMainTexture;
  100197. private _setStencil;
  100198. private _setStencilBack;
  100199. private _draw;
  100200. private _drawCamera;
  100201. private _drawRenderingGroup;
  100202. }
  100203. }
  100204. declare module BABYLON {
  100205. /** @hidden */
  100206. export var glowMapMergePixelShader: {
  100207. name: string;
  100208. shader: string;
  100209. };
  100210. }
  100211. declare module BABYLON {
  100212. /** @hidden */
  100213. export var glowMapMergeVertexShader: {
  100214. name: string;
  100215. shader: string;
  100216. };
  100217. }
  100218. declare module BABYLON {
  100219. interface AbstractScene {
  100220. /**
  100221. * Return a the first highlight layer of the scene with a given name.
  100222. * @param name The name of the highlight layer to look for.
  100223. * @return The highlight layer if found otherwise null.
  100224. */
  100225. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100226. }
  100227. /**
  100228. * Glow layer options. This helps customizing the behaviour
  100229. * of the glow layer.
  100230. */
  100231. export interface IGlowLayerOptions {
  100232. /**
  100233. * Multiplication factor apply to the canvas size to compute the render target size
  100234. * used to generated the glowing objects (the smaller the faster).
  100235. */
  100236. mainTextureRatio: number;
  100237. /**
  100238. * Enforces a fixed size texture to ensure resize independant blur.
  100239. */
  100240. mainTextureFixedSize?: number;
  100241. /**
  100242. * How big is the kernel of the blur texture.
  100243. */
  100244. blurKernelSize: number;
  100245. /**
  100246. * The camera attached to the layer.
  100247. */
  100248. camera: Nullable<Camera>;
  100249. /**
  100250. * Enable MSAA by chosing the number of samples.
  100251. */
  100252. mainTextureSamples?: number;
  100253. /**
  100254. * The rendering group to draw the layer in.
  100255. */
  100256. renderingGroupId: number;
  100257. }
  100258. /**
  100259. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100260. *
  100261. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100262. * glowy meshes to your scene.
  100263. *
  100264. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100265. */
  100266. export class GlowLayer extends EffectLayer {
  100267. /**
  100268. * Effect Name of the layer.
  100269. */
  100270. static readonly EffectName: string;
  100271. /**
  100272. * The default blur kernel size used for the glow.
  100273. */
  100274. static DefaultBlurKernelSize: number;
  100275. /**
  100276. * The default texture size ratio used for the glow.
  100277. */
  100278. static DefaultTextureRatio: number;
  100279. /**
  100280. * Sets the kernel size of the blur.
  100281. */
  100282. /**
  100283. * Gets the kernel size of the blur.
  100284. */
  100285. blurKernelSize: number;
  100286. /**
  100287. * Sets the glow intensity.
  100288. */
  100289. /**
  100290. * Gets the glow intensity.
  100291. */
  100292. intensity: number;
  100293. private _options;
  100294. private _intensity;
  100295. private _horizontalBlurPostprocess1;
  100296. private _verticalBlurPostprocess1;
  100297. private _horizontalBlurPostprocess2;
  100298. private _verticalBlurPostprocess2;
  100299. private _blurTexture1;
  100300. private _blurTexture2;
  100301. private _postProcesses1;
  100302. private _postProcesses2;
  100303. private _includedOnlyMeshes;
  100304. private _excludedMeshes;
  100305. /**
  100306. * Callback used to let the user override the color selection on a per mesh basis
  100307. */
  100308. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100309. /**
  100310. * Callback used to let the user override the texture selection on a per mesh basis
  100311. */
  100312. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100313. /**
  100314. * Instantiates a new glow Layer and references it to the scene.
  100315. * @param name The name of the layer
  100316. * @param scene The scene to use the layer in
  100317. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100318. */
  100319. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100320. /**
  100321. * Get the effect name of the layer.
  100322. * @return The effect name
  100323. */
  100324. getEffectName(): string;
  100325. /**
  100326. * Create the merge effect. This is the shader use to blit the information back
  100327. * to the main canvas at the end of the scene rendering.
  100328. */
  100329. protected _createMergeEffect(): Effect;
  100330. /**
  100331. * Creates the render target textures and post processes used in the glow layer.
  100332. */
  100333. protected _createTextureAndPostProcesses(): void;
  100334. /**
  100335. * Checks for the readiness of the element composing the layer.
  100336. * @param subMesh the mesh to check for
  100337. * @param useInstances specify wether or not to use instances to render the mesh
  100338. * @param emissiveTexture the associated emissive texture used to generate the glow
  100339. * @return true if ready otherwise, false
  100340. */
  100341. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100342. /**
  100343. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100344. */
  100345. needStencil(): boolean;
  100346. /**
  100347. * Returns true if the mesh can be rendered, otherwise false.
  100348. * @param mesh The mesh to render
  100349. * @param material The material used on the mesh
  100350. * @returns true if it can be rendered otherwise false
  100351. */
  100352. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100353. /**
  100354. * Implementation specific of rendering the generating effect on the main canvas.
  100355. * @param effect The effect used to render through
  100356. */
  100357. protected _internalRender(effect: Effect): void;
  100358. /**
  100359. * Sets the required values for both the emissive texture and and the main color.
  100360. */
  100361. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100362. /**
  100363. * Returns true if the mesh should render, otherwise false.
  100364. * @param mesh The mesh to render
  100365. * @returns true if it should render otherwise false
  100366. */
  100367. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100368. /**
  100369. * Adds specific effects defines.
  100370. * @param defines The defines to add specifics to.
  100371. */
  100372. protected _addCustomEffectDefines(defines: string[]): void;
  100373. /**
  100374. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100375. * @param mesh The mesh to exclude from the glow layer
  100376. */
  100377. addExcludedMesh(mesh: Mesh): void;
  100378. /**
  100379. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100380. * @param mesh The mesh to remove
  100381. */
  100382. removeExcludedMesh(mesh: Mesh): void;
  100383. /**
  100384. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100385. * @param mesh The mesh to include in the glow layer
  100386. */
  100387. addIncludedOnlyMesh(mesh: Mesh): void;
  100388. /**
  100389. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100390. * @param mesh The mesh to remove
  100391. */
  100392. removeIncludedOnlyMesh(mesh: Mesh): void;
  100393. /**
  100394. * Determine if a given mesh will be used in the glow layer
  100395. * @param mesh The mesh to test
  100396. * @returns true if the mesh will be highlighted by the current glow layer
  100397. */
  100398. hasMesh(mesh: AbstractMesh): boolean;
  100399. /**
  100400. * Free any resources and references associated to a mesh.
  100401. * Internal use
  100402. * @param mesh The mesh to free.
  100403. * @hidden
  100404. */
  100405. _disposeMesh(mesh: Mesh): void;
  100406. /**
  100407. * Gets the class name of the effect layer
  100408. * @returns the string with the class name of the effect layer
  100409. */
  100410. getClassName(): string;
  100411. /**
  100412. * Serializes this glow layer
  100413. * @returns a serialized glow layer object
  100414. */
  100415. serialize(): any;
  100416. /**
  100417. * Creates a Glow Layer from parsed glow layer data
  100418. * @param parsedGlowLayer defines glow layer data
  100419. * @param scene defines the current scene
  100420. * @param rootUrl defines the root URL containing the glow layer information
  100421. * @returns a parsed Glow Layer
  100422. */
  100423. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100424. }
  100425. }
  100426. declare module BABYLON {
  100427. /** @hidden */
  100428. export var glowBlurPostProcessPixelShader: {
  100429. name: string;
  100430. shader: string;
  100431. };
  100432. }
  100433. declare module BABYLON {
  100434. interface AbstractScene {
  100435. /**
  100436. * Return a the first highlight layer of the scene with a given name.
  100437. * @param name The name of the highlight layer to look for.
  100438. * @return The highlight layer if found otherwise null.
  100439. */
  100440. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100441. }
  100442. /**
  100443. * Highlight layer options. This helps customizing the behaviour
  100444. * of the highlight layer.
  100445. */
  100446. export interface IHighlightLayerOptions {
  100447. /**
  100448. * Multiplication factor apply to the canvas size to compute the render target size
  100449. * used to generated the glowing objects (the smaller the faster).
  100450. */
  100451. mainTextureRatio: number;
  100452. /**
  100453. * Enforces a fixed size texture to ensure resize independant blur.
  100454. */
  100455. mainTextureFixedSize?: number;
  100456. /**
  100457. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100458. * of the picture to blur (the smaller the faster).
  100459. */
  100460. blurTextureSizeRatio: number;
  100461. /**
  100462. * How big in texel of the blur texture is the vertical blur.
  100463. */
  100464. blurVerticalSize: number;
  100465. /**
  100466. * How big in texel of the blur texture is the horizontal blur.
  100467. */
  100468. blurHorizontalSize: number;
  100469. /**
  100470. * Alpha blending mode used to apply the blur. Default is combine.
  100471. */
  100472. alphaBlendingMode: number;
  100473. /**
  100474. * The camera attached to the layer.
  100475. */
  100476. camera: Nullable<Camera>;
  100477. /**
  100478. * Should we display highlight as a solid stroke?
  100479. */
  100480. isStroke?: boolean;
  100481. /**
  100482. * The rendering group to draw the layer in.
  100483. */
  100484. renderingGroupId: number;
  100485. }
  100486. /**
  100487. * The highlight layer Helps adding a glow effect around a mesh.
  100488. *
  100489. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100490. * glowy meshes to your scene.
  100491. *
  100492. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100493. */
  100494. export class HighlightLayer extends EffectLayer {
  100495. name: string;
  100496. /**
  100497. * Effect Name of the highlight layer.
  100498. */
  100499. static readonly EffectName: string;
  100500. /**
  100501. * The neutral color used during the preparation of the glow effect.
  100502. * This is black by default as the blend operation is a blend operation.
  100503. */
  100504. static NeutralColor: Color4;
  100505. /**
  100506. * Stencil value used for glowing meshes.
  100507. */
  100508. static GlowingMeshStencilReference: number;
  100509. /**
  100510. * Stencil value used for the other meshes in the scene.
  100511. */
  100512. static NormalMeshStencilReference: number;
  100513. /**
  100514. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100515. */
  100516. innerGlow: boolean;
  100517. /**
  100518. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100519. */
  100520. outerGlow: boolean;
  100521. /**
  100522. * Specifies the horizontal size of the blur.
  100523. */
  100524. /**
  100525. * Gets the horizontal size of the blur.
  100526. */
  100527. blurHorizontalSize: number;
  100528. /**
  100529. * Specifies the vertical size of the blur.
  100530. */
  100531. /**
  100532. * Gets the vertical size of the blur.
  100533. */
  100534. blurVerticalSize: number;
  100535. /**
  100536. * An event triggered when the highlight layer is being blurred.
  100537. */
  100538. onBeforeBlurObservable: Observable<HighlightLayer>;
  100539. /**
  100540. * An event triggered when the highlight layer has been blurred.
  100541. */
  100542. onAfterBlurObservable: Observable<HighlightLayer>;
  100543. private _instanceGlowingMeshStencilReference;
  100544. private _options;
  100545. private _downSamplePostprocess;
  100546. private _horizontalBlurPostprocess;
  100547. private _verticalBlurPostprocess;
  100548. private _blurTexture;
  100549. private _meshes;
  100550. private _excludedMeshes;
  100551. /**
  100552. * Instantiates a new highlight Layer and references it to the scene..
  100553. * @param name The name of the layer
  100554. * @param scene The scene to use the layer in
  100555. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100556. */
  100557. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100558. /**
  100559. * Get the effect name of the layer.
  100560. * @return The effect name
  100561. */
  100562. getEffectName(): string;
  100563. /**
  100564. * Create the merge effect. This is the shader use to blit the information back
  100565. * to the main canvas at the end of the scene rendering.
  100566. */
  100567. protected _createMergeEffect(): Effect;
  100568. /**
  100569. * Creates the render target textures and post processes used in the highlight layer.
  100570. */
  100571. protected _createTextureAndPostProcesses(): void;
  100572. /**
  100573. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100574. */
  100575. needStencil(): boolean;
  100576. /**
  100577. * Checks for the readiness of the element composing the layer.
  100578. * @param subMesh the mesh to check for
  100579. * @param useInstances specify wether or not to use instances to render the mesh
  100580. * @param emissiveTexture the associated emissive texture used to generate the glow
  100581. * @return true if ready otherwise, false
  100582. */
  100583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100584. /**
  100585. * Implementation specific of rendering the generating effect on the main canvas.
  100586. * @param effect The effect used to render through
  100587. */
  100588. protected _internalRender(effect: Effect): void;
  100589. /**
  100590. * Returns true if the layer contains information to display, otherwise false.
  100591. */
  100592. shouldRender(): boolean;
  100593. /**
  100594. * Returns true if the mesh should render, otherwise false.
  100595. * @param mesh The mesh to render
  100596. * @returns true if it should render otherwise false
  100597. */
  100598. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100599. /**
  100600. * Sets the required values for both the emissive texture and and the main color.
  100601. */
  100602. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100603. /**
  100604. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100605. * @param mesh The mesh to exclude from the highlight layer
  100606. */
  100607. addExcludedMesh(mesh: Mesh): void;
  100608. /**
  100609. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100610. * @param mesh The mesh to highlight
  100611. */
  100612. removeExcludedMesh(mesh: Mesh): void;
  100613. /**
  100614. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100615. * @param mesh mesh to test
  100616. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100617. */
  100618. hasMesh(mesh: AbstractMesh): boolean;
  100619. /**
  100620. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100621. * @param mesh The mesh to highlight
  100622. * @param color The color of the highlight
  100623. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100624. */
  100625. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100626. /**
  100627. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100628. * @param mesh The mesh to highlight
  100629. */
  100630. removeMesh(mesh: Mesh): void;
  100631. /**
  100632. * Force the stencil to the normal expected value for none glowing parts
  100633. */
  100634. private _defaultStencilReference;
  100635. /**
  100636. * Free any resources and references associated to a mesh.
  100637. * Internal use
  100638. * @param mesh The mesh to free.
  100639. * @hidden
  100640. */
  100641. _disposeMesh(mesh: Mesh): void;
  100642. /**
  100643. * Dispose the highlight layer and free resources.
  100644. */
  100645. dispose(): void;
  100646. /**
  100647. * Gets the class name of the effect layer
  100648. * @returns the string with the class name of the effect layer
  100649. */
  100650. getClassName(): string;
  100651. /**
  100652. * Serializes this Highlight layer
  100653. * @returns a serialized Highlight layer object
  100654. */
  100655. serialize(): any;
  100656. /**
  100657. * Creates a Highlight layer from parsed Highlight layer data
  100658. * @param parsedHightlightLayer defines the Highlight layer data
  100659. * @param scene defines the current scene
  100660. * @param rootUrl defines the root URL containing the Highlight layer information
  100661. * @returns a parsed Highlight layer
  100662. */
  100663. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100664. }
  100665. }
  100666. declare module BABYLON {
  100667. /** @hidden */
  100668. export var lensFlarePixelShader: {
  100669. name: string;
  100670. shader: string;
  100671. };
  100672. }
  100673. declare module BABYLON {
  100674. /** @hidden */
  100675. export var lensFlareVertexShader: {
  100676. name: string;
  100677. shader: string;
  100678. };
  100679. }
  100680. declare module BABYLON {
  100681. /**
  100682. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100683. * It is usually composed of several `lensFlare`.
  100684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100685. */
  100686. export class LensFlareSystem {
  100687. /**
  100688. * Define the name of the lens flare system
  100689. */
  100690. name: string;
  100691. /**
  100692. * List of lens flares used in this system.
  100693. */
  100694. lensFlares: LensFlare[];
  100695. /**
  100696. * Define a limit from the border the lens flare can be visible.
  100697. */
  100698. borderLimit: number;
  100699. /**
  100700. * Define a viewport border we do not want to see the lens flare in.
  100701. */
  100702. viewportBorder: number;
  100703. /**
  100704. * Define a predicate which could limit the list of meshes able to occlude the effect.
  100705. */
  100706. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  100707. /**
  100708. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  100709. */
  100710. layerMask: number;
  100711. /**
  100712. * Define the id of the lens flare system in the scene.
  100713. * (equal to name by default)
  100714. */
  100715. id: string;
  100716. private _scene;
  100717. private _emitter;
  100718. private _vertexBuffers;
  100719. private _indexBuffer;
  100720. private _effect;
  100721. private _positionX;
  100722. private _positionY;
  100723. private _isEnabled;
  100724. /** @hidden */
  100725. static _SceneComponentInitialization: (scene: Scene) => void;
  100726. /**
  100727. * Instantiates a lens flare system.
  100728. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100729. * It is usually composed of several `lensFlare`.
  100730. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100731. * @param name Define the name of the lens flare system in the scene
  100732. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  100733. * @param scene Define the scene the lens flare system belongs to
  100734. */
  100735. constructor(
  100736. /**
  100737. * Define the name of the lens flare system
  100738. */
  100739. name: string, emitter: any, scene: Scene);
  100740. /**
  100741. * Define if the lens flare system is enabled.
  100742. */
  100743. isEnabled: boolean;
  100744. /**
  100745. * Get the scene the effects belongs to.
  100746. * @returns the scene holding the lens flare system
  100747. */
  100748. getScene(): Scene;
  100749. /**
  100750. * Get the emitter of the lens flare system.
  100751. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100752. * @returns the emitter of the lens flare system
  100753. */
  100754. getEmitter(): any;
  100755. /**
  100756. * Set the emitter of the lens flare system.
  100757. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100758. * @param newEmitter Define the new emitter of the system
  100759. */
  100760. setEmitter(newEmitter: any): void;
  100761. /**
  100762. * Get the lens flare system emitter position.
  100763. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  100764. * @returns the position
  100765. */
  100766. getEmitterPosition(): Vector3;
  100767. /**
  100768. * @hidden
  100769. */
  100770. computeEffectivePosition(globalViewport: Viewport): boolean;
  100771. /** @hidden */
  100772. _isVisible(): boolean;
  100773. /**
  100774. * @hidden
  100775. */
  100776. render(): boolean;
  100777. /**
  100778. * Dispose and release the lens flare with its associated resources.
  100779. */
  100780. dispose(): void;
  100781. /**
  100782. * Parse a lens flare system from a JSON repressentation
  100783. * @param parsedLensFlareSystem Define the JSON to parse
  100784. * @param scene Define the scene the parsed system should be instantiated in
  100785. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  100786. * @returns the parsed system
  100787. */
  100788. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  100789. /**
  100790. * Serialize the current Lens Flare System into a JSON representation.
  100791. * @returns the serialized JSON
  100792. */
  100793. serialize(): any;
  100794. }
  100795. }
  100796. declare module BABYLON {
  100797. /**
  100798. * This represents one of the lens effect in a `lensFlareSystem`.
  100799. * It controls one of the indiviual texture used in the effect.
  100800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100801. */
  100802. export class LensFlare {
  100803. /**
  100804. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100805. */
  100806. size: number;
  100807. /**
  100808. * 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.
  100809. */
  100810. position: number;
  100811. /**
  100812. * Define the lens color.
  100813. */
  100814. color: Color3;
  100815. /**
  100816. * Define the lens texture.
  100817. */
  100818. texture: Nullable<Texture>;
  100819. /**
  100820. * Define the alpha mode to render this particular lens.
  100821. */
  100822. alphaMode: number;
  100823. private _system;
  100824. /**
  100825. * Creates a new Lens Flare.
  100826. * This represents one of the lens effect in a `lensFlareSystem`.
  100827. * It controls one of the indiviual texture used in the effect.
  100828. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100829. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  100830. * @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.
  100831. * @param color Define the lens color
  100832. * @param imgUrl Define the lens texture url
  100833. * @param system Define the `lensFlareSystem` this flare is part of
  100834. * @returns The newly created Lens Flare
  100835. */
  100836. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  100837. /**
  100838. * Instantiates a new Lens Flare.
  100839. * This represents one of the lens effect in a `lensFlareSystem`.
  100840. * It controls one of the indiviual texture used in the effect.
  100841. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100842. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  100843. * @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.
  100844. * @param color Define the lens color
  100845. * @param imgUrl Define the lens texture url
  100846. * @param system Define the `lensFlareSystem` this flare is part of
  100847. */
  100848. constructor(
  100849. /**
  100850. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100851. */
  100852. size: number,
  100853. /**
  100854. * 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.
  100855. */
  100856. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  100857. /**
  100858. * Dispose and release the lens flare with its associated resources.
  100859. */
  100860. dispose(): void;
  100861. }
  100862. }
  100863. declare module BABYLON {
  100864. interface AbstractScene {
  100865. /**
  100866. * The list of lens flare system added to the scene
  100867. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100868. */
  100869. lensFlareSystems: Array<LensFlareSystem>;
  100870. /**
  100871. * Removes the given lens flare system from this scene.
  100872. * @param toRemove The lens flare system to remove
  100873. * @returns The index of the removed lens flare system
  100874. */
  100875. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  100876. /**
  100877. * Adds the given lens flare system to this scene
  100878. * @param newLensFlareSystem The lens flare system to add
  100879. */
  100880. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  100881. /**
  100882. * Gets a lens flare system using its name
  100883. * @param name defines the name to look for
  100884. * @returns the lens flare system or null if not found
  100885. */
  100886. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  100887. /**
  100888. * Gets a lens flare system using its id
  100889. * @param id defines the id to look for
  100890. * @returns the lens flare system or null if not found
  100891. */
  100892. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  100893. }
  100894. /**
  100895. * Defines the lens flare scene component responsible to manage any lens flares
  100896. * in a given scene.
  100897. */
  100898. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  100899. /**
  100900. * The component name helpfull to identify the component in the list of scene components.
  100901. */
  100902. readonly name: string;
  100903. /**
  100904. * The scene the component belongs to.
  100905. */
  100906. scene: Scene;
  100907. /**
  100908. * Creates a new instance of the component for the given scene
  100909. * @param scene Defines the scene to register the component in
  100910. */
  100911. constructor(scene: Scene);
  100912. /**
  100913. * Registers the component in a given scene
  100914. */
  100915. register(): void;
  100916. /**
  100917. * Rebuilds the elements related to this component in case of
  100918. * context lost for instance.
  100919. */
  100920. rebuild(): void;
  100921. /**
  100922. * Adds all the element from the container to the scene
  100923. * @param container the container holding the elements
  100924. */
  100925. addFromContainer(container: AbstractScene): void;
  100926. /**
  100927. * Removes all the elements in the container from the scene
  100928. * @param container contains the elements to remove
  100929. */
  100930. removeFromContainer(container: AbstractScene): void;
  100931. /**
  100932. * Serializes the component data to the specified json object
  100933. * @param serializationObject The object to serialize to
  100934. */
  100935. serialize(serializationObject: any): void;
  100936. /**
  100937. * Disposes the component and the associated ressources.
  100938. */
  100939. dispose(): void;
  100940. private _draw;
  100941. }
  100942. }
  100943. declare module BABYLON {
  100944. /**
  100945. * Defines the shadow generator component responsible to manage any shadow generators
  100946. * in a given scene.
  100947. */
  100948. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  100949. /**
  100950. * The component name helpfull to identify the component in the list of scene components.
  100951. */
  100952. readonly name: string;
  100953. /**
  100954. * The scene the component belongs to.
  100955. */
  100956. scene: Scene;
  100957. /**
  100958. * Creates a new instance of the component for the given scene
  100959. * @param scene Defines the scene to register the component in
  100960. */
  100961. constructor(scene: Scene);
  100962. /**
  100963. * Registers the component in a given scene
  100964. */
  100965. register(): void;
  100966. /**
  100967. * Rebuilds the elements related to this component in case of
  100968. * context lost for instance.
  100969. */
  100970. rebuild(): void;
  100971. /**
  100972. * Serializes the component data to the specified json object
  100973. * @param serializationObject The object to serialize to
  100974. */
  100975. serialize(serializationObject: any): void;
  100976. /**
  100977. * Adds all the element from the container to the scene
  100978. * @param container the container holding the elements
  100979. */
  100980. addFromContainer(container: AbstractScene): void;
  100981. /**
  100982. * Removes all the elements in the container from the scene
  100983. * @param container contains the elements to remove
  100984. */
  100985. removeFromContainer(container: AbstractScene): void;
  100986. /**
  100987. * Rebuilds the elements related to this component in case of
  100988. * context lost for instance.
  100989. */
  100990. dispose(): void;
  100991. private _gatherRenderTargets;
  100992. }
  100993. }
  100994. declare module BABYLON {
  100995. /**
  100996. * A directional light is defined by a direction (what a surprise!).
  100997. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  100998. * 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.
  100999. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101000. */
  101001. export class DirectionalLight extends ShadowLight {
  101002. private _shadowFrustumSize;
  101003. /**
  101004. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101005. */
  101006. /**
  101007. * Specifies a fix frustum size for the shadow generation.
  101008. */
  101009. shadowFrustumSize: number;
  101010. private _shadowOrthoScale;
  101011. /**
  101012. * Gets the shadow projection scale against the optimal computed one.
  101013. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101014. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101015. */
  101016. /**
  101017. * Sets the shadow projection scale against the optimal computed one.
  101018. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101019. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101020. */
  101021. shadowOrthoScale: number;
  101022. /**
  101023. * Automatically compute the projection matrix to best fit (including all the casters)
  101024. * on each frame.
  101025. */
  101026. autoUpdateExtends: boolean;
  101027. private _orthoLeft;
  101028. private _orthoRight;
  101029. private _orthoTop;
  101030. private _orthoBottom;
  101031. /**
  101032. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101033. * The directional light is emitted from everywhere in the given direction.
  101034. * It can cast shadows.
  101035. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101036. * @param name The friendly name of the light
  101037. * @param direction The direction of the light
  101038. * @param scene The scene the light belongs to
  101039. */
  101040. constructor(name: string, direction: Vector3, scene: Scene);
  101041. /**
  101042. * Returns the string "DirectionalLight".
  101043. * @return The class name
  101044. */
  101045. getClassName(): string;
  101046. /**
  101047. * Returns the integer 1.
  101048. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101049. */
  101050. getTypeID(): number;
  101051. /**
  101052. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101053. * Returns the DirectionalLight Shadow projection matrix.
  101054. */
  101055. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101056. /**
  101057. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101058. * Returns the DirectionalLight Shadow projection matrix.
  101059. */
  101060. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101061. /**
  101062. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101063. * Returns the DirectionalLight Shadow projection matrix.
  101064. */
  101065. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101066. protected _buildUniformLayout(): void;
  101067. /**
  101068. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101069. * @param effect The effect to update
  101070. * @param lightIndex The index of the light in the effect to update
  101071. * @returns The directional light
  101072. */
  101073. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101074. /**
  101075. * Gets the minZ used for shadow according to both the scene and the light.
  101076. *
  101077. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101078. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101079. * @param activeCamera The camera we are returning the min for
  101080. * @returns the depth min z
  101081. */
  101082. getDepthMinZ(activeCamera: Camera): number;
  101083. /**
  101084. * Gets the maxZ used for shadow according to both the scene and the light.
  101085. *
  101086. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101087. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101088. * @param activeCamera The camera we are returning the max for
  101089. * @returns the depth max z
  101090. */
  101091. getDepthMaxZ(activeCamera: Camera): number;
  101092. /**
  101093. * Prepares the list of defines specific to the light type.
  101094. * @param defines the list of defines
  101095. * @param lightIndex defines the index of the light for the effect
  101096. */
  101097. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101098. }
  101099. }
  101100. declare module BABYLON {
  101101. /**
  101102. * A point light is a light defined by an unique point in world space.
  101103. * The light is emitted in every direction from this point.
  101104. * A good example of a point light is a standard light bulb.
  101105. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101106. */
  101107. export class PointLight extends ShadowLight {
  101108. private _shadowAngle;
  101109. /**
  101110. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101111. * This specifies what angle the shadow will use to be created.
  101112. *
  101113. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101114. */
  101115. /**
  101116. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101117. * This specifies what angle the shadow will use to be created.
  101118. *
  101119. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101120. */
  101121. shadowAngle: number;
  101122. /**
  101123. * Gets the direction if it has been set.
  101124. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101125. */
  101126. /**
  101127. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101128. */
  101129. direction: Vector3;
  101130. /**
  101131. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101132. * A PointLight emits the light in every direction.
  101133. * It can cast shadows.
  101134. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101135. * ```javascript
  101136. * var pointLight = new PointLight("pl", camera.position, scene);
  101137. * ```
  101138. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101139. * @param name The light friendly name
  101140. * @param position The position of the point light in the scene
  101141. * @param scene The scene the lights belongs to
  101142. */
  101143. constructor(name: string, position: Vector3, scene: Scene);
  101144. /**
  101145. * Returns the string "PointLight"
  101146. * @returns the class name
  101147. */
  101148. getClassName(): string;
  101149. /**
  101150. * Returns the integer 0.
  101151. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101152. */
  101153. getTypeID(): number;
  101154. /**
  101155. * Specifies wether or not the shadowmap should be a cube texture.
  101156. * @returns true if the shadowmap needs to be a cube texture.
  101157. */
  101158. needCube(): boolean;
  101159. /**
  101160. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101161. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101162. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101163. */
  101164. getShadowDirection(faceIndex?: number): Vector3;
  101165. /**
  101166. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101167. * - fov = PI / 2
  101168. * - aspect ratio : 1.0
  101169. * - z-near and far equal to the active camera minZ and maxZ.
  101170. * Returns the PointLight.
  101171. */
  101172. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101173. protected _buildUniformLayout(): void;
  101174. /**
  101175. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101176. * @param effect The effect to update
  101177. * @param lightIndex The index of the light in the effect to update
  101178. * @returns The point light
  101179. */
  101180. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101181. /**
  101182. * Prepares the list of defines specific to the light type.
  101183. * @param defines the list of defines
  101184. * @param lightIndex defines the index of the light for the effect
  101185. */
  101186. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101187. }
  101188. }
  101189. declare module BABYLON {
  101190. /**
  101191. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101192. * These values define a cone of light starting from the position, emitting toward the direction.
  101193. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101194. * and the exponent defines the speed of the decay of the light with distance (reach).
  101195. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101196. */
  101197. export class SpotLight extends ShadowLight {
  101198. private _angle;
  101199. private _innerAngle;
  101200. private _cosHalfAngle;
  101201. private _lightAngleScale;
  101202. private _lightAngleOffset;
  101203. /**
  101204. * Gets the cone angle of the spot light in Radians.
  101205. */
  101206. /**
  101207. * Sets the cone angle of the spot light in Radians.
  101208. */
  101209. angle: number;
  101210. /**
  101211. * Only used in gltf falloff mode, this defines the angle where
  101212. * the directional falloff will start before cutting at angle which could be seen
  101213. * as outer angle.
  101214. */
  101215. /**
  101216. * Only used in gltf falloff mode, this defines the angle where
  101217. * the directional falloff will start before cutting at angle which could be seen
  101218. * as outer angle.
  101219. */
  101220. innerAngle: number;
  101221. private _shadowAngleScale;
  101222. /**
  101223. * Allows scaling the angle of the light for shadow generation only.
  101224. */
  101225. /**
  101226. * Allows scaling the angle of the light for shadow generation only.
  101227. */
  101228. shadowAngleScale: number;
  101229. /**
  101230. * The light decay speed with the distance from the emission spot.
  101231. */
  101232. exponent: number;
  101233. private _projectionTextureMatrix;
  101234. /**
  101235. * Allows reading the projecton texture
  101236. */
  101237. readonly projectionTextureMatrix: Matrix;
  101238. protected _projectionTextureLightNear: number;
  101239. /**
  101240. * Gets the near clip of the Spotlight for texture projection.
  101241. */
  101242. /**
  101243. * Sets the near clip of the Spotlight for texture projection.
  101244. */
  101245. projectionTextureLightNear: number;
  101246. protected _projectionTextureLightFar: number;
  101247. /**
  101248. * Gets the far clip of the Spotlight for texture projection.
  101249. */
  101250. /**
  101251. * Sets the far clip of the Spotlight for texture projection.
  101252. */
  101253. projectionTextureLightFar: number;
  101254. protected _projectionTextureUpDirection: Vector3;
  101255. /**
  101256. * Gets the Up vector of the Spotlight for texture projection.
  101257. */
  101258. /**
  101259. * Sets the Up vector of the Spotlight for texture projection.
  101260. */
  101261. projectionTextureUpDirection: Vector3;
  101262. private _projectionTexture;
  101263. /**
  101264. * Gets the projection texture of the light.
  101265. */
  101266. /**
  101267. * Sets the projection texture of the light.
  101268. */
  101269. projectionTexture: Nullable<BaseTexture>;
  101270. private _projectionTextureViewLightDirty;
  101271. private _projectionTextureProjectionLightDirty;
  101272. private _projectionTextureDirty;
  101273. private _projectionTextureViewTargetVector;
  101274. private _projectionTextureViewLightMatrix;
  101275. private _projectionTextureProjectionLightMatrix;
  101276. private _projectionTextureScalingMatrix;
  101277. /**
  101278. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101279. * It can cast shadows.
  101280. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101281. * @param name The light friendly name
  101282. * @param position The position of the spot light in the scene
  101283. * @param direction The direction of the light in the scene
  101284. * @param angle The cone angle of the light in Radians
  101285. * @param exponent The light decay speed with the distance from the emission spot
  101286. * @param scene The scene the lights belongs to
  101287. */
  101288. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101289. /**
  101290. * Returns the string "SpotLight".
  101291. * @returns the class name
  101292. */
  101293. getClassName(): string;
  101294. /**
  101295. * Returns the integer 2.
  101296. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101297. */
  101298. getTypeID(): number;
  101299. /**
  101300. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101301. */
  101302. protected _setDirection(value: Vector3): void;
  101303. /**
  101304. * Overrides the position setter to recompute the projection texture view light Matrix.
  101305. */
  101306. protected _setPosition(value: Vector3): void;
  101307. /**
  101308. * 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.
  101309. * Returns the SpotLight.
  101310. */
  101311. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101312. protected _computeProjectionTextureViewLightMatrix(): void;
  101313. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101314. /**
  101315. * Main function for light texture projection matrix computing.
  101316. */
  101317. protected _computeProjectionTextureMatrix(): void;
  101318. protected _buildUniformLayout(): void;
  101319. private _computeAngleValues;
  101320. /**
  101321. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101322. * @param effect The effect to update
  101323. * @param lightIndex The index of the light in the effect to update
  101324. * @returns The spot light
  101325. */
  101326. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101327. /**
  101328. * Disposes the light and the associated resources.
  101329. */
  101330. dispose(): void;
  101331. /**
  101332. * Prepares the list of defines specific to the light type.
  101333. * @param defines the list of defines
  101334. * @param lightIndex defines the index of the light for the effect
  101335. */
  101336. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101337. }
  101338. }
  101339. declare module BABYLON {
  101340. /**
  101341. * Header information of HDR texture files.
  101342. */
  101343. export interface HDRInfo {
  101344. /**
  101345. * The height of the texture in pixels.
  101346. */
  101347. height: number;
  101348. /**
  101349. * The width of the texture in pixels.
  101350. */
  101351. width: number;
  101352. /**
  101353. * The index of the beginning of the data in the binary file.
  101354. */
  101355. dataPosition: number;
  101356. }
  101357. /**
  101358. * This groups tools to convert HDR texture to native colors array.
  101359. */
  101360. export class HDRTools {
  101361. private static Ldexp;
  101362. private static Rgbe2float;
  101363. private static readStringLine;
  101364. /**
  101365. * Reads header information from an RGBE texture stored in a native array.
  101366. * More information on this format are available here:
  101367. * https://en.wikipedia.org/wiki/RGBE_image_format
  101368. *
  101369. * @param uint8array The binary file stored in native array.
  101370. * @return The header information.
  101371. */
  101372. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101373. /**
  101374. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101375. * This RGBE texture needs to store the information as a panorama.
  101376. *
  101377. * More information on this format are available here:
  101378. * https://en.wikipedia.org/wiki/RGBE_image_format
  101379. *
  101380. * @param buffer The binary file stored in an array buffer.
  101381. * @param size The expected size of the extracted cubemap.
  101382. * @return The Cube Map information.
  101383. */
  101384. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101385. /**
  101386. * Returns the pixels data extracted from an RGBE texture.
  101387. * This pixels will be stored left to right up to down in the R G B order in one array.
  101388. *
  101389. * More information on this format are available here:
  101390. * https://en.wikipedia.org/wiki/RGBE_image_format
  101391. *
  101392. * @param uint8array The binary file stored in an array buffer.
  101393. * @param hdrInfo The header information of the file.
  101394. * @return The pixels data in RGB right to left up to down order.
  101395. */
  101396. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101397. private static RGBE_ReadPixels_RLE;
  101398. }
  101399. }
  101400. declare module BABYLON {
  101401. /**
  101402. * This represents a texture coming from an HDR input.
  101403. *
  101404. * The only supported format is currently panorama picture stored in RGBE format.
  101405. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101406. */
  101407. export class HDRCubeTexture extends BaseTexture {
  101408. private static _facesMapping;
  101409. private _generateHarmonics;
  101410. private _noMipmap;
  101411. private _textureMatrix;
  101412. private _size;
  101413. private _onLoad;
  101414. private _onError;
  101415. /**
  101416. * The texture URL.
  101417. */
  101418. url: string;
  101419. /**
  101420. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101421. */
  101422. coordinatesMode: number;
  101423. protected _isBlocking: boolean;
  101424. /**
  101425. * Sets wether or not the texture is blocking during loading.
  101426. */
  101427. /**
  101428. * Gets wether or not the texture is blocking during loading.
  101429. */
  101430. isBlocking: boolean;
  101431. protected _rotationY: number;
  101432. /**
  101433. * Sets texture matrix rotation angle around Y axis in radians.
  101434. */
  101435. /**
  101436. * Gets texture matrix rotation angle around Y axis radians.
  101437. */
  101438. rotationY: number;
  101439. /**
  101440. * Gets or sets the center of the bounding box associated with the cube texture
  101441. * It must define where the camera used to render the texture was set
  101442. */
  101443. boundingBoxPosition: Vector3;
  101444. private _boundingBoxSize;
  101445. /**
  101446. * Gets or sets the size of the bounding box associated with the cube texture
  101447. * When defined, the cubemap will switch to local mode
  101448. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101449. * @example https://www.babylonjs-playground.com/#RNASML
  101450. */
  101451. boundingBoxSize: Vector3;
  101452. /**
  101453. * Instantiates an HDRTexture from the following parameters.
  101454. *
  101455. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101456. * @param scene The scene the texture will be used in
  101457. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101458. * @param noMipmap Forces to not generate the mipmap if true
  101459. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101460. * @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)
  101461. * @param reserved Reserved flag for internal use.
  101462. */
  101463. 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>);
  101464. /**
  101465. * Get the current class name of the texture useful for serialization or dynamic coding.
  101466. * @returns "HDRCubeTexture"
  101467. */
  101468. getClassName(): string;
  101469. /**
  101470. * Occurs when the file is raw .hdr file.
  101471. */
  101472. private loadTexture;
  101473. clone(): HDRCubeTexture;
  101474. delayLoad(): void;
  101475. /**
  101476. * Get the texture reflection matrix used to rotate/transform the reflection.
  101477. * @returns the reflection matrix
  101478. */
  101479. getReflectionTextureMatrix(): Matrix;
  101480. /**
  101481. * Set the texture reflection matrix used to rotate/transform the reflection.
  101482. * @param value Define the reflection matrix to set
  101483. */
  101484. setReflectionTextureMatrix(value: Matrix): void;
  101485. /**
  101486. * Parses a JSON representation of an HDR Texture in order to create the texture
  101487. * @param parsedTexture Define the JSON representation
  101488. * @param scene Define the scene the texture should be created in
  101489. * @param rootUrl Define the root url in case we need to load relative dependencies
  101490. * @returns the newly created texture after parsing
  101491. */
  101492. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101493. serialize(): any;
  101494. }
  101495. }
  101496. declare module BABYLON {
  101497. /**
  101498. * Class used to control physics engine
  101499. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101500. */
  101501. export class PhysicsEngine implements IPhysicsEngine {
  101502. private _physicsPlugin;
  101503. /**
  101504. * Global value used to control the smallest number supported by the simulation
  101505. */
  101506. static Epsilon: number;
  101507. private _impostors;
  101508. private _joints;
  101509. /**
  101510. * Gets the gravity vector used by the simulation
  101511. */
  101512. gravity: Vector3;
  101513. /**
  101514. * Factory used to create the default physics plugin.
  101515. * @returns The default physics plugin
  101516. */
  101517. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101518. /**
  101519. * Creates a new Physics Engine
  101520. * @param gravity defines the gravity vector used by the simulation
  101521. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101522. */
  101523. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101524. /**
  101525. * Sets the gravity vector used by the simulation
  101526. * @param gravity defines the gravity vector to use
  101527. */
  101528. setGravity(gravity: Vector3): void;
  101529. /**
  101530. * Set the time step of the physics engine.
  101531. * Default is 1/60.
  101532. * To slow it down, enter 1/600 for example.
  101533. * To speed it up, 1/30
  101534. * @param newTimeStep defines the new timestep to apply to this world.
  101535. */
  101536. setTimeStep(newTimeStep?: number): void;
  101537. /**
  101538. * Get the time step of the physics engine.
  101539. * @returns the current time step
  101540. */
  101541. getTimeStep(): number;
  101542. /**
  101543. * Release all resources
  101544. */
  101545. dispose(): void;
  101546. /**
  101547. * Gets the name of the current physics plugin
  101548. * @returns the name of the plugin
  101549. */
  101550. getPhysicsPluginName(): string;
  101551. /**
  101552. * Adding a new impostor for the impostor tracking.
  101553. * This will be done by the impostor itself.
  101554. * @param impostor the impostor to add
  101555. */
  101556. addImpostor(impostor: PhysicsImpostor): void;
  101557. /**
  101558. * Remove an impostor from the engine.
  101559. * This impostor and its mesh will not longer be updated by the physics engine.
  101560. * @param impostor the impostor to remove
  101561. */
  101562. removeImpostor(impostor: PhysicsImpostor): void;
  101563. /**
  101564. * Add a joint to the physics engine
  101565. * @param mainImpostor defines the main impostor to which the joint is added.
  101566. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101567. * @param joint defines the joint that will connect both impostors.
  101568. */
  101569. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101570. /**
  101571. * Removes a joint from the simulation
  101572. * @param mainImpostor defines the impostor used with the joint
  101573. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101574. * @param joint defines the joint to remove
  101575. */
  101576. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101577. /**
  101578. * Called by the scene. No need to call it.
  101579. * @param delta defines the timespam between frames
  101580. */
  101581. _step(delta: number): void;
  101582. /**
  101583. * Gets the current plugin used to run the simulation
  101584. * @returns current plugin
  101585. */
  101586. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101587. /**
  101588. * Gets the list of physic impostors
  101589. * @returns an array of PhysicsImpostor
  101590. */
  101591. getImpostors(): Array<PhysicsImpostor>;
  101592. /**
  101593. * Gets the impostor for a physics enabled object
  101594. * @param object defines the object impersonated by the impostor
  101595. * @returns the PhysicsImpostor or null if not found
  101596. */
  101597. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101598. /**
  101599. * Gets the impostor for a physics body object
  101600. * @param body defines physics body used by the impostor
  101601. * @returns the PhysicsImpostor or null if not found
  101602. */
  101603. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101604. }
  101605. }
  101606. declare module BABYLON {
  101607. /** @hidden */
  101608. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101609. private _useDeltaForWorldStep;
  101610. world: any;
  101611. name: string;
  101612. private _physicsMaterials;
  101613. private _fixedTimeStep;
  101614. BJSCANNON: any;
  101615. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101616. setGravity(gravity: Vector3): void;
  101617. setTimeStep(timeStep: number): void;
  101618. getTimeStep(): number;
  101619. executeStep(delta: number): void;
  101620. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101621. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101622. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101623. private _processChildMeshes;
  101624. removePhysicsBody(impostor: PhysicsImpostor): void;
  101625. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101626. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101627. private _addMaterial;
  101628. private _checkWithEpsilon;
  101629. private _createShape;
  101630. private _createHeightmap;
  101631. private _minus90X;
  101632. private _plus90X;
  101633. private _tmpPosition;
  101634. private _tmpDeltaPosition;
  101635. private _tmpUnityRotation;
  101636. private _updatePhysicsBodyTransformation;
  101637. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101638. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101639. isSupported(): boolean;
  101640. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101641. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101642. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101643. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101644. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101645. getBodyMass(impostor: PhysicsImpostor): number;
  101646. getBodyFriction(impostor: PhysicsImpostor): number;
  101647. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101648. getBodyRestitution(impostor: PhysicsImpostor): number;
  101649. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101650. sleepBody(impostor: PhysicsImpostor): void;
  101651. wakeUpBody(impostor: PhysicsImpostor): void;
  101652. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101653. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101654. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101655. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101656. getRadius(impostor: PhysicsImpostor): number;
  101657. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101658. dispose(): void;
  101659. private _extendNamespace;
  101660. }
  101661. }
  101662. declare module BABYLON {
  101663. /** @hidden */
  101664. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101665. world: any;
  101666. name: string;
  101667. BJSOIMO: any;
  101668. constructor(iterations?: number, oimoInjection?: any);
  101669. setGravity(gravity: Vector3): void;
  101670. setTimeStep(timeStep: number): void;
  101671. getTimeStep(): number;
  101672. private _tmpImpostorsArray;
  101673. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101674. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101675. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101676. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101677. private _tmpPositionVector;
  101678. removePhysicsBody(impostor: PhysicsImpostor): void;
  101679. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101680. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101681. isSupported(): boolean;
  101682. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101683. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101684. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101685. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101687. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101688. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101689. getBodyMass(impostor: PhysicsImpostor): number;
  101690. getBodyFriction(impostor: PhysicsImpostor): number;
  101691. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101692. getBodyRestitution(impostor: PhysicsImpostor): number;
  101693. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101694. sleepBody(impostor: PhysicsImpostor): void;
  101695. wakeUpBody(impostor: PhysicsImpostor): void;
  101696. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101697. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  101698. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101699. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101700. getRadius(impostor: PhysicsImpostor): number;
  101701. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101702. dispose(): void;
  101703. }
  101704. }
  101705. declare module BABYLON {
  101706. interface AbstractScene {
  101707. /**
  101708. * The list of reflection probes added to the scene
  101709. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101710. */
  101711. reflectionProbes: Array<ReflectionProbe>;
  101712. /**
  101713. * Removes the given reflection probe from this scene.
  101714. * @param toRemove The reflection probe to remove
  101715. * @returns The index of the removed reflection probe
  101716. */
  101717. removeReflectionProbe(toRemove: ReflectionProbe): number;
  101718. /**
  101719. * Adds the given reflection probe to this scene.
  101720. * @param newReflectionProbe The reflection probe to add
  101721. */
  101722. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  101723. }
  101724. /**
  101725. * Class used to generate realtime reflection / refraction cube textures
  101726. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101727. */
  101728. export class ReflectionProbe {
  101729. /** defines the name of the probe */
  101730. name: string;
  101731. private _scene;
  101732. private _renderTargetTexture;
  101733. private _projectionMatrix;
  101734. private _viewMatrix;
  101735. private _target;
  101736. private _add;
  101737. private _attachedMesh;
  101738. private _invertYAxis;
  101739. /** Gets or sets probe position (center of the cube map) */
  101740. position: Vector3;
  101741. /**
  101742. * Creates a new reflection probe
  101743. * @param name defines the name of the probe
  101744. * @param size defines the texture resolution (for each face)
  101745. * @param scene defines the hosting scene
  101746. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  101747. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  101748. */
  101749. constructor(
  101750. /** defines the name of the probe */
  101751. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  101752. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  101753. samples: number;
  101754. /** Gets or sets the refresh rate to use (on every frame by default) */
  101755. refreshRate: number;
  101756. /**
  101757. * Gets the hosting scene
  101758. * @returns a Scene
  101759. */
  101760. getScene(): Scene;
  101761. /** Gets the internal CubeTexture used to render to */
  101762. readonly cubeTexture: RenderTargetTexture;
  101763. /** Gets the list of meshes to render */
  101764. readonly renderList: Nullable<AbstractMesh[]>;
  101765. /**
  101766. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  101767. * @param mesh defines the mesh to attach to
  101768. */
  101769. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101770. /**
  101771. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  101772. * @param renderingGroupId The rendering group id corresponding to its index
  101773. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101774. */
  101775. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101776. /**
  101777. * Clean all associated resources
  101778. */
  101779. dispose(): void;
  101780. /**
  101781. * Converts the reflection probe information to a readable string for debug purpose.
  101782. * @param fullDetails Supports for multiple levels of logging within scene loading
  101783. * @returns the human readable reflection probe info
  101784. */
  101785. toString(fullDetails?: boolean): string;
  101786. /**
  101787. * Get the class name of the relfection probe.
  101788. * @returns "ReflectionProbe"
  101789. */
  101790. getClassName(): string;
  101791. /**
  101792. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  101793. * @returns The JSON representation of the texture
  101794. */
  101795. serialize(): any;
  101796. /**
  101797. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  101798. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  101799. * @param scene Define the scene the parsed reflection probe should be instantiated in
  101800. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101801. * @returns The parsed reflection probe if successful
  101802. */
  101803. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  101804. }
  101805. }
  101806. declare module BABYLON {
  101807. /** @hidden */
  101808. export var _BabylonLoaderRegistered: boolean;
  101809. }
  101810. declare module BABYLON {
  101811. /**
  101812. * The Physically based simple base material of BJS.
  101813. *
  101814. * This enables better naming and convention enforcements on top of the pbrMaterial.
  101815. * It is used as the base class for both the specGloss and metalRough conventions.
  101816. */
  101817. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  101818. /**
  101819. * Number of Simultaneous lights allowed on the material.
  101820. */
  101821. maxSimultaneousLights: number;
  101822. /**
  101823. * If sets to true, disables all the lights affecting the material.
  101824. */
  101825. disableLighting: boolean;
  101826. /**
  101827. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  101828. */
  101829. environmentTexture: BaseTexture;
  101830. /**
  101831. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101832. */
  101833. invertNormalMapX: boolean;
  101834. /**
  101835. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101836. */
  101837. invertNormalMapY: boolean;
  101838. /**
  101839. * Normal map used in the model.
  101840. */
  101841. normalTexture: BaseTexture;
  101842. /**
  101843. * Emissivie color used to self-illuminate the model.
  101844. */
  101845. emissiveColor: Color3;
  101846. /**
  101847. * Emissivie texture used to self-illuminate the model.
  101848. */
  101849. emissiveTexture: BaseTexture;
  101850. /**
  101851. * Occlusion Channel Strenght.
  101852. */
  101853. occlusionStrength: number;
  101854. /**
  101855. * Occlusion Texture of the material (adding extra occlusion effects).
  101856. */
  101857. occlusionTexture: BaseTexture;
  101858. /**
  101859. * Defines the alpha limits in alpha test mode.
  101860. */
  101861. alphaCutOff: number;
  101862. /**
  101863. * Gets the current double sided mode.
  101864. */
  101865. /**
  101866. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101867. */
  101868. doubleSided: boolean;
  101869. /**
  101870. * Stores the pre-calculated light information of a mesh in a texture.
  101871. */
  101872. lightmapTexture: BaseTexture;
  101873. /**
  101874. * If true, the light map contains occlusion information instead of lighting info.
  101875. */
  101876. useLightmapAsShadowmap: boolean;
  101877. /**
  101878. * Return the active textures of the material.
  101879. */
  101880. getActiveTextures(): BaseTexture[];
  101881. hasTexture(texture: BaseTexture): boolean;
  101882. /**
  101883. * Instantiates a new PBRMaterial instance.
  101884. *
  101885. * @param name The material name
  101886. * @param scene The scene the material will be use in.
  101887. */
  101888. constructor(name: string, scene: Scene);
  101889. getClassName(): string;
  101890. }
  101891. }
  101892. declare module BABYLON {
  101893. /**
  101894. * The PBR material of BJS following the metal roughness convention.
  101895. *
  101896. * This fits to the PBR convention in the GLTF definition:
  101897. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  101898. */
  101899. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  101900. /**
  101901. * The base color has two different interpretations depending on the value of metalness.
  101902. * When the material is a metal, the base color is the specific measured reflectance value
  101903. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  101904. * of the material.
  101905. */
  101906. baseColor: Color3;
  101907. /**
  101908. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  101909. * well as opacity information in the alpha channel.
  101910. */
  101911. baseTexture: BaseTexture;
  101912. /**
  101913. * Specifies the metallic scalar value of the material.
  101914. * Can also be used to scale the metalness values of the metallic texture.
  101915. */
  101916. metallic: number;
  101917. /**
  101918. * Specifies the roughness scalar value of the material.
  101919. * Can also be used to scale the roughness values of the metallic texture.
  101920. */
  101921. roughness: number;
  101922. /**
  101923. * Texture containing both the metallic value in the B channel and the
  101924. * roughness value in the G channel to keep better precision.
  101925. */
  101926. metallicRoughnessTexture: BaseTexture;
  101927. /**
  101928. * Instantiates a new PBRMetalRoughnessMaterial instance.
  101929. *
  101930. * @param name The material name
  101931. * @param scene The scene the material will be use in.
  101932. */
  101933. constructor(name: string, scene: Scene);
  101934. /**
  101935. * Return the currrent class name of the material.
  101936. */
  101937. getClassName(): string;
  101938. /**
  101939. * Return the active textures of the material.
  101940. */
  101941. getActiveTextures(): BaseTexture[];
  101942. /**
  101943. * Checks to see if a texture is used in the material.
  101944. * @param texture - Base texture to use.
  101945. * @returns - Boolean specifying if a texture is used in the material.
  101946. */
  101947. hasTexture(texture: BaseTexture): boolean;
  101948. /**
  101949. * Makes a duplicate of the current material.
  101950. * @param name - name to use for the new material.
  101951. */
  101952. clone(name: string): PBRMetallicRoughnessMaterial;
  101953. /**
  101954. * Serialize the material to a parsable JSON object.
  101955. */
  101956. serialize(): any;
  101957. /**
  101958. * Parses a JSON object correponding to the serialize function.
  101959. */
  101960. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  101961. }
  101962. }
  101963. declare module BABYLON {
  101964. /**
  101965. * The PBR material of BJS following the specular glossiness convention.
  101966. *
  101967. * This fits to the PBR convention in the GLTF definition:
  101968. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  101969. */
  101970. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  101971. /**
  101972. * Specifies the diffuse color of the material.
  101973. */
  101974. diffuseColor: Color3;
  101975. /**
  101976. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  101977. * channel.
  101978. */
  101979. diffuseTexture: BaseTexture;
  101980. /**
  101981. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  101982. */
  101983. specularColor: Color3;
  101984. /**
  101985. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  101986. */
  101987. glossiness: number;
  101988. /**
  101989. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  101990. */
  101991. specularGlossinessTexture: BaseTexture;
  101992. /**
  101993. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  101994. *
  101995. * @param name The material name
  101996. * @param scene The scene the material will be use in.
  101997. */
  101998. constructor(name: string, scene: Scene);
  101999. /**
  102000. * Return the currrent class name of the material.
  102001. */
  102002. getClassName(): string;
  102003. /**
  102004. * Return the active textures of the material.
  102005. */
  102006. getActiveTextures(): BaseTexture[];
  102007. /**
  102008. * Checks to see if a texture is used in the material.
  102009. * @param texture - Base texture to use.
  102010. * @returns - Boolean specifying if a texture is used in the material.
  102011. */
  102012. hasTexture(texture: BaseTexture): boolean;
  102013. /**
  102014. * Makes a duplicate of the current material.
  102015. * @param name - name to use for the new material.
  102016. */
  102017. clone(name: string): PBRSpecularGlossinessMaterial;
  102018. /**
  102019. * Serialize the material to a parsable JSON object.
  102020. */
  102021. serialize(): any;
  102022. /**
  102023. * Parses a JSON object correponding to the serialize function.
  102024. */
  102025. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102026. }
  102027. }
  102028. declare module BABYLON {
  102029. /**
  102030. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102031. * It can help converting any input color in a desired output one. This can then be used to create effects
  102032. * from sepia, black and white to sixties or futuristic rendering...
  102033. *
  102034. * The only supported format is currently 3dl.
  102035. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102036. */
  102037. export class ColorGradingTexture extends BaseTexture {
  102038. /**
  102039. * The current texture matrix. (will always be identity in color grading texture)
  102040. */
  102041. private _textureMatrix;
  102042. /**
  102043. * The texture URL.
  102044. */
  102045. url: string;
  102046. /**
  102047. * Empty line regex stored for GC.
  102048. */
  102049. private static _noneEmptyLineRegex;
  102050. private _engine;
  102051. /**
  102052. * Instantiates a ColorGradingTexture from the following parameters.
  102053. *
  102054. * @param url The location of the color gradind data (currently only supporting 3dl)
  102055. * @param scene The scene the texture will be used in
  102056. */
  102057. constructor(url: string, scene: Scene);
  102058. /**
  102059. * Returns the texture matrix used in most of the material.
  102060. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102061. */
  102062. getTextureMatrix(): Matrix;
  102063. /**
  102064. * Occurs when the file being loaded is a .3dl LUT file.
  102065. */
  102066. private load3dlTexture;
  102067. /**
  102068. * Starts the loading process of the texture.
  102069. */
  102070. private loadTexture;
  102071. /**
  102072. * Clones the color gradind texture.
  102073. */
  102074. clone(): ColorGradingTexture;
  102075. /**
  102076. * Called during delayed load for textures.
  102077. */
  102078. delayLoad(): void;
  102079. /**
  102080. * Parses a color grading texture serialized by Babylon.
  102081. * @param parsedTexture The texture information being parsedTexture
  102082. * @param scene The scene to load the texture in
  102083. * @param rootUrl The root url of the data assets to load
  102084. * @return A color gradind texture
  102085. */
  102086. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102087. /**
  102088. * Serializes the LUT texture to json format.
  102089. */
  102090. serialize(): any;
  102091. }
  102092. }
  102093. declare module BABYLON {
  102094. /**
  102095. * Direct draw surface info
  102096. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102097. */
  102098. export interface DDSInfo {
  102099. /**
  102100. * Width of the texture
  102101. */
  102102. width: number;
  102103. /**
  102104. * Width of the texture
  102105. */
  102106. height: number;
  102107. /**
  102108. * Number of Mipmaps for the texture
  102109. * @see https://en.wikipedia.org/wiki/Mipmap
  102110. */
  102111. mipmapCount: number;
  102112. /**
  102113. * If the textures format is a known fourCC format
  102114. * @see https://www.fourcc.org/
  102115. */
  102116. isFourCC: boolean;
  102117. /**
  102118. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102119. */
  102120. isRGB: boolean;
  102121. /**
  102122. * If the texture is a lumincance format
  102123. */
  102124. isLuminance: boolean;
  102125. /**
  102126. * If this is a cube texture
  102127. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102128. */
  102129. isCube: boolean;
  102130. /**
  102131. * If the texture is a compressed format eg. FOURCC_DXT1
  102132. */
  102133. isCompressed: boolean;
  102134. /**
  102135. * The dxgiFormat of the texture
  102136. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102137. */
  102138. dxgiFormat: number;
  102139. /**
  102140. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102141. */
  102142. textureType: number;
  102143. /**
  102144. * Sphericle polynomial created for the dds texture
  102145. */
  102146. sphericalPolynomial?: SphericalPolynomial;
  102147. }
  102148. /**
  102149. * Class used to provide DDS decompression tools
  102150. */
  102151. export class DDSTools {
  102152. /**
  102153. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102154. */
  102155. static StoreLODInAlphaChannel: boolean;
  102156. /**
  102157. * Gets DDS information from an array buffer
  102158. * @param arrayBuffer defines the array buffer to read data from
  102159. * @returns the DDS information
  102160. */
  102161. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102162. private static _FloatView;
  102163. private static _Int32View;
  102164. private static _ToHalfFloat;
  102165. private static _FromHalfFloat;
  102166. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102167. private static _GetHalfFloatRGBAArrayBuffer;
  102168. private static _GetFloatRGBAArrayBuffer;
  102169. private static _GetFloatAsUIntRGBAArrayBuffer;
  102170. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102171. private static _GetRGBAArrayBuffer;
  102172. private static _ExtractLongWordOrder;
  102173. private static _GetRGBArrayBuffer;
  102174. private static _GetLuminanceArrayBuffer;
  102175. /**
  102176. * Uploads DDS Levels to a Babylon Texture
  102177. * @hidden
  102178. */
  102179. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102180. }
  102181. interface Engine {
  102182. /**
  102183. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102184. * @param rootUrl defines the url where the file to load is located
  102185. * @param scene defines the current scene
  102186. * @param lodScale defines scale to apply to the mip map selection
  102187. * @param lodOffset defines offset to apply to the mip map selection
  102188. * @param onLoad defines an optional callback raised when the texture is loaded
  102189. * @param onError defines an optional callback raised if there is an issue to load the texture
  102190. * @param format defines the format of the data
  102191. * @param forcedExtension defines the extension to use to pick the right loader
  102192. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102193. * @returns the cube texture as an InternalTexture
  102194. */
  102195. 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;
  102196. }
  102197. }
  102198. declare module BABYLON {
  102199. /**
  102200. * Implementation of the DDS Texture Loader.
  102201. * @hidden
  102202. */
  102203. export class _DDSTextureLoader implements IInternalTextureLoader {
  102204. /**
  102205. * Defines wether the loader supports cascade loading the different faces.
  102206. */
  102207. readonly supportCascades: boolean;
  102208. /**
  102209. * This returns if the loader support the current file information.
  102210. * @param extension defines the file extension of the file being loaded
  102211. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102212. * @param fallback defines the fallback internal texture if any
  102213. * @param isBase64 defines whether the texture is encoded as a base64
  102214. * @param isBuffer defines whether the texture data are stored as a buffer
  102215. * @returns true if the loader can load the specified file
  102216. */
  102217. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102218. /**
  102219. * Transform the url before loading if required.
  102220. * @param rootUrl the url of the texture
  102221. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102222. * @returns the transformed texture
  102223. */
  102224. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102225. /**
  102226. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102227. * @param rootUrl the url of the texture
  102228. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102229. * @returns the fallback texture
  102230. */
  102231. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102232. /**
  102233. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102234. * @param data contains the texture data
  102235. * @param texture defines the BabylonJS internal texture
  102236. * @param createPolynomials will be true if polynomials have been requested
  102237. * @param onLoad defines the callback to trigger once the texture is ready
  102238. * @param onError defines the callback to trigger in case of error
  102239. */
  102240. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102241. /**
  102242. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102243. * @param data contains the texture data
  102244. * @param texture defines the BabylonJS internal texture
  102245. * @param callback defines the method to call once ready to upload
  102246. */
  102247. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102248. }
  102249. }
  102250. declare module BABYLON {
  102251. /** @hidden */
  102252. export var rgbdEncodePixelShader: {
  102253. name: string;
  102254. shader: string;
  102255. };
  102256. }
  102257. declare module BABYLON {
  102258. /** @hidden */
  102259. export var rgbdDecodePixelShader: {
  102260. name: string;
  102261. shader: string;
  102262. };
  102263. }
  102264. declare module BABYLON {
  102265. /**
  102266. * Raw texture data and descriptor sufficient for WebGL texture upload
  102267. */
  102268. export interface EnvironmentTextureInfo {
  102269. /**
  102270. * Version of the environment map
  102271. */
  102272. version: number;
  102273. /**
  102274. * Width of image
  102275. */
  102276. width: number;
  102277. /**
  102278. * Irradiance information stored in the file.
  102279. */
  102280. irradiance: any;
  102281. /**
  102282. * Specular information stored in the file.
  102283. */
  102284. specular: any;
  102285. }
  102286. /**
  102287. * Sets of helpers addressing the serialization and deserialization of environment texture
  102288. * stored in a BabylonJS env file.
  102289. * Those files are usually stored as .env files.
  102290. */
  102291. export class EnvironmentTextureTools {
  102292. /**
  102293. * Magic number identifying the env file.
  102294. */
  102295. private static _MagicBytes;
  102296. /**
  102297. * Gets the environment info from an env file.
  102298. * @param data The array buffer containing the .env bytes.
  102299. * @returns the environment file info (the json header) if successfully parsed.
  102300. */
  102301. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102302. /**
  102303. * Creates an environment texture from a loaded cube texture.
  102304. * @param texture defines the cube texture to convert in env file
  102305. * @return a promise containing the environment data if succesfull.
  102306. */
  102307. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102308. /**
  102309. * Creates a JSON representation of the spherical data.
  102310. * @param texture defines the texture containing the polynomials
  102311. * @return the JSON representation of the spherical info
  102312. */
  102313. private static _CreateEnvTextureIrradiance;
  102314. /**
  102315. * Uploads the texture info contained in the env file to the GPU.
  102316. * @param texture defines the internal texture to upload to
  102317. * @param arrayBuffer defines the buffer cotaining the data to load
  102318. * @param info defines the texture info retrieved through the GetEnvInfo method
  102319. * @returns a promise
  102320. */
  102321. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102322. /**
  102323. * Uploads the levels of image data to the GPU.
  102324. * @param texture defines the internal texture to upload to
  102325. * @param imageData defines the array buffer views of image data [mipmap][face]
  102326. * @returns a promise
  102327. */
  102328. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102329. /**
  102330. * Uploads spherical polynomials information to the texture.
  102331. * @param texture defines the texture we are trying to upload the information to
  102332. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102333. */
  102334. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102335. /** @hidden */
  102336. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102337. }
  102338. }
  102339. declare module BABYLON {
  102340. /**
  102341. * Implementation of the ENV Texture Loader.
  102342. * @hidden
  102343. */
  102344. export class _ENVTextureLoader implements IInternalTextureLoader {
  102345. /**
  102346. * Defines wether the loader supports cascade loading the different faces.
  102347. */
  102348. readonly supportCascades: boolean;
  102349. /**
  102350. * This returns if the loader support the current file information.
  102351. * @param extension defines the file extension of the file being loaded
  102352. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102353. * @param fallback defines the fallback internal texture if any
  102354. * @param isBase64 defines whether the texture is encoded as a base64
  102355. * @param isBuffer defines whether the texture data are stored as a buffer
  102356. * @returns true if the loader can load the specified file
  102357. */
  102358. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102359. /**
  102360. * Transform the url before loading if required.
  102361. * @param rootUrl the url of the texture
  102362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102363. * @returns the transformed texture
  102364. */
  102365. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102366. /**
  102367. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102368. * @param rootUrl the url of the texture
  102369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102370. * @returns the fallback texture
  102371. */
  102372. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102373. /**
  102374. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102375. * @param data contains the texture data
  102376. * @param texture defines the BabylonJS internal texture
  102377. * @param createPolynomials will be true if polynomials have been requested
  102378. * @param onLoad defines the callback to trigger once the texture is ready
  102379. * @param onError defines the callback to trigger in case of error
  102380. */
  102381. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102382. /**
  102383. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102384. * @param data contains the texture data
  102385. * @param texture defines the BabylonJS internal texture
  102386. * @param callback defines the method to call once ready to upload
  102387. */
  102388. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102389. }
  102390. }
  102391. declare module BABYLON {
  102392. /**
  102393. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102394. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102395. */
  102396. export class KhronosTextureContainer {
  102397. /** contents of the KTX container file */
  102398. arrayBuffer: any;
  102399. private static HEADER_LEN;
  102400. private static COMPRESSED_2D;
  102401. private static COMPRESSED_3D;
  102402. private static TEX_2D;
  102403. private static TEX_3D;
  102404. /**
  102405. * Gets the openGL type
  102406. */
  102407. glType: number;
  102408. /**
  102409. * Gets the openGL type size
  102410. */
  102411. glTypeSize: number;
  102412. /**
  102413. * Gets the openGL format
  102414. */
  102415. glFormat: number;
  102416. /**
  102417. * Gets the openGL internal format
  102418. */
  102419. glInternalFormat: number;
  102420. /**
  102421. * Gets the base internal format
  102422. */
  102423. glBaseInternalFormat: number;
  102424. /**
  102425. * Gets image width in pixel
  102426. */
  102427. pixelWidth: number;
  102428. /**
  102429. * Gets image height in pixel
  102430. */
  102431. pixelHeight: number;
  102432. /**
  102433. * Gets image depth in pixels
  102434. */
  102435. pixelDepth: number;
  102436. /**
  102437. * Gets the number of array elements
  102438. */
  102439. numberOfArrayElements: number;
  102440. /**
  102441. * Gets the number of faces
  102442. */
  102443. numberOfFaces: number;
  102444. /**
  102445. * Gets the number of mipmap levels
  102446. */
  102447. numberOfMipmapLevels: number;
  102448. /**
  102449. * Gets the bytes of key value data
  102450. */
  102451. bytesOfKeyValueData: number;
  102452. /**
  102453. * Gets the load type
  102454. */
  102455. loadType: number;
  102456. /**
  102457. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102458. */
  102459. isInvalid: boolean;
  102460. /**
  102461. * Creates a new KhronosTextureContainer
  102462. * @param arrayBuffer contents of the KTX container file
  102463. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102464. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102465. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102466. */
  102467. constructor(
  102468. /** contents of the KTX container file */
  102469. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102470. /**
  102471. * Uploads KTX content to a Babylon Texture.
  102472. * It is assumed that the texture has already been created & is currently bound
  102473. * @hidden
  102474. */
  102475. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102476. private _upload2DCompressedLevels;
  102477. }
  102478. }
  102479. declare module BABYLON {
  102480. /**
  102481. * Implementation of the KTX Texture Loader.
  102482. * @hidden
  102483. */
  102484. export class _KTXTextureLoader implements IInternalTextureLoader {
  102485. /**
  102486. * Defines wether the loader supports cascade loading the different faces.
  102487. */
  102488. readonly supportCascades: boolean;
  102489. /**
  102490. * This returns if the loader support the current file information.
  102491. * @param extension defines the file extension of the file being loaded
  102492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102493. * @param fallback defines the fallback internal texture if any
  102494. * @param isBase64 defines whether the texture is encoded as a base64
  102495. * @param isBuffer defines whether the texture data are stored as a buffer
  102496. * @returns true if the loader can load the specified file
  102497. */
  102498. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102499. /**
  102500. * Transform the url before loading if required.
  102501. * @param rootUrl the url of the texture
  102502. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102503. * @returns the transformed texture
  102504. */
  102505. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102506. /**
  102507. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102508. * @param rootUrl the url of the texture
  102509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102510. * @returns the fallback texture
  102511. */
  102512. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102513. /**
  102514. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102515. * @param data contains the texture data
  102516. * @param texture defines the BabylonJS internal texture
  102517. * @param createPolynomials will be true if polynomials have been requested
  102518. * @param onLoad defines the callback to trigger once the texture is ready
  102519. * @param onError defines the callback to trigger in case of error
  102520. */
  102521. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102522. /**
  102523. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102524. * @param data contains the texture data
  102525. * @param texture defines the BabylonJS internal texture
  102526. * @param callback defines the method to call once ready to upload
  102527. */
  102528. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102529. }
  102530. }
  102531. declare module BABYLON {
  102532. /**
  102533. * Based on jsTGALoader - Javascript loader for TGA file
  102534. * By Vincent Thibault
  102535. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102536. */
  102537. export class TGATools {
  102538. private static _TYPE_INDEXED;
  102539. private static _TYPE_RGB;
  102540. private static _TYPE_GREY;
  102541. private static _TYPE_RLE_INDEXED;
  102542. private static _TYPE_RLE_RGB;
  102543. private static _TYPE_RLE_GREY;
  102544. private static _ORIGIN_MASK;
  102545. private static _ORIGIN_SHIFT;
  102546. private static _ORIGIN_BL;
  102547. private static _ORIGIN_BR;
  102548. private static _ORIGIN_UL;
  102549. private static _ORIGIN_UR;
  102550. /**
  102551. * Gets the header of a TGA file
  102552. * @param data defines the TGA data
  102553. * @returns the header
  102554. */
  102555. static GetTGAHeader(data: Uint8Array): any;
  102556. /**
  102557. * Uploads TGA content to a Babylon Texture
  102558. * @hidden
  102559. */
  102560. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102561. /** @hidden */
  102562. 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;
  102563. /** @hidden */
  102564. 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;
  102565. /** @hidden */
  102566. 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;
  102567. /** @hidden */
  102568. 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;
  102569. /** @hidden */
  102570. 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;
  102571. /** @hidden */
  102572. 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;
  102573. }
  102574. }
  102575. declare module BABYLON {
  102576. /**
  102577. * Implementation of the TGA Texture Loader.
  102578. * @hidden
  102579. */
  102580. export class _TGATextureLoader implements IInternalTextureLoader {
  102581. /**
  102582. * Defines wether the loader supports cascade loading the different faces.
  102583. */
  102584. readonly supportCascades: boolean;
  102585. /**
  102586. * This returns if the loader support the current file information.
  102587. * @param extension defines the file extension of the file being loaded
  102588. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102589. * @param fallback defines the fallback internal texture if any
  102590. * @param isBase64 defines whether the texture is encoded as a base64
  102591. * @param isBuffer defines whether the texture data are stored as a buffer
  102592. * @returns true if the loader can load the specified file
  102593. */
  102594. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102595. /**
  102596. * Transform the url before loading if required.
  102597. * @param rootUrl the url of the texture
  102598. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102599. * @returns the transformed texture
  102600. */
  102601. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102602. /**
  102603. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102604. * @param rootUrl the url of the texture
  102605. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102606. * @returns the fallback texture
  102607. */
  102608. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102609. /**
  102610. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102611. * @param data contains the texture data
  102612. * @param texture defines the BabylonJS internal texture
  102613. * @param createPolynomials will be true if polynomials have been requested
  102614. * @param onLoad defines the callback to trigger once the texture is ready
  102615. * @param onError defines the callback to trigger in case of error
  102616. */
  102617. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102618. /**
  102619. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102620. * @param data contains the texture data
  102621. * @param texture defines the BabylonJS internal texture
  102622. * @param callback defines the method to call once ready to upload
  102623. */
  102624. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102625. }
  102626. }
  102627. declare module BABYLON {
  102628. /**
  102629. * 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.
  102630. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102631. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102632. */
  102633. export class CustomProceduralTexture extends ProceduralTexture {
  102634. private _animate;
  102635. private _time;
  102636. private _config;
  102637. private _texturePath;
  102638. /**
  102639. * Instantiates a new Custom Procedural Texture.
  102640. * 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.
  102641. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102642. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102643. * @param name Define the name of the texture
  102644. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102645. * @param size Define the size of the texture to create
  102646. * @param scene Define the scene the texture belongs to
  102647. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102648. * @param generateMipMaps Define if the texture should creates mip maps or not
  102649. */
  102650. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102651. private _loadJson;
  102652. /**
  102653. * Is the texture ready to be used ? (rendered at least once)
  102654. * @returns true if ready, otherwise, false.
  102655. */
  102656. isReady(): boolean;
  102657. /**
  102658. * Render the texture to its associated render target.
  102659. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102660. */
  102661. render(useCameraPostProcess?: boolean): void;
  102662. /**
  102663. * Update the list of dependant textures samplers in the shader.
  102664. */
  102665. updateTextures(): void;
  102666. /**
  102667. * Update the uniform values of the procedural texture in the shader.
  102668. */
  102669. updateShaderUniforms(): void;
  102670. /**
  102671. * Define if the texture animates or not.
  102672. */
  102673. animate: boolean;
  102674. }
  102675. }
  102676. declare module BABYLON {
  102677. /** @hidden */
  102678. export var noisePixelShader: {
  102679. name: string;
  102680. shader: string;
  102681. };
  102682. }
  102683. declare module BABYLON {
  102684. /**
  102685. * Class used to generate noise procedural textures
  102686. */
  102687. export class NoiseProceduralTexture extends ProceduralTexture {
  102688. private _time;
  102689. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102690. brightness: number;
  102691. /** Defines the number of octaves to process */
  102692. octaves: number;
  102693. /** Defines the level of persistence (0.8 by default) */
  102694. persistence: number;
  102695. /** Gets or sets animation speed factor (default is 1) */
  102696. animationSpeedFactor: number;
  102697. /**
  102698. * Creates a new NoiseProceduralTexture
  102699. * @param name defines the name fo the texture
  102700. * @param size defines the size of the texture (default is 256)
  102701. * @param scene defines the hosting scene
  102702. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  102703. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  102704. */
  102705. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102706. private _updateShaderUniforms;
  102707. protected _getDefines(): string;
  102708. /** Generate the current state of the procedural texture */
  102709. render(useCameraPostProcess?: boolean): void;
  102710. /**
  102711. * Serializes this noise procedural texture
  102712. * @returns a serialized noise procedural texture object
  102713. */
  102714. serialize(): any;
  102715. /**
  102716. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  102717. * @param parsedTexture defines parsed texture data
  102718. * @param scene defines the current scene
  102719. * @param rootUrl defines the root URL containing noise procedural texture information
  102720. * @returns a parsed NoiseProceduralTexture
  102721. */
  102722. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  102723. }
  102724. }
  102725. declare module BABYLON {
  102726. /**
  102727. * Raw cube texture where the raw buffers are passed in
  102728. */
  102729. export class RawCubeTexture extends CubeTexture {
  102730. /**
  102731. * Creates a cube texture where the raw buffers are passed in.
  102732. * @param scene defines the scene the texture is attached to
  102733. * @param data defines the array of data to use to create each face
  102734. * @param size defines the size of the textures
  102735. * @param format defines the format of the data
  102736. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102737. * @param generateMipMaps defines if the engine should generate the mip levels
  102738. * @param invertY defines if data must be stored with Y axis inverted
  102739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102740. * @param compression defines the compression used (null by default)
  102741. */
  102742. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  102743. /**
  102744. * Updates the raw cube texture.
  102745. * @param data defines the data to store
  102746. * @param format defines the data format
  102747. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102748. * @param invertY defines if data must be stored with Y axis inverted
  102749. * @param compression defines the compression used (null by default)
  102750. * @param level defines which level of the texture to update
  102751. */
  102752. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  102753. /**
  102754. * Updates a raw cube texture with RGBD encoded data.
  102755. * @param data defines the array of data [mipmap][face] to use to create each face
  102756. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  102757. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  102758. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  102759. * @returns a promsie that resolves when the operation is complete
  102760. */
  102761. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  102762. /**
  102763. * Clones the raw cube texture.
  102764. * @return a new cube texture
  102765. */
  102766. clone(): CubeTexture;
  102767. /** @hidden */
  102768. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102769. }
  102770. }
  102771. declare module BABYLON {
  102772. /**
  102773. * Class used to store 3D textures containing user data
  102774. */
  102775. export class RawTexture3D extends Texture {
  102776. /** Gets or sets the texture format to use */
  102777. format: number;
  102778. private _engine;
  102779. /**
  102780. * Create a new RawTexture3D
  102781. * @param data defines the data of the texture
  102782. * @param width defines the width of the texture
  102783. * @param height defines the height of the texture
  102784. * @param depth defines the depth of the texture
  102785. * @param format defines the texture format to use
  102786. * @param scene defines the hosting scene
  102787. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  102788. * @param invertY defines if texture must be stored with Y axis inverted
  102789. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  102790. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  102791. */
  102792. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  102793. /** Gets or sets the texture format to use */
  102794. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  102795. /**
  102796. * Update the texture with new data
  102797. * @param data defines the data to store in the texture
  102798. */
  102799. update(data: ArrayBufferView): void;
  102800. }
  102801. }
  102802. declare module BABYLON {
  102803. /**
  102804. * Creates a refraction texture used by refraction channel of the standard material.
  102805. * It is like a mirror but to see through a material.
  102806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102807. */
  102808. export class RefractionTexture extends RenderTargetTexture {
  102809. /**
  102810. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  102811. * 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.
  102812. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102813. */
  102814. refractionPlane: Plane;
  102815. /**
  102816. * Define how deep under the surface we should see.
  102817. */
  102818. depth: number;
  102819. /**
  102820. * Creates a refraction texture used by refraction channel of the standard material.
  102821. * It is like a mirror but to see through a material.
  102822. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102823. * @param name Define the texture name
  102824. * @param size Define the size of the underlying texture
  102825. * @param scene Define the scene the refraction belongs to
  102826. * @param generateMipMaps Define if we need to generate mips level for the refraction
  102827. */
  102828. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  102829. /**
  102830. * Clone the refraction texture.
  102831. * @returns the cloned texture
  102832. */
  102833. clone(): RefractionTexture;
  102834. /**
  102835. * Serialize the texture to a JSON representation you could use in Parse later on
  102836. * @returns the serialized JSON representation
  102837. */
  102838. serialize(): any;
  102839. }
  102840. }
  102841. declare module BABYLON {
  102842. /**
  102843. * Configuration for Draco compression
  102844. */
  102845. export interface IDracoCompressionConfiguration {
  102846. /**
  102847. * Configuration for the decoder.
  102848. */
  102849. decoder?: {
  102850. /**
  102851. * The url to the WebAssembly module.
  102852. */
  102853. wasmUrl?: string;
  102854. /**
  102855. * The url to the WebAssembly binary.
  102856. */
  102857. wasmBinaryUrl?: string;
  102858. /**
  102859. * The url to the fallback JavaScript module.
  102860. */
  102861. fallbackUrl?: string;
  102862. };
  102863. }
  102864. /**
  102865. * Draco compression (https://google.github.io/draco/)
  102866. *
  102867. * This class wraps the Draco module.
  102868. *
  102869. * **Encoder**
  102870. *
  102871. * The encoder is not currently implemented.
  102872. *
  102873. * **Decoder**
  102874. *
  102875. * 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.
  102876. *
  102877. * To update the configuration, use the following code:
  102878. * ```javascript
  102879. * DracoCompression.Configuration = {
  102880. * decoder: {
  102881. * wasmUrl: "<url to the WebAssembly library>",
  102882. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  102883. * fallbackUrl: "<url to the fallback JavaScript library>",
  102884. * }
  102885. * };
  102886. * ```
  102887. *
  102888. * 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.
  102889. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  102890. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  102891. *
  102892. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  102893. * ```javascript
  102894. * var dracoCompression = new DracoCompression();
  102895. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  102896. * [VertexBuffer.PositionKind]: 0
  102897. * });
  102898. * ```
  102899. *
  102900. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  102901. */
  102902. export class DracoCompression implements IDisposable {
  102903. private static _DecoderModulePromise;
  102904. /**
  102905. * The configuration. Defaults to the following urls:
  102906. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  102907. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  102908. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  102909. */
  102910. static Configuration: IDracoCompressionConfiguration;
  102911. /**
  102912. * Returns true if the decoder is available.
  102913. */
  102914. static readonly DecoderAvailable: boolean;
  102915. /**
  102916. * Constructor
  102917. */
  102918. constructor();
  102919. /**
  102920. * Stop all async operations and release resources.
  102921. */
  102922. dispose(): void;
  102923. /**
  102924. * Decode Draco compressed mesh data to vertex data.
  102925. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  102926. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  102927. * @returns A promise that resolves with the decoded vertex data
  102928. */
  102929. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  102930. [kind: string]: number;
  102931. }): Promise<VertexData>;
  102932. private static _GetDecoderModule;
  102933. private static _LoadScriptAsync;
  102934. private static _LoadFileAsync;
  102935. }
  102936. }
  102937. declare module BABYLON {
  102938. /**
  102939. * Class for building Constructive Solid Geometry
  102940. */
  102941. export class CSG {
  102942. private polygons;
  102943. /**
  102944. * The world matrix
  102945. */
  102946. matrix: Matrix;
  102947. /**
  102948. * Stores the position
  102949. */
  102950. position: Vector3;
  102951. /**
  102952. * Stores the rotation
  102953. */
  102954. rotation: Vector3;
  102955. /**
  102956. * Stores the rotation quaternion
  102957. */
  102958. rotationQuaternion: Nullable<Quaternion>;
  102959. /**
  102960. * Stores the scaling vector
  102961. */
  102962. scaling: Vector3;
  102963. /**
  102964. * Convert the Mesh to CSG
  102965. * @param mesh The Mesh to convert to CSG
  102966. * @returns A new CSG from the Mesh
  102967. */
  102968. static FromMesh(mesh: Mesh): CSG;
  102969. /**
  102970. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  102971. * @param polygons Polygons used to construct a CSG solid
  102972. */
  102973. private static FromPolygons;
  102974. /**
  102975. * Clones, or makes a deep copy, of the CSG
  102976. * @returns A new CSG
  102977. */
  102978. clone(): CSG;
  102979. /**
  102980. * Unions this CSG with another CSG
  102981. * @param csg The CSG to union against this CSG
  102982. * @returns The unioned CSG
  102983. */
  102984. union(csg: CSG): CSG;
  102985. /**
  102986. * Unions this CSG with another CSG in place
  102987. * @param csg The CSG to union against this CSG
  102988. */
  102989. unionInPlace(csg: CSG): void;
  102990. /**
  102991. * Subtracts this CSG with another CSG
  102992. * @param csg The CSG to subtract against this CSG
  102993. * @returns A new CSG
  102994. */
  102995. subtract(csg: CSG): CSG;
  102996. /**
  102997. * Subtracts this CSG with another CSG in place
  102998. * @param csg The CSG to subtact against this CSG
  102999. */
  103000. subtractInPlace(csg: CSG): void;
  103001. /**
  103002. * Intersect this CSG with another CSG
  103003. * @param csg The CSG to intersect against this CSG
  103004. * @returns A new CSG
  103005. */
  103006. intersect(csg: CSG): CSG;
  103007. /**
  103008. * Intersects this CSG with another CSG in place
  103009. * @param csg The CSG to intersect against this CSG
  103010. */
  103011. intersectInPlace(csg: CSG): void;
  103012. /**
  103013. * Return a new CSG solid with solid and empty space switched. This solid is
  103014. * not modified.
  103015. * @returns A new CSG solid with solid and empty space switched
  103016. */
  103017. inverse(): CSG;
  103018. /**
  103019. * Inverses the CSG in place
  103020. */
  103021. inverseInPlace(): void;
  103022. /**
  103023. * This is used to keep meshes transformations so they can be restored
  103024. * when we build back a Babylon Mesh
  103025. * NB : All CSG operations are performed in world coordinates
  103026. * @param csg The CSG to copy the transform attributes from
  103027. * @returns This CSG
  103028. */
  103029. copyTransformAttributes(csg: CSG): CSG;
  103030. /**
  103031. * Build Raw mesh from CSG
  103032. * Coordinates here are in world space
  103033. * @param name The name of the mesh geometry
  103034. * @param scene The Scene
  103035. * @param keepSubMeshes Specifies if the submeshes should be kept
  103036. * @returns A new Mesh
  103037. */
  103038. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103039. /**
  103040. * Build Mesh from CSG taking material and transforms into account
  103041. * @param name The name of the Mesh
  103042. * @param material The material of the Mesh
  103043. * @param scene The Scene
  103044. * @param keepSubMeshes Specifies if submeshes should be kept
  103045. * @returns The new Mesh
  103046. */
  103047. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103048. }
  103049. }
  103050. declare module BABYLON {
  103051. /**
  103052. * Class containing static functions to help procedurally build meshes
  103053. */
  103054. export class RibbonBuilder {
  103055. /**
  103056. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103057. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103058. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103059. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103060. * * 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
  103061. * * 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
  103062. * * 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
  103063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103065. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103066. * * 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
  103067. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103068. * * 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
  103069. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103071. * @param name defines the name of the mesh
  103072. * @param options defines the options used to create the mesh
  103073. * @param scene defines the hosting scene
  103074. * @returns the ribbon mesh
  103075. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103077. */
  103078. static CreateRibbon(name: string, options: {
  103079. pathArray: Vector3[][];
  103080. closeArray?: boolean;
  103081. closePath?: boolean;
  103082. offset?: number;
  103083. updatable?: boolean;
  103084. sideOrientation?: number;
  103085. frontUVs?: Vector4;
  103086. backUVs?: Vector4;
  103087. instance?: Mesh;
  103088. invertUV?: boolean;
  103089. uvs?: Vector2[];
  103090. colors?: Color4[];
  103091. }, scene?: Nullable<Scene>): Mesh;
  103092. }
  103093. }
  103094. declare module BABYLON {
  103095. /**
  103096. * Class containing static functions to help procedurally build meshes
  103097. */
  103098. export class TorusKnotBuilder {
  103099. /**
  103100. * Creates a torus knot mesh
  103101. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103102. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103103. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103104. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103108. * @param name defines the name of the mesh
  103109. * @param options defines the options used to create the mesh
  103110. * @param scene defines the hosting scene
  103111. * @returns the torus knot mesh
  103112. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103113. */
  103114. static CreateTorusKnot(name: string, options: {
  103115. radius?: number;
  103116. tube?: number;
  103117. radialSegments?: number;
  103118. tubularSegments?: number;
  103119. p?: number;
  103120. q?: number;
  103121. updatable?: boolean;
  103122. sideOrientation?: number;
  103123. frontUVs?: Vector4;
  103124. backUVs?: Vector4;
  103125. }, scene: any): Mesh;
  103126. }
  103127. }
  103128. declare module BABYLON {
  103129. /**
  103130. * Polygon
  103131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103132. */
  103133. export class Polygon {
  103134. /**
  103135. * Creates a rectangle
  103136. * @param xmin bottom X coord
  103137. * @param ymin bottom Y coord
  103138. * @param xmax top X coord
  103139. * @param ymax top Y coord
  103140. * @returns points that make the resulting rectation
  103141. */
  103142. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103143. /**
  103144. * Creates a circle
  103145. * @param radius radius of circle
  103146. * @param cx scale in x
  103147. * @param cy scale in y
  103148. * @param numberOfSides number of sides that make up the circle
  103149. * @returns points that make the resulting circle
  103150. */
  103151. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103152. /**
  103153. * Creates a polygon from input string
  103154. * @param input Input polygon data
  103155. * @returns the parsed points
  103156. */
  103157. static Parse(input: string): Vector2[];
  103158. /**
  103159. * Starts building a polygon from x and y coordinates
  103160. * @param x x coordinate
  103161. * @param y y coordinate
  103162. * @returns the started path2
  103163. */
  103164. static StartingAt(x: number, y: number): Path2;
  103165. }
  103166. /**
  103167. * Builds a polygon
  103168. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103169. */
  103170. export class PolygonMeshBuilder {
  103171. private _points;
  103172. private _outlinepoints;
  103173. private _holes;
  103174. private _name;
  103175. private _scene;
  103176. private _epoints;
  103177. private _eholes;
  103178. private _addToepoint;
  103179. /**
  103180. * Babylon reference to the earcut plugin.
  103181. */
  103182. bjsEarcut: any;
  103183. /**
  103184. * Creates a PolygonMeshBuilder
  103185. * @param name name of the builder
  103186. * @param contours Path of the polygon
  103187. * @param scene scene to add to
  103188. * @param earcutInjection can be used to inject your own earcut reference
  103189. */
  103190. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103191. /**
  103192. * Adds a whole within the polygon
  103193. * @param hole Array of points defining the hole
  103194. * @returns this
  103195. */
  103196. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103197. /**
  103198. * Creates the polygon
  103199. * @param updatable If the mesh should be updatable
  103200. * @param depth The depth of the mesh created
  103201. * @returns the created mesh
  103202. */
  103203. build(updatable?: boolean, depth?: number): Mesh;
  103204. /**
  103205. * Adds a side to the polygon
  103206. * @param positions points that make the polygon
  103207. * @param normals normals of the polygon
  103208. * @param uvs uvs of the polygon
  103209. * @param indices indices of the polygon
  103210. * @param bounds bounds of the polygon
  103211. * @param points points of the polygon
  103212. * @param depth depth of the polygon
  103213. * @param flip flip of the polygon
  103214. */
  103215. private addSide;
  103216. }
  103217. }
  103218. declare module BABYLON {
  103219. /**
  103220. * Class containing static functions to help procedurally build meshes
  103221. */
  103222. export class PolygonBuilder {
  103223. /**
  103224. * Creates a polygon mesh
  103225. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103226. * * 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
  103227. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103230. * * Remember you can only change the shape positions, not their number when updating a polygon
  103231. * @param name defines the name of the mesh
  103232. * @param options defines the options used to create the mesh
  103233. * @param scene defines the hosting scene
  103234. * @param earcutInjection can be used to inject your own earcut reference
  103235. * @returns the polygon mesh
  103236. */
  103237. static CreatePolygon(name: string, options: {
  103238. shape: Vector3[];
  103239. holes?: Vector3[][];
  103240. depth?: number;
  103241. faceUV?: Vector4[];
  103242. faceColors?: Color4[];
  103243. updatable?: boolean;
  103244. sideOrientation?: number;
  103245. frontUVs?: Vector4;
  103246. backUVs?: Vector4;
  103247. }, scene: Scene, earcutInjection?: any): Mesh;
  103248. /**
  103249. * Creates an extruded polygon mesh, with depth in the Y direction.
  103250. * * 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)
  103251. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103252. * @param name defines the name of the mesh
  103253. * @param options defines the options used to create the mesh
  103254. * @param scene defines the hosting scene
  103255. * @param earcutInjection can be used to inject your own earcut reference
  103256. * @returns the polygon mesh
  103257. */
  103258. static ExtrudePolygon(name: string, options: {
  103259. shape: Vector3[];
  103260. holes?: Vector3[][];
  103261. depth?: number;
  103262. faceUV?: Vector4[];
  103263. faceColors?: Color4[];
  103264. updatable?: boolean;
  103265. sideOrientation?: number;
  103266. frontUVs?: Vector4;
  103267. backUVs?: Vector4;
  103268. }, scene: Scene, earcutInjection?: any): Mesh;
  103269. }
  103270. }
  103271. declare module BABYLON {
  103272. /**
  103273. * Class containing static functions to help procedurally build meshes
  103274. */
  103275. export class ShapeBuilder {
  103276. /**
  103277. * 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.
  103278. * * 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.
  103279. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103280. * * 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.
  103281. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103282. * * 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
  103283. * * 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
  103284. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103286. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103287. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103289. * @param name defines the name of the mesh
  103290. * @param options defines the options used to create the mesh
  103291. * @param scene defines the hosting scene
  103292. * @returns the extruded shape mesh
  103293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103295. */
  103296. static ExtrudeShape(name: string, options: {
  103297. shape: Vector3[];
  103298. path: Vector3[];
  103299. scale?: number;
  103300. rotation?: number;
  103301. cap?: number;
  103302. updatable?: boolean;
  103303. sideOrientation?: number;
  103304. frontUVs?: Vector4;
  103305. backUVs?: Vector4;
  103306. instance?: Mesh;
  103307. invertUV?: boolean;
  103308. }, scene?: Nullable<Scene>): Mesh;
  103309. /**
  103310. * Creates an custom extruded shape mesh.
  103311. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103312. * * 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.
  103313. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103314. * * 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
  103315. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103316. * * 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
  103317. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103318. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103319. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103320. * * 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
  103321. * * 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
  103322. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103325. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103327. * @param name defines the name of the mesh
  103328. * @param options defines the options used to create the mesh
  103329. * @param scene defines the hosting scene
  103330. * @returns the custom extruded shape mesh
  103331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103332. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103334. */
  103335. static ExtrudeShapeCustom(name: string, options: {
  103336. shape: Vector3[];
  103337. path: Vector3[];
  103338. scaleFunction?: any;
  103339. rotationFunction?: any;
  103340. ribbonCloseArray?: boolean;
  103341. ribbonClosePath?: boolean;
  103342. cap?: number;
  103343. updatable?: boolean;
  103344. sideOrientation?: number;
  103345. frontUVs?: Vector4;
  103346. backUVs?: Vector4;
  103347. instance?: Mesh;
  103348. invertUV?: boolean;
  103349. }, scene: Scene): Mesh;
  103350. private static _ExtrudeShapeGeneric;
  103351. }
  103352. }
  103353. declare module BABYLON {
  103354. /**
  103355. * Class containing static functions to help procedurally build meshes
  103356. */
  103357. export class LatheBuilder {
  103358. /**
  103359. * Creates lathe mesh.
  103360. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103361. * * 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
  103362. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103363. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103364. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103365. * * 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
  103366. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103367. * * 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
  103368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103370. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103372. * @param name defines the name of the mesh
  103373. * @param options defines the options used to create the mesh
  103374. * @param scene defines the hosting scene
  103375. * @returns the lathe mesh
  103376. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103377. */
  103378. static CreateLathe(name: string, options: {
  103379. shape: Vector3[];
  103380. radius?: number;
  103381. tessellation?: number;
  103382. clip?: number;
  103383. arc?: number;
  103384. closed?: boolean;
  103385. updatable?: boolean;
  103386. sideOrientation?: number;
  103387. frontUVs?: Vector4;
  103388. backUVs?: Vector4;
  103389. cap?: number;
  103390. invertUV?: boolean;
  103391. }, scene: Scene): Mesh;
  103392. }
  103393. }
  103394. declare module BABYLON {
  103395. /**
  103396. * Class containing static functions to help procedurally build meshes
  103397. */
  103398. export class TubeBuilder {
  103399. /**
  103400. * Creates a tube mesh.
  103401. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103402. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103403. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103404. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103405. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103406. * * 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)
  103407. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103408. * * 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
  103409. * * 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
  103410. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103412. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103414. * @param name defines the name of the mesh
  103415. * @param options defines the options used to create the mesh
  103416. * @param scene defines the hosting scene
  103417. * @returns the tube mesh
  103418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103419. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103420. */
  103421. static CreateTube(name: string, options: {
  103422. path: Vector3[];
  103423. radius?: number;
  103424. tessellation?: number;
  103425. radiusFunction?: {
  103426. (i: number, distance: number): number;
  103427. };
  103428. cap?: number;
  103429. arc?: number;
  103430. updatable?: boolean;
  103431. sideOrientation?: number;
  103432. frontUVs?: Vector4;
  103433. backUVs?: Vector4;
  103434. instance?: Mesh;
  103435. invertUV?: boolean;
  103436. }, scene: Scene): Mesh;
  103437. }
  103438. }
  103439. declare module BABYLON {
  103440. /**
  103441. * Class containing static functions to help procedurally build meshes
  103442. */
  103443. export class IcoSphereBuilder {
  103444. /**
  103445. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103446. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103447. * * 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`)
  103448. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103449. * * 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
  103450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103453. * @param name defines the name of the mesh
  103454. * @param options defines the options used to create the mesh
  103455. * @param scene defines the hosting scene
  103456. * @returns the icosahedron mesh
  103457. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103458. */
  103459. static CreateIcoSphere(name: string, options: {
  103460. radius?: number;
  103461. radiusX?: number;
  103462. radiusY?: number;
  103463. radiusZ?: number;
  103464. flat?: boolean;
  103465. subdivisions?: number;
  103466. sideOrientation?: number;
  103467. frontUVs?: Vector4;
  103468. backUVs?: Vector4;
  103469. updatable?: boolean;
  103470. }, scene: Scene): Mesh;
  103471. }
  103472. }
  103473. declare module BABYLON {
  103474. /**
  103475. * Class containing static functions to help procedurally build meshes
  103476. */
  103477. export class DecalBuilder {
  103478. /**
  103479. * Creates a decal mesh.
  103480. * 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
  103481. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103482. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103483. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103484. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103485. * @param name defines the name of the mesh
  103486. * @param sourceMesh defines the mesh where the decal must be applied
  103487. * @param options defines the options used to create the mesh
  103488. * @param scene defines the hosting scene
  103489. * @returns the decal mesh
  103490. * @see https://doc.babylonjs.com/how_to/decals
  103491. */
  103492. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  103493. position?: Vector3;
  103494. normal?: Vector3;
  103495. size?: Vector3;
  103496. angle?: number;
  103497. }): Mesh;
  103498. }
  103499. }
  103500. declare module BABYLON {
  103501. /**
  103502. * Class containing static functions to help procedurally build meshes
  103503. */
  103504. export class MeshBuilder {
  103505. /**
  103506. * Creates a box mesh
  103507. * * The parameter `size` sets the size (float) of each box side (default 1)
  103508. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103509. * * 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)
  103510. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103514. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103515. * @param name defines the name of the mesh
  103516. * @param options defines the options used to create the mesh
  103517. * @param scene defines the hosting scene
  103518. * @returns the box mesh
  103519. */
  103520. static CreateBox(name: string, options: {
  103521. size?: number;
  103522. width?: number;
  103523. height?: number;
  103524. depth?: number;
  103525. faceUV?: Vector4[];
  103526. faceColors?: Color4[];
  103527. sideOrientation?: number;
  103528. frontUVs?: Vector4;
  103529. backUVs?: Vector4;
  103530. updatable?: boolean;
  103531. }, scene?: Nullable<Scene>): Mesh;
  103532. /**
  103533. * Creates a sphere mesh
  103534. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103535. * * 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`)
  103536. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103537. * * 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
  103538. * * 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)
  103539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103542. * @param name defines the name of the mesh
  103543. * @param options defines the options used to create the mesh
  103544. * @param scene defines the hosting scene
  103545. * @returns the sphere mesh
  103546. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103547. */
  103548. static CreateSphere(name: string, options: {
  103549. segments?: number;
  103550. diameter?: number;
  103551. diameterX?: number;
  103552. diameterY?: number;
  103553. diameterZ?: number;
  103554. arc?: number;
  103555. slice?: number;
  103556. sideOrientation?: number;
  103557. frontUVs?: Vector4;
  103558. backUVs?: Vector4;
  103559. updatable?: boolean;
  103560. }, scene: any): Mesh;
  103561. /**
  103562. * Creates a plane polygonal mesh. By default, this is a disc
  103563. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103564. * * 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
  103565. * * 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
  103566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103569. * @param name defines the name of the mesh
  103570. * @param options defines the options used to create the mesh
  103571. * @param scene defines the hosting scene
  103572. * @returns the plane polygonal mesh
  103573. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103574. */
  103575. static CreateDisc(name: string, options: {
  103576. radius?: number;
  103577. tessellation?: number;
  103578. arc?: number;
  103579. updatable?: boolean;
  103580. sideOrientation?: number;
  103581. frontUVs?: Vector4;
  103582. backUVs?: Vector4;
  103583. }, scene?: Nullable<Scene>): Mesh;
  103584. /**
  103585. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103586. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103587. * * 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`)
  103588. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103589. * * 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
  103590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103593. * @param name defines the name of the mesh
  103594. * @param options defines the options used to create the mesh
  103595. * @param scene defines the hosting scene
  103596. * @returns the icosahedron mesh
  103597. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103598. */
  103599. static CreateIcoSphere(name: string, options: {
  103600. radius?: number;
  103601. radiusX?: number;
  103602. radiusY?: number;
  103603. radiusZ?: number;
  103604. flat?: boolean;
  103605. subdivisions?: number;
  103606. sideOrientation?: number;
  103607. frontUVs?: Vector4;
  103608. backUVs?: Vector4;
  103609. updatable?: boolean;
  103610. }, scene: Scene): Mesh;
  103611. /**
  103612. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103613. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103614. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103615. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103616. * * 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
  103617. * * 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
  103618. * * 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
  103619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103621. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103622. * * 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
  103623. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103624. * * 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
  103625. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103627. * @param name defines the name of the mesh
  103628. * @param options defines the options used to create the mesh
  103629. * @param scene defines the hosting scene
  103630. * @returns the ribbon mesh
  103631. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103633. */
  103634. static CreateRibbon(name: string, options: {
  103635. pathArray: Vector3[][];
  103636. closeArray?: boolean;
  103637. closePath?: boolean;
  103638. offset?: number;
  103639. updatable?: boolean;
  103640. sideOrientation?: number;
  103641. frontUVs?: Vector4;
  103642. backUVs?: Vector4;
  103643. instance?: Mesh;
  103644. invertUV?: boolean;
  103645. uvs?: Vector2[];
  103646. colors?: Color4[];
  103647. }, scene?: Nullable<Scene>): Mesh;
  103648. /**
  103649. * Creates a cylinder or a cone mesh
  103650. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103651. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103652. * * 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.
  103653. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103654. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103655. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103656. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103657. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103658. * * 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).
  103659. * * 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
  103660. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103661. * * 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
  103662. * * 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.
  103663. * * If `enclose` is false, a ring surface is one element.
  103664. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103665. * * 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
  103666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103669. * @param name defines the name of the mesh
  103670. * @param options defines the options used to create the mesh
  103671. * @param scene defines the hosting scene
  103672. * @returns the cylinder mesh
  103673. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103674. */
  103675. static CreateCylinder(name: string, options: {
  103676. height?: number;
  103677. diameterTop?: number;
  103678. diameterBottom?: number;
  103679. diameter?: number;
  103680. tessellation?: number;
  103681. subdivisions?: number;
  103682. arc?: number;
  103683. faceColors?: Color4[];
  103684. faceUV?: Vector4[];
  103685. updatable?: boolean;
  103686. hasRings?: boolean;
  103687. enclose?: boolean;
  103688. sideOrientation?: number;
  103689. frontUVs?: Vector4;
  103690. backUVs?: Vector4;
  103691. }, scene: any): Mesh;
  103692. /**
  103693. * Creates a torus mesh
  103694. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103695. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103696. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103700. * @param name defines the name of the mesh
  103701. * @param options defines the options used to create the mesh
  103702. * @param scene defines the hosting scene
  103703. * @returns the torus mesh
  103704. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103705. */
  103706. static CreateTorus(name: string, options: {
  103707. diameter?: number;
  103708. thickness?: number;
  103709. tessellation?: number;
  103710. updatable?: boolean;
  103711. sideOrientation?: number;
  103712. frontUVs?: Vector4;
  103713. backUVs?: Vector4;
  103714. }, scene: any): Mesh;
  103715. /**
  103716. * Creates a torus knot mesh
  103717. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103718. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103719. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103720. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103724. * @param name defines the name of the mesh
  103725. * @param options defines the options used to create the mesh
  103726. * @param scene defines the hosting scene
  103727. * @returns the torus knot mesh
  103728. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103729. */
  103730. static CreateTorusKnot(name: string, options: {
  103731. radius?: number;
  103732. tube?: number;
  103733. radialSegments?: number;
  103734. tubularSegments?: number;
  103735. p?: number;
  103736. q?: number;
  103737. updatable?: boolean;
  103738. sideOrientation?: number;
  103739. frontUVs?: Vector4;
  103740. backUVs?: Vector4;
  103741. }, scene: any): Mesh;
  103742. /**
  103743. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103744. * * 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
  103745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103746. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103747. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103748. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103749. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103750. * * 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
  103751. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103754. * @param name defines the name of the new line system
  103755. * @param options defines the options used to create the line system
  103756. * @param scene defines the hosting scene
  103757. * @returns a new line system mesh
  103758. */
  103759. static CreateLineSystem(name: string, options: {
  103760. lines: Vector3[][];
  103761. updatable?: boolean;
  103762. instance?: Nullable<LinesMesh>;
  103763. colors?: Nullable<Color4[][]>;
  103764. useVertexAlpha?: boolean;
  103765. }, scene: Nullable<Scene>): LinesMesh;
  103766. /**
  103767. * Creates a line mesh
  103768. * 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
  103769. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103770. * * The parameter `points` is an array successive Vector3
  103771. * * 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
  103772. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103773. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103774. * * When updating an instance, remember that only point positions can change, not the number of points
  103775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103777. * @param name defines the name of the new line system
  103778. * @param options defines the options used to create the line system
  103779. * @param scene defines the hosting scene
  103780. * @returns a new line mesh
  103781. */
  103782. static CreateLines(name: string, options: {
  103783. points: Vector3[];
  103784. updatable?: boolean;
  103785. instance?: Nullable<LinesMesh>;
  103786. colors?: Color4[];
  103787. useVertexAlpha?: boolean;
  103788. }, scene?: Nullable<Scene>): LinesMesh;
  103789. /**
  103790. * Creates a dashed line mesh
  103791. * * 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
  103792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103793. * * The parameter `points` is an array successive Vector3
  103794. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103795. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103796. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103797. * * 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
  103798. * * When updating an instance, remember that only point positions can change, not the number of points
  103799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103800. * @param name defines the name of the mesh
  103801. * @param options defines the options used to create the mesh
  103802. * @param scene defines the hosting scene
  103803. * @returns the dashed line mesh
  103804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103805. */
  103806. static CreateDashedLines(name: string, options: {
  103807. points: Vector3[];
  103808. dashSize?: number;
  103809. gapSize?: number;
  103810. dashNb?: number;
  103811. updatable?: boolean;
  103812. instance?: LinesMesh;
  103813. }, scene?: Nullable<Scene>): LinesMesh;
  103814. /**
  103815. * 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.
  103816. * * 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.
  103817. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103818. * * 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.
  103819. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103820. * * 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
  103821. * * 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
  103822. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103827. * @param name defines the name of the mesh
  103828. * @param options defines the options used to create the mesh
  103829. * @param scene defines the hosting scene
  103830. * @returns the extruded shape mesh
  103831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103833. */
  103834. static ExtrudeShape(name: string, options: {
  103835. shape: Vector3[];
  103836. path: Vector3[];
  103837. scale?: number;
  103838. rotation?: number;
  103839. cap?: number;
  103840. updatable?: boolean;
  103841. sideOrientation?: number;
  103842. frontUVs?: Vector4;
  103843. backUVs?: Vector4;
  103844. instance?: Mesh;
  103845. invertUV?: boolean;
  103846. }, scene?: Nullable<Scene>): Mesh;
  103847. /**
  103848. * Creates an custom extruded shape mesh.
  103849. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103850. * * 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.
  103851. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103852. * * 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
  103853. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103854. * * 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
  103855. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103856. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103857. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103858. * * 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
  103859. * * 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
  103860. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103865. * @param name defines the name of the mesh
  103866. * @param options defines the options used to create the mesh
  103867. * @param scene defines the hosting scene
  103868. * @returns the custom extruded shape mesh
  103869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103872. */
  103873. static ExtrudeShapeCustom(name: string, options: {
  103874. shape: Vector3[];
  103875. path: Vector3[];
  103876. scaleFunction?: any;
  103877. rotationFunction?: any;
  103878. ribbonCloseArray?: boolean;
  103879. ribbonClosePath?: boolean;
  103880. cap?: number;
  103881. updatable?: boolean;
  103882. sideOrientation?: number;
  103883. frontUVs?: Vector4;
  103884. backUVs?: Vector4;
  103885. instance?: Mesh;
  103886. invertUV?: boolean;
  103887. }, scene: Scene): Mesh;
  103888. /**
  103889. * Creates lathe mesh.
  103890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103891. * * 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
  103892. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103893. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103894. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103895. * * 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
  103896. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103897. * * 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
  103898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103902. * @param name defines the name of the mesh
  103903. * @param options defines the options used to create the mesh
  103904. * @param scene defines the hosting scene
  103905. * @returns the lathe mesh
  103906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103907. */
  103908. static CreateLathe(name: string, options: {
  103909. shape: Vector3[];
  103910. radius?: number;
  103911. tessellation?: number;
  103912. clip?: number;
  103913. arc?: number;
  103914. closed?: boolean;
  103915. updatable?: boolean;
  103916. sideOrientation?: number;
  103917. frontUVs?: Vector4;
  103918. backUVs?: Vector4;
  103919. cap?: number;
  103920. invertUV?: boolean;
  103921. }, scene: Scene): Mesh;
  103922. /**
  103923. * Creates a plane mesh
  103924. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103925. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103926. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103930. * @param name defines the name of the mesh
  103931. * @param options defines the options used to create the mesh
  103932. * @param scene defines the hosting scene
  103933. * @returns the plane mesh
  103934. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103935. */
  103936. static CreatePlane(name: string, options: {
  103937. size?: number;
  103938. width?: number;
  103939. height?: number;
  103940. sideOrientation?: number;
  103941. frontUVs?: Vector4;
  103942. backUVs?: Vector4;
  103943. updatable?: boolean;
  103944. sourcePlane?: Plane;
  103945. }, scene: Scene): Mesh;
  103946. /**
  103947. * Creates a ground mesh
  103948. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103949. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103951. * @param name defines the name of the mesh
  103952. * @param options defines the options used to create the mesh
  103953. * @param scene defines the hosting scene
  103954. * @returns the ground mesh
  103955. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  103956. */
  103957. static CreateGround(name: string, options: {
  103958. width?: number;
  103959. height?: number;
  103960. subdivisions?: number;
  103961. subdivisionsX?: number;
  103962. subdivisionsY?: number;
  103963. updatable?: boolean;
  103964. }, scene: any): Mesh;
  103965. /**
  103966. * Creates a tiled ground mesh
  103967. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  103968. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  103969. * * 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
  103970. * * 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
  103971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103972. * @param name defines the name of the mesh
  103973. * @param options defines the options used to create the mesh
  103974. * @param scene defines the hosting scene
  103975. * @returns the tiled ground mesh
  103976. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  103977. */
  103978. static CreateTiledGround(name: string, options: {
  103979. xmin: number;
  103980. zmin: number;
  103981. xmax: number;
  103982. zmax: number;
  103983. subdivisions?: {
  103984. w: number;
  103985. h: number;
  103986. };
  103987. precision?: {
  103988. w: number;
  103989. h: number;
  103990. };
  103991. updatable?: boolean;
  103992. }, scene: Scene): Mesh;
  103993. /**
  103994. * Creates a ground mesh from a height map
  103995. * * The parameter `url` sets the URL of the height map image resource.
  103996. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103997. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103998. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103999. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104000. * * 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.
  104001. * * 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).
  104002. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104004. * @param name defines the name of the mesh
  104005. * @param url defines the url to the height map
  104006. * @param options defines the options used to create the mesh
  104007. * @param scene defines the hosting scene
  104008. * @returns the ground mesh
  104009. * @see https://doc.babylonjs.com/babylon101/height_map
  104010. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104011. */
  104012. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104013. width?: number;
  104014. height?: number;
  104015. subdivisions?: number;
  104016. minHeight?: number;
  104017. maxHeight?: number;
  104018. colorFilter?: Color3;
  104019. alphaFilter?: number;
  104020. updatable?: boolean;
  104021. onReady?: (mesh: GroundMesh) => void;
  104022. }, scene: Scene): GroundMesh;
  104023. /**
  104024. * Creates a polygon mesh
  104025. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104026. * * 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
  104027. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104030. * * Remember you can only change the shape positions, not their number when updating a polygon
  104031. * @param name defines the name of the mesh
  104032. * @param options defines the options used to create the mesh
  104033. * @param scene defines the hosting scene
  104034. * @param earcutInjection can be used to inject your own earcut reference
  104035. * @returns the polygon mesh
  104036. */
  104037. static CreatePolygon(name: string, options: {
  104038. shape: Vector3[];
  104039. holes?: Vector3[][];
  104040. depth?: number;
  104041. faceUV?: Vector4[];
  104042. faceColors?: Color4[];
  104043. updatable?: boolean;
  104044. sideOrientation?: number;
  104045. frontUVs?: Vector4;
  104046. backUVs?: Vector4;
  104047. }, scene: Scene, earcutInjection?: any): Mesh;
  104048. /**
  104049. * Creates an extruded polygon mesh, with depth in the Y direction.
  104050. * * 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)
  104051. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104052. * @param name defines the name of the mesh
  104053. * @param options defines the options used to create the mesh
  104054. * @param scene defines the hosting scene
  104055. * @param earcutInjection can be used to inject your own earcut reference
  104056. * @returns the polygon mesh
  104057. */
  104058. static ExtrudePolygon(name: string, options: {
  104059. shape: Vector3[];
  104060. holes?: Vector3[][];
  104061. depth?: number;
  104062. faceUV?: Vector4[];
  104063. faceColors?: Color4[];
  104064. updatable?: boolean;
  104065. sideOrientation?: number;
  104066. frontUVs?: Vector4;
  104067. backUVs?: Vector4;
  104068. }, scene: Scene, earcutInjection?: any): Mesh;
  104069. /**
  104070. * Creates a tube mesh.
  104071. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104072. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104073. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104074. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104075. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104076. * * 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)
  104077. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104078. * * 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
  104079. * * 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
  104080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104084. * @param name defines the name of the mesh
  104085. * @param options defines the options used to create the mesh
  104086. * @param scene defines the hosting scene
  104087. * @returns the tube mesh
  104088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104089. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104090. */
  104091. static CreateTube(name: string, options: {
  104092. path: Vector3[];
  104093. radius?: number;
  104094. tessellation?: number;
  104095. radiusFunction?: {
  104096. (i: number, distance: number): number;
  104097. };
  104098. cap?: number;
  104099. arc?: number;
  104100. updatable?: boolean;
  104101. sideOrientation?: number;
  104102. frontUVs?: Vector4;
  104103. backUVs?: Vector4;
  104104. instance?: Mesh;
  104105. invertUV?: boolean;
  104106. }, scene: Scene): Mesh;
  104107. /**
  104108. * Creates a polyhedron mesh
  104109. * * 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
  104110. * * The parameter `size` (positive float, default 1) sets the polygon size
  104111. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104112. * * 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`
  104113. * * 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
  104114. * * 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)`)
  104115. * * 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
  104116. * * 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
  104117. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104120. * @param name defines the name of the mesh
  104121. * @param options defines the options used to create the mesh
  104122. * @param scene defines the hosting scene
  104123. * @returns the polyhedron mesh
  104124. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104125. */
  104126. static CreatePolyhedron(name: string, options: {
  104127. type?: number;
  104128. size?: number;
  104129. sizeX?: number;
  104130. sizeY?: number;
  104131. sizeZ?: number;
  104132. custom?: any;
  104133. faceUV?: Vector4[];
  104134. faceColors?: Color4[];
  104135. flat?: boolean;
  104136. updatable?: boolean;
  104137. sideOrientation?: number;
  104138. frontUVs?: Vector4;
  104139. backUVs?: Vector4;
  104140. }, scene: Scene): Mesh;
  104141. /**
  104142. * Creates a decal mesh.
  104143. * 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
  104144. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104145. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104146. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104147. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104148. * @param name defines the name of the mesh
  104149. * @param sourceMesh defines the mesh where the decal must be applied
  104150. * @param options defines the options used to create the mesh
  104151. * @param scene defines the hosting scene
  104152. * @returns the decal mesh
  104153. * @see https://doc.babylonjs.com/how_to/decals
  104154. */
  104155. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104156. position?: Vector3;
  104157. normal?: Vector3;
  104158. size?: Vector3;
  104159. angle?: number;
  104160. }): Mesh;
  104161. }
  104162. }
  104163. declare module BABYLON {
  104164. /**
  104165. * A simplifier interface for future simplification implementations
  104166. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104167. */
  104168. export interface ISimplifier {
  104169. /**
  104170. * Simplification of a given mesh according to the given settings.
  104171. * Since this requires computation, it is assumed that the function runs async.
  104172. * @param settings The settings of the simplification, including quality and distance
  104173. * @param successCallback A callback that will be called after the mesh was simplified.
  104174. * @param errorCallback in case of an error, this callback will be called. optional.
  104175. */
  104176. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104177. }
  104178. /**
  104179. * Expected simplification settings.
  104180. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104181. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104182. */
  104183. export interface ISimplificationSettings {
  104184. /**
  104185. * Gets or sets the expected quality
  104186. */
  104187. quality: number;
  104188. /**
  104189. * Gets or sets the distance when this optimized version should be used
  104190. */
  104191. distance: number;
  104192. /**
  104193. * Gets an already optimized mesh
  104194. */
  104195. optimizeMesh?: boolean;
  104196. }
  104197. /**
  104198. * Class used to specify simplification options
  104199. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104200. */
  104201. export class SimplificationSettings implements ISimplificationSettings {
  104202. /** expected quality */
  104203. quality: number;
  104204. /** distance when this optimized version should be used */
  104205. distance: number;
  104206. /** already optimized mesh */
  104207. optimizeMesh?: boolean | undefined;
  104208. /**
  104209. * Creates a SimplificationSettings
  104210. * @param quality expected quality
  104211. * @param distance distance when this optimized version should be used
  104212. * @param optimizeMesh already optimized mesh
  104213. */
  104214. constructor(
  104215. /** expected quality */
  104216. quality: number,
  104217. /** distance when this optimized version should be used */
  104218. distance: number,
  104219. /** already optimized mesh */
  104220. optimizeMesh?: boolean | undefined);
  104221. }
  104222. /**
  104223. * Interface used to define a simplification task
  104224. */
  104225. export interface ISimplificationTask {
  104226. /**
  104227. * Array of settings
  104228. */
  104229. settings: Array<ISimplificationSettings>;
  104230. /**
  104231. * Simplification type
  104232. */
  104233. simplificationType: SimplificationType;
  104234. /**
  104235. * Mesh to simplify
  104236. */
  104237. mesh: Mesh;
  104238. /**
  104239. * Callback called on success
  104240. */
  104241. successCallback?: () => void;
  104242. /**
  104243. * Defines if parallel processing can be used
  104244. */
  104245. parallelProcessing: boolean;
  104246. }
  104247. /**
  104248. * Queue used to order the simplification tasks
  104249. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104250. */
  104251. export class SimplificationQueue {
  104252. private _simplificationArray;
  104253. /**
  104254. * Gets a boolean indicating that the process is still running
  104255. */
  104256. running: boolean;
  104257. /**
  104258. * Creates a new queue
  104259. */
  104260. constructor();
  104261. /**
  104262. * Adds a new simplification task
  104263. * @param task defines a task to add
  104264. */
  104265. addTask(task: ISimplificationTask): void;
  104266. /**
  104267. * Execute next task
  104268. */
  104269. executeNext(): void;
  104270. /**
  104271. * Execute a simplification task
  104272. * @param task defines the task to run
  104273. */
  104274. runSimplification(task: ISimplificationTask): void;
  104275. private getSimplifier;
  104276. }
  104277. /**
  104278. * The implemented types of simplification
  104279. * At the moment only Quadratic Error Decimation is implemented
  104280. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104281. */
  104282. export enum SimplificationType {
  104283. /** Quadratic error decimation */
  104284. QUADRATIC = 0
  104285. }
  104286. }
  104287. declare module BABYLON {
  104288. interface Scene {
  104289. /** @hidden (Backing field) */
  104290. _simplificationQueue: SimplificationQueue;
  104291. /**
  104292. * Gets or sets the simplification queue attached to the scene
  104293. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104294. */
  104295. simplificationQueue: SimplificationQueue;
  104296. }
  104297. interface Mesh {
  104298. /**
  104299. * Simplify the mesh according to the given array of settings.
  104300. * Function will return immediately and will simplify async
  104301. * @param settings a collection of simplification settings
  104302. * @param parallelProcessing should all levels calculate parallel or one after the other
  104303. * @param simplificationType the type of simplification to run
  104304. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  104305. * @returns the current mesh
  104306. */
  104307. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  104308. }
  104309. /**
  104310. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104311. * created in a scene
  104312. */
  104313. export class SimplicationQueueSceneComponent implements ISceneComponent {
  104314. /**
  104315. * The component name helpfull to identify the component in the list of scene components.
  104316. */
  104317. readonly name: string;
  104318. /**
  104319. * The scene the component belongs to.
  104320. */
  104321. scene: Scene;
  104322. /**
  104323. * Creates a new instance of the component for the given scene
  104324. * @param scene Defines the scene to register the component in
  104325. */
  104326. constructor(scene: Scene);
  104327. /**
  104328. * Registers the component in a given scene
  104329. */
  104330. register(): void;
  104331. /**
  104332. * Rebuilds the elements related to this component in case of
  104333. * context lost for instance.
  104334. */
  104335. rebuild(): void;
  104336. /**
  104337. * Disposes the component and the associated ressources
  104338. */
  104339. dispose(): void;
  104340. private _beforeCameraUpdate;
  104341. }
  104342. }
  104343. declare module BABYLON {
  104344. /**
  104345. * Class used to enable access to IndexedDB
  104346. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104347. */
  104348. export class Database implements IOfflineProvider {
  104349. private _callbackManifestChecked;
  104350. private _currentSceneUrl;
  104351. private _db;
  104352. private _enableSceneOffline;
  104353. private _enableTexturesOffline;
  104354. private _manifestVersionFound;
  104355. private _mustUpdateRessources;
  104356. private _hasReachedQuota;
  104357. private _isSupported;
  104358. private _idbFactory;
  104359. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104360. private static IsUASupportingBlobStorage;
  104361. /**
  104362. * Gets a boolean indicating if Database storate is enabled (off by default)
  104363. */
  104364. static IDBStorageEnabled: boolean;
  104365. /**
  104366. * Gets a boolean indicating if scene must be saved in the database
  104367. */
  104368. readonly enableSceneOffline: boolean;
  104369. /**
  104370. * Gets a boolean indicating if textures must be saved in the database
  104371. */
  104372. readonly enableTexturesOffline: boolean;
  104373. /**
  104374. * Creates a new Database
  104375. * @param urlToScene defines the url to load the scene
  104376. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104377. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104378. */
  104379. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  104380. private static _ParseURL;
  104381. private static _ReturnFullUrlLocation;
  104382. private _checkManifestFile;
  104383. /**
  104384. * Open the database and make it available
  104385. * @param successCallback defines the callback to call on success
  104386. * @param errorCallback defines the callback to call on error
  104387. */
  104388. open(successCallback: () => void, errorCallback: () => void): void;
  104389. /**
  104390. * Loads an image from the database
  104391. * @param url defines the url to load from
  104392. * @param image defines the target DOM image
  104393. */
  104394. loadImage(url: string, image: HTMLImageElement): void;
  104395. private _loadImageFromDBAsync;
  104396. private _saveImageIntoDBAsync;
  104397. private _checkVersionFromDB;
  104398. private _loadVersionFromDBAsync;
  104399. private _saveVersionIntoDBAsync;
  104400. /**
  104401. * Loads a file from database
  104402. * @param url defines the URL to load from
  104403. * @param sceneLoaded defines a callback to call on success
  104404. * @param progressCallBack defines a callback to call when progress changed
  104405. * @param errorCallback defines a callback to call on error
  104406. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104407. */
  104408. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  104409. private _loadFileAsync;
  104410. private _saveFileAsync;
  104411. /**
  104412. * Validates if xhr data is correct
  104413. * @param xhr defines the request to validate
  104414. * @param dataType defines the expected data type
  104415. * @returns true if data is correct
  104416. */
  104417. private static _ValidateXHRData;
  104418. }
  104419. }
  104420. declare module BABYLON {
  104421. /** @hidden */
  104422. export var gpuUpdateParticlesPixelShader: {
  104423. name: string;
  104424. shader: string;
  104425. };
  104426. }
  104427. declare module BABYLON {
  104428. /** @hidden */
  104429. export var gpuUpdateParticlesVertexShader: {
  104430. name: string;
  104431. shader: string;
  104432. };
  104433. }
  104434. declare module BABYLON {
  104435. /** @hidden */
  104436. export var clipPlaneFragmentDeclaration2: {
  104437. name: string;
  104438. shader: string;
  104439. };
  104440. }
  104441. declare module BABYLON {
  104442. /** @hidden */
  104443. export var gpuRenderParticlesPixelShader: {
  104444. name: string;
  104445. shader: string;
  104446. };
  104447. }
  104448. declare module BABYLON {
  104449. /** @hidden */
  104450. export var clipPlaneVertexDeclaration2: {
  104451. name: string;
  104452. shader: string;
  104453. };
  104454. }
  104455. declare module BABYLON {
  104456. /** @hidden */
  104457. export var gpuRenderParticlesVertexShader: {
  104458. name: string;
  104459. shader: string;
  104460. };
  104461. }
  104462. declare module BABYLON {
  104463. /**
  104464. * This represents a GPU particle system in Babylon
  104465. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104466. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104467. */
  104468. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  104469. /**
  104470. * The layer mask we are rendering the particles through.
  104471. */
  104472. layerMask: number;
  104473. private _capacity;
  104474. private _activeCount;
  104475. private _currentActiveCount;
  104476. private _accumulatedCount;
  104477. private _renderEffect;
  104478. private _updateEffect;
  104479. private _buffer0;
  104480. private _buffer1;
  104481. private _spriteBuffer;
  104482. private _updateVAO;
  104483. private _renderVAO;
  104484. private _targetIndex;
  104485. private _sourceBuffer;
  104486. private _targetBuffer;
  104487. private _engine;
  104488. private _currentRenderId;
  104489. private _started;
  104490. private _stopped;
  104491. private _timeDelta;
  104492. private _randomTexture;
  104493. private _randomTexture2;
  104494. private _attributesStrideSize;
  104495. private _updateEffectOptions;
  104496. private _randomTextureSize;
  104497. private _actualFrame;
  104498. private readonly _rawTextureWidth;
  104499. /**
  104500. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104501. */
  104502. static readonly IsSupported: boolean;
  104503. /**
  104504. * An event triggered when the system is disposed.
  104505. */
  104506. onDisposeObservable: Observable<GPUParticleSystem>;
  104507. /**
  104508. * Gets the maximum number of particles active at the same time.
  104509. * @returns The max number of active particles.
  104510. */
  104511. getCapacity(): number;
  104512. /**
  104513. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104514. * to override the particles.
  104515. */
  104516. forceDepthWrite: boolean;
  104517. /**
  104518. * Gets or set the number of active particles
  104519. */
  104520. activeParticleCount: number;
  104521. private _preWarmDone;
  104522. /**
  104523. * Is this system ready to be used/rendered
  104524. * @return true if the system is ready
  104525. */
  104526. isReady(): boolean;
  104527. /**
  104528. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104529. * @returns True if it has been started, otherwise false.
  104530. */
  104531. isStarted(): boolean;
  104532. /**
  104533. * Starts the particle system and begins to emit
  104534. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104535. */
  104536. start(delay?: number): void;
  104537. /**
  104538. * Stops the particle system.
  104539. */
  104540. stop(): void;
  104541. /**
  104542. * Remove all active particles
  104543. */
  104544. reset(): void;
  104545. /**
  104546. * Returns the string "GPUParticleSystem"
  104547. * @returns a string containing the class name
  104548. */
  104549. getClassName(): string;
  104550. private _colorGradientsTexture;
  104551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  104552. /**
  104553. * Adds a new color gradient
  104554. * @param gradient defines the gradient to use (between 0 and 1)
  104555. * @param color1 defines the color to affect to the specified gradient
  104556. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104557. * @returns the current particle system
  104558. */
  104559. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  104560. /**
  104561. * Remove a specific color gradient
  104562. * @param gradient defines the gradient to remove
  104563. * @returns the current particle system
  104564. */
  104565. removeColorGradient(gradient: number): GPUParticleSystem;
  104566. private _angularSpeedGradientsTexture;
  104567. private _sizeGradientsTexture;
  104568. private _velocityGradientsTexture;
  104569. private _limitVelocityGradientsTexture;
  104570. private _dragGradientsTexture;
  104571. private _addFactorGradient;
  104572. /**
  104573. * Adds a new size gradient
  104574. * @param gradient defines the gradient to use (between 0 and 1)
  104575. * @param factor defines the size factor to affect to the specified gradient
  104576. * @returns the current particle system
  104577. */
  104578. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  104579. /**
  104580. * Remove a specific size gradient
  104581. * @param gradient defines the gradient to remove
  104582. * @returns the current particle system
  104583. */
  104584. removeSizeGradient(gradient: number): GPUParticleSystem;
  104585. /**
  104586. * Adds a new angular speed gradient
  104587. * @param gradient defines the gradient to use (between 0 and 1)
  104588. * @param factor defines the angular speed to affect to the specified gradient
  104589. * @returns the current particle system
  104590. */
  104591. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  104592. /**
  104593. * Remove a specific angular speed gradient
  104594. * @param gradient defines the gradient to remove
  104595. * @returns the current particle system
  104596. */
  104597. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  104598. /**
  104599. * Adds a new velocity gradient
  104600. * @param gradient defines the gradient to use (between 0 and 1)
  104601. * @param factor defines the velocity to affect to the specified gradient
  104602. * @returns the current particle system
  104603. */
  104604. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104605. /**
  104606. * Remove a specific velocity gradient
  104607. * @param gradient defines the gradient to remove
  104608. * @returns the current particle system
  104609. */
  104610. removeVelocityGradient(gradient: number): GPUParticleSystem;
  104611. /**
  104612. * Adds a new limit velocity gradient
  104613. * @param gradient defines the gradient to use (between 0 and 1)
  104614. * @param factor defines the limit velocity value to affect to the specified gradient
  104615. * @returns the current particle system
  104616. */
  104617. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104618. /**
  104619. * Remove a specific limit velocity gradient
  104620. * @param gradient defines the gradient to remove
  104621. * @returns the current particle system
  104622. */
  104623. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  104624. /**
  104625. * Adds a new drag gradient
  104626. * @param gradient defines the gradient to use (between 0 and 1)
  104627. * @param factor defines the drag value to affect to the specified gradient
  104628. * @returns the current particle system
  104629. */
  104630. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  104631. /**
  104632. * Remove a specific drag gradient
  104633. * @param gradient defines the gradient to remove
  104634. * @returns the current particle system
  104635. */
  104636. removeDragGradient(gradient: number): GPUParticleSystem;
  104637. /**
  104638. * Not supported by GPUParticleSystem
  104639. * @param gradient defines the gradient to use (between 0 and 1)
  104640. * @param factor defines the emit rate value to affect to the specified gradient
  104641. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104642. * @returns the current particle system
  104643. */
  104644. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104645. /**
  104646. * Not supported by GPUParticleSystem
  104647. * @param gradient defines the gradient to remove
  104648. * @returns the current particle system
  104649. */
  104650. removeEmitRateGradient(gradient: number): IParticleSystem;
  104651. /**
  104652. * Not supported by GPUParticleSystem
  104653. * @param gradient defines the gradient to use (between 0 and 1)
  104654. * @param factor defines the start size value to affect to the specified gradient
  104655. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104656. * @returns the current particle system
  104657. */
  104658. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104659. /**
  104660. * Not supported by GPUParticleSystem
  104661. * @param gradient defines the gradient to remove
  104662. * @returns the current particle system
  104663. */
  104664. removeStartSizeGradient(gradient: number): IParticleSystem;
  104665. /**
  104666. * Not supported by GPUParticleSystem
  104667. * @param gradient defines the gradient to use (between 0 and 1)
  104668. * @param min defines the color remap minimal range
  104669. * @param max defines the color remap maximal range
  104670. * @returns the current particle system
  104671. */
  104672. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104673. /**
  104674. * Not supported by GPUParticleSystem
  104675. * @param gradient defines the gradient to remove
  104676. * @returns the current particle system
  104677. */
  104678. removeColorRemapGradient(): IParticleSystem;
  104679. /**
  104680. * Not supported by GPUParticleSystem
  104681. * @param gradient defines the gradient to use (between 0 and 1)
  104682. * @param min defines the alpha remap minimal range
  104683. * @param max defines the alpha remap maximal range
  104684. * @returns the current particle system
  104685. */
  104686. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104687. /**
  104688. * Not supported by GPUParticleSystem
  104689. * @param gradient defines the gradient to remove
  104690. * @returns the current particle system
  104691. */
  104692. removeAlphaRemapGradient(): IParticleSystem;
  104693. /**
  104694. * Not supported by GPUParticleSystem
  104695. * @param gradient defines the gradient to use (between 0 and 1)
  104696. * @param color defines the color to affect to the specified gradient
  104697. * @returns the current particle system
  104698. */
  104699. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  104700. /**
  104701. * Not supported by GPUParticleSystem
  104702. * @param gradient defines the gradient to remove
  104703. * @returns the current particle system
  104704. */
  104705. removeRampGradient(): IParticleSystem;
  104706. /**
  104707. * Not supported by GPUParticleSystem
  104708. * @returns the list of ramp gradients
  104709. */
  104710. getRampGradients(): Nullable<Array<Color3Gradient>>;
  104711. /**
  104712. * Not supported by GPUParticleSystem
  104713. * Gets or sets a boolean indicating that ramp gradients must be used
  104714. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104715. */
  104716. useRampGradients: boolean;
  104717. /**
  104718. * Not supported by GPUParticleSystem
  104719. * @param gradient defines the gradient to use (between 0 and 1)
  104720. * @param factor defines the life time factor to affect to the specified gradient
  104721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104722. * @returns the current particle system
  104723. */
  104724. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104725. /**
  104726. * Not supported by GPUParticleSystem
  104727. * @param gradient defines the gradient to remove
  104728. * @returns the current particle system
  104729. */
  104730. removeLifeTimeGradient(gradient: number): IParticleSystem;
  104731. /**
  104732. * Instantiates a GPU particle system.
  104733. * 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.
  104734. * @param name The name of the particle system
  104735. * @param options The options used to create the system
  104736. * @param scene The scene the particle system belongs to
  104737. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104738. */
  104739. constructor(name: string, options: Partial<{
  104740. capacity: number;
  104741. randomTextureSize: number;
  104742. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  104743. protected _reset(): void;
  104744. private _createUpdateVAO;
  104745. private _createRenderVAO;
  104746. private _initialize;
  104747. /** @hidden */
  104748. _recreateUpdateEffect(): void;
  104749. /** @hidden */
  104750. _recreateRenderEffect(): void;
  104751. /**
  104752. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104753. * @param preWarm defines if we are in the pre-warmimg phase
  104754. */
  104755. animate(preWarm?: boolean): void;
  104756. private _createFactorGradientTexture;
  104757. private _createSizeGradientTexture;
  104758. private _createAngularSpeedGradientTexture;
  104759. private _createVelocityGradientTexture;
  104760. private _createLimitVelocityGradientTexture;
  104761. private _createDragGradientTexture;
  104762. private _createColorGradientTexture;
  104763. /**
  104764. * Renders the particle system in its current state
  104765. * @param preWarm defines if the system should only update the particles but not render them
  104766. * @returns the current number of particles
  104767. */
  104768. render(preWarm?: boolean): number;
  104769. /**
  104770. * Rebuilds the particle system
  104771. */
  104772. rebuild(): void;
  104773. private _releaseBuffers;
  104774. private _releaseVAOs;
  104775. /**
  104776. * Disposes the particle system and free the associated resources
  104777. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104778. */
  104779. dispose(disposeTexture?: boolean): void;
  104780. /**
  104781. * Clones the particle system.
  104782. * @param name The name of the cloned object
  104783. * @param newEmitter The new emitter to use
  104784. * @returns the cloned particle system
  104785. */
  104786. clone(name: string, newEmitter: any): GPUParticleSystem;
  104787. /**
  104788. * Serializes the particle system to a JSON object.
  104789. * @returns the JSON object
  104790. */
  104791. serialize(): any;
  104792. /**
  104793. * Parses a JSON object to create a GPU particle system.
  104794. * @param parsedParticleSystem The JSON object to parse
  104795. * @param scene The scene to create the particle system in
  104796. * @param rootUrl The root url to use to load external dependencies like texture
  104797. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104798. * @returns the parsed GPU particle system
  104799. */
  104800. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  104801. }
  104802. }
  104803. declare module BABYLON {
  104804. /**
  104805. * Represents a set of particle systems working together to create a specific effect
  104806. */
  104807. export class ParticleSystemSet implements IDisposable {
  104808. private _emitterCreationOptions;
  104809. private _emitterNode;
  104810. /**
  104811. * Gets the particle system list
  104812. */
  104813. systems: IParticleSystem[];
  104814. /**
  104815. * Gets the emitter node used with this set
  104816. */
  104817. readonly emitterNode: Nullable<TransformNode>;
  104818. /**
  104819. * Creates a new emitter mesh as a sphere
  104820. * @param options defines the options used to create the sphere
  104821. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  104822. * @param scene defines the hosting scene
  104823. */
  104824. setEmitterAsSphere(options: {
  104825. diameter: number;
  104826. segments: number;
  104827. color: Color3;
  104828. }, renderingGroupId: number, scene: Scene): void;
  104829. /**
  104830. * Starts all particle systems of the set
  104831. * @param emitter defines an optional mesh to use as emitter for the particle systems
  104832. */
  104833. start(emitter?: AbstractMesh): void;
  104834. /**
  104835. * Release all associated resources
  104836. */
  104837. dispose(): void;
  104838. /**
  104839. * Serialize the set into a JSON compatible object
  104840. * @returns a JSON compatible representation of the set
  104841. */
  104842. serialize(): any;
  104843. /**
  104844. * Parse a new ParticleSystemSet from a serialized source
  104845. * @param data defines a JSON compatible representation of the set
  104846. * @param scene defines the hosting scene
  104847. * @param gpu defines if we want GPU particles or CPU particles
  104848. * @returns a new ParticleSystemSet
  104849. */
  104850. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  104851. }
  104852. }
  104853. declare module BABYLON {
  104854. /**
  104855. * This class is made for on one-liner static method to help creating particle system set.
  104856. */
  104857. export class ParticleHelper {
  104858. /**
  104859. * Gets or sets base Assets URL
  104860. */
  104861. static BaseAssetsUrl: string;
  104862. /**
  104863. * Create a default particle system that you can tweak
  104864. * @param emitter defines the emitter to use
  104865. * @param capacity defines the system capacity (default is 500 particles)
  104866. * @param scene defines the hosting scene
  104867. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104868. * @returns the new Particle system
  104869. */
  104870. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  104871. /**
  104872. * This is the main static method (one-liner) of this helper to create different particle systems
  104873. * @param type This string represents the type to the particle system to create
  104874. * @param scene The scene where the particle system should live
  104875. * @param gpu If the system will use gpu
  104876. * @returns the ParticleSystemSet created
  104877. */
  104878. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  104879. /**
  104880. * Static function used to export a particle system to a ParticleSystemSet variable.
  104881. * Please note that the emitter shape is not exported
  104882. * @param systems defines the particle systems to export
  104883. * @returns the created particle system set
  104884. */
  104885. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  104886. }
  104887. }
  104888. declare module BABYLON {
  104889. interface Engine {
  104890. /**
  104891. * Create an effect to use with particle systems.
  104892. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  104893. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  104894. * @param uniformsNames defines a list of attribute names
  104895. * @param samplers defines an array of string used to represent textures
  104896. * @param defines defines the string containing the defines to use to compile the shaders
  104897. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104898. * @param onCompiled defines a function to call when the effect creation is successful
  104899. * @param onError defines a function to call when the effect creation has failed
  104900. * @returns the new Effect
  104901. */
  104902. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  104903. }
  104904. interface Mesh {
  104905. /**
  104906. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  104907. * @returns an array of IParticleSystem
  104908. */
  104909. getEmittedParticleSystems(): IParticleSystem[];
  104910. /**
  104911. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  104912. * @returns an array of IParticleSystem
  104913. */
  104914. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  104915. }
  104916. /**
  104917. * @hidden
  104918. */
  104919. export var _IDoNeedToBeInTheBuild: number;
  104920. }
  104921. declare module BABYLON {
  104922. interface Scene {
  104923. /** @hidden (Backing field) */
  104924. _physicsEngine: Nullable<IPhysicsEngine>;
  104925. /**
  104926. * Gets the current physics engine
  104927. * @returns a IPhysicsEngine or null if none attached
  104928. */
  104929. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  104930. /**
  104931. * Enables physics to the current scene
  104932. * @param gravity defines the scene's gravity for the physics engine
  104933. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  104934. * @return a boolean indicating if the physics engine was initialized
  104935. */
  104936. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  104937. /**
  104938. * Disables and disposes the physics engine associated with the scene
  104939. */
  104940. disablePhysicsEngine(): void;
  104941. /**
  104942. * Gets a boolean indicating if there is an active physics engine
  104943. * @returns a boolean indicating if there is an active physics engine
  104944. */
  104945. isPhysicsEnabled(): boolean;
  104946. /**
  104947. * Deletes a physics compound impostor
  104948. * @param compound defines the compound to delete
  104949. */
  104950. deleteCompoundImpostor(compound: any): void;
  104951. /**
  104952. * An event triggered when physic simulation is about to be run
  104953. */
  104954. onBeforePhysicsObservable: Observable<Scene>;
  104955. /**
  104956. * An event triggered when physic simulation has been done
  104957. */
  104958. onAfterPhysicsObservable: Observable<Scene>;
  104959. }
  104960. interface AbstractMesh {
  104961. /** @hidden */
  104962. _physicsImpostor: Nullable<PhysicsImpostor>;
  104963. /**
  104964. * Gets or sets impostor used for physic simulation
  104965. * @see http://doc.babylonjs.com/features/physics_engine
  104966. */
  104967. physicsImpostor: Nullable<PhysicsImpostor>;
  104968. /**
  104969. * Gets the current physics impostor
  104970. * @see http://doc.babylonjs.com/features/physics_engine
  104971. * @returns a physics impostor or null
  104972. */
  104973. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  104974. /** Apply a physic impulse to the mesh
  104975. * @param force defines the force to apply
  104976. * @param contactPoint defines where to apply the force
  104977. * @returns the current mesh
  104978. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104979. */
  104980. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  104981. /**
  104982. * Creates a physic joint between two meshes
  104983. * @param otherMesh defines the other mesh to use
  104984. * @param pivot1 defines the pivot to use on this mesh
  104985. * @param pivot2 defines the pivot to use on the other mesh
  104986. * @param options defines additional options (can be plugin dependent)
  104987. * @returns the current mesh
  104988. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  104989. */
  104990. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  104991. /** @hidden */
  104992. _disposePhysicsObserver: Nullable<Observer<Node>>;
  104993. }
  104994. /**
  104995. * Defines the physics engine scene component responsible to manage a physics engine
  104996. */
  104997. export class PhysicsEngineSceneComponent implements ISceneComponent {
  104998. /**
  104999. * The component name helpful to identify the component in the list of scene components.
  105000. */
  105001. readonly name: string;
  105002. /**
  105003. * The scene the component belongs to.
  105004. */
  105005. scene: Scene;
  105006. /**
  105007. * Creates a new instance of the component for the given scene
  105008. * @param scene Defines the scene to register the component in
  105009. */
  105010. constructor(scene: Scene);
  105011. /**
  105012. * Registers the component in a given scene
  105013. */
  105014. register(): void;
  105015. /**
  105016. * Rebuilds the elements related to this component in case of
  105017. * context lost for instance.
  105018. */
  105019. rebuild(): void;
  105020. /**
  105021. * Disposes the component and the associated ressources
  105022. */
  105023. dispose(): void;
  105024. }
  105025. }
  105026. declare module BABYLON {
  105027. /**
  105028. * A helper for physics simulations
  105029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105030. */
  105031. export class PhysicsHelper {
  105032. private _scene;
  105033. private _physicsEngine;
  105034. /**
  105035. * Initializes the Physics helper
  105036. * @param scene Babylon.js scene
  105037. */
  105038. constructor(scene: Scene);
  105039. /**
  105040. * Applies a radial explosion impulse
  105041. * @param origin the origin of the explosion
  105042. * @param radius the explosion radius
  105043. * @param strength the explosion strength
  105044. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105045. * @returns A physics radial explosion event, or null
  105046. */
  105047. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105048. /**
  105049. * Applies a radial explosion force
  105050. * @param origin the origin of the explosion
  105051. * @param radius the explosion radius
  105052. * @param strength the explosion strength
  105053. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105054. * @returns A physics radial explosion event, or null
  105055. */
  105056. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105057. /**
  105058. * Creates a gravitational field
  105059. * @param origin the origin of the explosion
  105060. * @param radius the explosion radius
  105061. * @param strength the explosion strength
  105062. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105063. * @returns A physics gravitational field event, or null
  105064. */
  105065. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105066. /**
  105067. * Creates a physics updraft event
  105068. * @param origin the origin of the updraft
  105069. * @param radius the radius of the updraft
  105070. * @param strength the strength of the updraft
  105071. * @param height the height of the updraft
  105072. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105073. * @returns A physics updraft event, or null
  105074. */
  105075. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105076. /**
  105077. * Creates a physics vortex event
  105078. * @param origin the of the vortex
  105079. * @param radius the radius of the vortex
  105080. * @param strength the strength of the vortex
  105081. * @param height the height of the vortex
  105082. * @returns a Physics vortex event, or null
  105083. * A physics vortex event or null
  105084. */
  105085. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105086. }
  105087. /**
  105088. * Represents a physics radial explosion event
  105089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105090. */
  105091. export class PhysicsRadialExplosionEvent {
  105092. private _scene;
  105093. private _sphere;
  105094. private _sphereOptions;
  105095. private _rays;
  105096. private _dataFetched;
  105097. /**
  105098. * Initializes a radial explosioin event
  105099. * @param scene BabylonJS scene
  105100. */
  105101. constructor(scene: Scene);
  105102. /**
  105103. * Returns the data related to the radial explosion event (sphere & rays).
  105104. * @returns The radial explosion event data
  105105. */
  105106. getData(): PhysicsRadialExplosionEventData;
  105107. /**
  105108. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105109. * @param impostor A physics imposter
  105110. * @param origin the origin of the explosion
  105111. * @param radius the explosion radius
  105112. * @param strength the explosion strength
  105113. * @param falloff possible options: Constant & Linear
  105114. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105115. */
  105116. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105117. /**
  105118. * Disposes the sphere.
  105119. * @param force Specifies if the sphere should be disposed by force
  105120. */
  105121. dispose(force?: boolean): void;
  105122. /*** Helpers ***/
  105123. private _prepareSphere;
  105124. private _intersectsWithSphere;
  105125. }
  105126. /**
  105127. * Represents a gravitational field event
  105128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105129. */
  105130. export class PhysicsGravitationalFieldEvent {
  105131. private _physicsHelper;
  105132. private _scene;
  105133. private _origin;
  105134. private _radius;
  105135. private _strength;
  105136. private _falloff;
  105137. private _tickCallback;
  105138. private _sphere;
  105139. private _dataFetched;
  105140. /**
  105141. * Initializes the physics gravitational field event
  105142. * @param physicsHelper A physics helper
  105143. * @param scene BabylonJS scene
  105144. * @param origin The origin position of the gravitational field event
  105145. * @param radius The radius of the gravitational field event
  105146. * @param strength The strength of the gravitational field event
  105147. * @param falloff The falloff for the gravitational field event
  105148. */
  105149. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105150. /**
  105151. * Returns the data related to the gravitational field event (sphere).
  105152. * @returns A gravitational field event
  105153. */
  105154. getData(): PhysicsGravitationalFieldEventData;
  105155. /**
  105156. * Enables the gravitational field.
  105157. */
  105158. enable(): void;
  105159. /**
  105160. * Disables the gravitational field.
  105161. */
  105162. disable(): void;
  105163. /**
  105164. * Disposes the sphere.
  105165. * @param force The force to dispose from the gravitational field event
  105166. */
  105167. dispose(force?: boolean): void;
  105168. private _tick;
  105169. }
  105170. /**
  105171. * Represents a physics updraft event
  105172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105173. */
  105174. export class PhysicsUpdraftEvent {
  105175. private _scene;
  105176. private _origin;
  105177. private _radius;
  105178. private _strength;
  105179. private _height;
  105180. private _updraftMode;
  105181. private _physicsEngine;
  105182. private _originTop;
  105183. private _originDirection;
  105184. private _tickCallback;
  105185. private _cylinder;
  105186. private _cylinderPosition;
  105187. private _dataFetched;
  105188. /**
  105189. * Initializes the physics updraft event
  105190. * @param _scene BabylonJS scene
  105191. * @param _origin The origin position of the updraft
  105192. * @param _radius The radius of the updraft
  105193. * @param _strength The strength of the updraft
  105194. * @param _height The height of the updraft
  105195. * @param _updraftMode The mode of the updraft
  105196. */
  105197. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105198. /**
  105199. * Returns the data related to the updraft event (cylinder).
  105200. * @returns A physics updraft event
  105201. */
  105202. getData(): PhysicsUpdraftEventData;
  105203. /**
  105204. * Enables the updraft.
  105205. */
  105206. enable(): void;
  105207. /**
  105208. * Disables the cortex.
  105209. */
  105210. disable(): void;
  105211. /**
  105212. * Disposes the sphere.
  105213. * @param force Specifies if the updraft should be disposed by force
  105214. */
  105215. dispose(force?: boolean): void;
  105216. private getImpostorForceAndContactPoint;
  105217. private _tick;
  105218. /*** Helpers ***/
  105219. private _prepareCylinder;
  105220. private _intersectsWithCylinder;
  105221. }
  105222. /**
  105223. * Represents a physics vortex event
  105224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105225. */
  105226. export class PhysicsVortexEvent {
  105227. private _scene;
  105228. private _origin;
  105229. private _radius;
  105230. private _strength;
  105231. private _height;
  105232. private _physicsEngine;
  105233. private _originTop;
  105234. private _centripetalForceThreshold;
  105235. private _updraftMultiplier;
  105236. private _tickCallback;
  105237. private _cylinder;
  105238. private _cylinderPosition;
  105239. private _dataFetched;
  105240. /**
  105241. * Initializes the physics vortex event
  105242. * @param _scene The BabylonJS scene
  105243. * @param _origin The origin position of the vortex
  105244. * @param _radius The radius of the vortex
  105245. * @param _strength The strength of the vortex
  105246. * @param _height The height of the vortex
  105247. */
  105248. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105249. /**
  105250. * Returns the data related to the vortex event (cylinder).
  105251. * @returns The physics vortex event data
  105252. */
  105253. getData(): PhysicsVortexEventData;
  105254. /**
  105255. * Enables the vortex.
  105256. */
  105257. enable(): void;
  105258. /**
  105259. * Disables the cortex.
  105260. */
  105261. disable(): void;
  105262. /**
  105263. * Disposes the sphere.
  105264. * @param force
  105265. */
  105266. dispose(force?: boolean): void;
  105267. private getImpostorForceAndContactPoint;
  105268. private _tick;
  105269. /*** Helpers ***/
  105270. private _prepareCylinder;
  105271. private _intersectsWithCylinder;
  105272. }
  105273. /**
  105274. * The strenght of the force in correspondence to the distance of the affected object
  105275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105276. */
  105277. export enum PhysicsRadialImpulseFalloff {
  105278. /** Defines that impulse is constant in strength across it's whole radius */
  105279. Constant = 0,
  105280. /** DEfines that impulse gets weaker if it's further from the origin */
  105281. Linear = 1
  105282. }
  105283. /**
  105284. * The strength of the force in correspondence to the distance of the affected object
  105285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105286. */
  105287. export enum PhysicsUpdraftMode {
  105288. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105289. Center = 0,
  105290. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  105291. Perpendicular = 1
  105292. }
  105293. /**
  105294. * Interface for a physics force and contact point
  105295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105296. */
  105297. export interface PhysicsForceAndContactPoint {
  105298. /**
  105299. * The force applied at the contact point
  105300. */
  105301. force: Vector3;
  105302. /**
  105303. * The contact point
  105304. */
  105305. contactPoint: Vector3;
  105306. }
  105307. /**
  105308. * Interface for radial explosion event data
  105309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105310. */
  105311. export interface PhysicsRadialExplosionEventData {
  105312. /**
  105313. * A sphere used for the radial explosion event
  105314. */
  105315. sphere: Mesh;
  105316. /**
  105317. * An array of rays for the radial explosion event
  105318. */
  105319. rays: Array<Ray>;
  105320. }
  105321. /**
  105322. * Interface for gravitational field event data
  105323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105324. */
  105325. export interface PhysicsGravitationalFieldEventData {
  105326. /**
  105327. * A sphere mesh used for the gravitational field event
  105328. */
  105329. sphere: Mesh;
  105330. }
  105331. /**
  105332. * Interface for updraft event data
  105333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105334. */
  105335. export interface PhysicsUpdraftEventData {
  105336. /**
  105337. * A cylinder used for the updraft event
  105338. */
  105339. cylinder: Mesh;
  105340. }
  105341. /**
  105342. * Interface for vortex event data
  105343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105344. */
  105345. export interface PhysicsVortexEventData {
  105346. /**
  105347. * A cylinder used for the vortex event
  105348. */
  105349. cylinder: Mesh;
  105350. }
  105351. }
  105352. declare module BABYLON {
  105353. /**
  105354. * AmmoJS Physics plugin
  105355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105356. * @see https://github.com/kripken/ammo.js/
  105357. */
  105358. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  105359. private _useDeltaForWorldStep;
  105360. /**
  105361. * Reference to the Ammo library
  105362. */
  105363. bjsAMMO: any;
  105364. /**
  105365. * Created ammoJS world which physics bodies are added to
  105366. */
  105367. world: any;
  105368. /**
  105369. * Name of the plugin
  105370. */
  105371. name: string;
  105372. private _timeStep;
  105373. private _fixedTimeStep;
  105374. private _maxSteps;
  105375. private _tmpQuaternion;
  105376. private _tmpAmmoTransform;
  105377. private _tmpAmmoQuaternion;
  105378. private _tmpAmmoConcreteContactResultCallback;
  105379. private _collisionConfiguration;
  105380. private _dispatcher;
  105381. private _overlappingPairCache;
  105382. private _solver;
  105383. private _tmpAmmoVectorA;
  105384. private _tmpAmmoVectorB;
  105385. private _tmpAmmoVectorC;
  105386. private _tmpContactCallbackResult;
  105387. private static readonly DISABLE_COLLISION_FLAG;
  105388. private static readonly KINEMATIC_FLAG;
  105389. private static readonly DISABLE_DEACTIVATION_FLAG;
  105390. /**
  105391. * Initializes the ammoJS plugin
  105392. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  105393. * @param ammoInjection can be used to inject your own ammo reference
  105394. */
  105395. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  105396. /**
  105397. * Sets the gravity of the physics world (m/(s^2))
  105398. * @param gravity Gravity to set
  105399. */
  105400. setGravity(gravity: Vector3): void;
  105401. /**
  105402. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  105403. * @param timeStep timestep to use in seconds
  105404. */
  105405. setTimeStep(timeStep: number): void;
  105406. /**
  105407. * 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)
  105408. * @param fixedTimeStep fixedTimeStep to use in seconds
  105409. */
  105410. setFixedTimeStep(fixedTimeStep: number): void;
  105411. /**
  105412. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  105413. * @param maxSteps the maximum number of steps by the physics engine per frame
  105414. */
  105415. setMaxSteps(maxSteps: number): void;
  105416. /**
  105417. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  105418. * @returns the current timestep in seconds
  105419. */
  105420. getTimeStep(): number;
  105421. private _isImpostorInContact;
  105422. private _isImpostorPairInContact;
  105423. private _stepSimulation;
  105424. /**
  105425. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  105426. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  105427. * After the step the babylon meshes are set to the position of the physics imposters
  105428. * @param delta amount of time to step forward
  105429. * @param impostors array of imposters to update before/after the step
  105430. */
  105431. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105432. private _tmpVector;
  105433. private _tmpMatrix;
  105434. /**
  105435. * Applies an implulse on the imposter
  105436. * @param impostor imposter to apply impulse
  105437. * @param force amount of force to be applied to the imposter
  105438. * @param contactPoint the location to apply the impulse on the imposter
  105439. */
  105440. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105441. /**
  105442. * Applies a force on the imposter
  105443. * @param impostor imposter to apply force
  105444. * @param force amount of force to be applied to the imposter
  105445. * @param contactPoint the location to apply the force on the imposter
  105446. */
  105447. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105448. /**
  105449. * Creates a physics body using the plugin
  105450. * @param impostor the imposter to create the physics body on
  105451. */
  105452. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105453. /**
  105454. * Removes the physics body from the imposter and disposes of the body's memory
  105455. * @param impostor imposter to remove the physics body from
  105456. */
  105457. removePhysicsBody(impostor: PhysicsImpostor): void;
  105458. /**
  105459. * Generates a joint
  105460. * @param impostorJoint the imposter joint to create the joint with
  105461. */
  105462. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105463. /**
  105464. * Removes a joint
  105465. * @param impostorJoint the imposter joint to remove the joint from
  105466. */
  105467. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105468. private _addMeshVerts;
  105469. private _createShape;
  105470. /**
  105471. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  105472. * @param impostor imposter containing the physics body and babylon object
  105473. */
  105474. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105475. /**
  105476. * Sets the babylon object's position/rotation from the physics body's position/rotation
  105477. * @param impostor imposter containing the physics body and babylon object
  105478. * @param newPosition new position
  105479. * @param newRotation new rotation
  105480. */
  105481. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105482. /**
  105483. * If this plugin is supported
  105484. * @returns true if its supported
  105485. */
  105486. isSupported(): boolean;
  105487. /**
  105488. * Sets the linear velocity of the physics body
  105489. * @param impostor imposter to set the velocity on
  105490. * @param velocity velocity to set
  105491. */
  105492. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105493. /**
  105494. * Sets the angular velocity of the physics body
  105495. * @param impostor imposter to set the velocity on
  105496. * @param velocity velocity to set
  105497. */
  105498. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105499. /**
  105500. * gets the linear velocity
  105501. * @param impostor imposter to get linear velocity from
  105502. * @returns linear velocity
  105503. */
  105504. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105505. /**
  105506. * gets the angular velocity
  105507. * @param impostor imposter to get angular velocity from
  105508. * @returns angular velocity
  105509. */
  105510. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105511. /**
  105512. * Sets the mass of physics body
  105513. * @param impostor imposter to set the mass on
  105514. * @param mass mass to set
  105515. */
  105516. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105517. /**
  105518. * Gets the mass of the physics body
  105519. * @param impostor imposter to get the mass from
  105520. * @returns mass
  105521. */
  105522. getBodyMass(impostor: PhysicsImpostor): number;
  105523. /**
  105524. * Gets friction of the impostor
  105525. * @param impostor impostor to get friction from
  105526. * @returns friction value
  105527. */
  105528. getBodyFriction(impostor: PhysicsImpostor): number;
  105529. /**
  105530. * Sets friction of the impostor
  105531. * @param impostor impostor to set friction on
  105532. * @param friction friction value
  105533. */
  105534. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105535. /**
  105536. * Gets restitution of the impostor
  105537. * @param impostor impostor to get restitution from
  105538. * @returns restitution value
  105539. */
  105540. getBodyRestitution(impostor: PhysicsImpostor): number;
  105541. /**
  105542. * Sets resitution of the impostor
  105543. * @param impostor impostor to set resitution on
  105544. * @param restitution resitution value
  105545. */
  105546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105547. /**
  105548. * Sleeps the physics body and stops it from being active
  105549. * @param impostor impostor to sleep
  105550. */
  105551. sleepBody(impostor: PhysicsImpostor): void;
  105552. /**
  105553. * Activates the physics body
  105554. * @param impostor impostor to activate
  105555. */
  105556. wakeUpBody(impostor: PhysicsImpostor): void;
  105557. /**
  105558. * Updates the distance parameters of the joint
  105559. * @param joint joint to update
  105560. * @param maxDistance maximum distance of the joint
  105561. * @param minDistance minimum distance of the joint
  105562. */
  105563. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105564. /**
  105565. * Sets a motor on the joint
  105566. * @param joint joint to set motor on
  105567. * @param speed speed of the motor
  105568. * @param maxForce maximum force of the motor
  105569. * @param motorIndex index of the motor
  105570. */
  105571. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105572. /**
  105573. * Sets the motors limit
  105574. * @param joint joint to set limit on
  105575. * @param upperLimit upper limit
  105576. * @param lowerLimit lower limit
  105577. */
  105578. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105579. /**
  105580. * Syncs the position and rotation of a mesh with the impostor
  105581. * @param mesh mesh to sync
  105582. * @param impostor impostor to update the mesh with
  105583. */
  105584. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105585. /**
  105586. * Gets the radius of the impostor
  105587. * @param impostor impostor to get radius from
  105588. * @returns the radius
  105589. */
  105590. getRadius(impostor: PhysicsImpostor): number;
  105591. /**
  105592. * Gets the box size of the impostor
  105593. * @param impostor impostor to get box size from
  105594. * @param result the resulting box size
  105595. */
  105596. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105597. /**
  105598. * Disposes of the impostor
  105599. */
  105600. dispose(): void;
  105601. }
  105602. }
  105603. declare module BABYLON {
  105604. /** @hidden */
  105605. export var blackAndWhitePixelShader: {
  105606. name: string;
  105607. shader: string;
  105608. };
  105609. }
  105610. declare module BABYLON {
  105611. /**
  105612. * Post process used to render in black and white
  105613. */
  105614. export class BlackAndWhitePostProcess extends PostProcess {
  105615. /**
  105616. * Linear about to convert he result to black and white (default: 1)
  105617. */
  105618. degree: number;
  105619. /**
  105620. * Creates a black and white post process
  105621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  105622. * @param name The name of the effect.
  105623. * @param options The required width/height ratio to downsize to before computing the render pass.
  105624. * @param camera The camera to apply the render pass to.
  105625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105626. * @param engine The engine which the post process will be applied. (default: current engine)
  105627. * @param reusable If the post process can be reused on the same frame. (default: false)
  105628. */
  105629. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105630. }
  105631. }
  105632. declare module BABYLON {
  105633. /**
  105634. * This represents a set of one or more post processes in Babylon.
  105635. * A post process can be used to apply a shader to a texture after it is rendered.
  105636. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105637. */
  105638. export class PostProcessRenderEffect {
  105639. private _postProcesses;
  105640. private _getPostProcesses;
  105641. private _singleInstance;
  105642. private _cameras;
  105643. private _indicesForCamera;
  105644. /**
  105645. * Name of the effect
  105646. * @hidden
  105647. */
  105648. _name: string;
  105649. /**
  105650. * Instantiates a post process render effect.
  105651. * A post process can be used to apply a shader to a texture after it is rendered.
  105652. * @param engine The engine the effect is tied to
  105653. * @param name The name of the effect
  105654. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  105655. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  105656. */
  105657. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  105658. /**
  105659. * Checks if all the post processes in the effect are supported.
  105660. */
  105661. readonly isSupported: boolean;
  105662. /**
  105663. * Updates the current state of the effect
  105664. * @hidden
  105665. */
  105666. _update(): void;
  105667. /**
  105668. * Attaches the effect on cameras
  105669. * @param cameras The camera to attach to.
  105670. * @hidden
  105671. */
  105672. _attachCameras(cameras: Camera): void;
  105673. /**
  105674. * Attaches the effect on cameras
  105675. * @param cameras The camera to attach to.
  105676. * @hidden
  105677. */
  105678. _attachCameras(cameras: Camera[]): void;
  105679. /**
  105680. * Detatches the effect on cameras
  105681. * @param cameras The camera to detatch from.
  105682. * @hidden
  105683. */
  105684. _detachCameras(cameras: Camera): void;
  105685. /**
  105686. * Detatches the effect on cameras
  105687. * @param cameras The camera to detatch from.
  105688. * @hidden
  105689. */
  105690. _detachCameras(cameras: Camera[]): void;
  105691. /**
  105692. * Enables the effect on given cameras
  105693. * @param cameras The camera to enable.
  105694. * @hidden
  105695. */
  105696. _enable(cameras: Camera): void;
  105697. /**
  105698. * Enables the effect on given cameras
  105699. * @param cameras The camera to enable.
  105700. * @hidden
  105701. */
  105702. _enable(cameras: Nullable<Camera[]>): void;
  105703. /**
  105704. * Disables the effect on the given cameras
  105705. * @param cameras The camera to disable.
  105706. * @hidden
  105707. */
  105708. _disable(cameras: Camera): void;
  105709. /**
  105710. * Disables the effect on the given cameras
  105711. * @param cameras The camera to disable.
  105712. * @hidden
  105713. */
  105714. _disable(cameras: Nullable<Camera[]>): void;
  105715. /**
  105716. * Gets a list of the post processes contained in the effect.
  105717. * @param camera The camera to get the post processes on.
  105718. * @returns The list of the post processes in the effect.
  105719. */
  105720. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  105721. }
  105722. }
  105723. declare module BABYLON {
  105724. /** @hidden */
  105725. export var extractHighlightsPixelShader: {
  105726. name: string;
  105727. shader: string;
  105728. };
  105729. }
  105730. declare module BABYLON {
  105731. /**
  105732. * 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.
  105733. */
  105734. export class ExtractHighlightsPostProcess extends PostProcess {
  105735. /**
  105736. * The luminance threshold, pixels below this value will be set to black.
  105737. */
  105738. threshold: number;
  105739. /** @hidden */
  105740. _exposure: number;
  105741. /**
  105742. * Post process which has the input texture to be used when performing highlight extraction
  105743. * @hidden
  105744. */
  105745. _inputPostProcess: Nullable<PostProcess>;
  105746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105747. }
  105748. }
  105749. declare module BABYLON {
  105750. /** @hidden */
  105751. export var bloomMergePixelShader: {
  105752. name: string;
  105753. shader: string;
  105754. };
  105755. }
  105756. declare module BABYLON {
  105757. /**
  105758. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105759. */
  105760. export class BloomMergePostProcess extends PostProcess {
  105761. /** Weight of the bloom to be added to the original input. */
  105762. weight: number;
  105763. /**
  105764. * Creates a new instance of @see BloomMergePostProcess
  105765. * @param name The name of the effect.
  105766. * @param originalFromInput Post process which's input will be used for the merge.
  105767. * @param blurred Blurred highlights post process which's output will be used.
  105768. * @param weight Weight of the bloom to be added to the original input.
  105769. * @param options The required width/height ratio to downsize to before computing the render pass.
  105770. * @param camera The camera to apply the render pass to.
  105771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105772. * @param engine The engine which the post process will be applied. (default: current engine)
  105773. * @param reusable If the post process can be reused on the same frame. (default: false)
  105774. * @param textureType Type of textures used when performing the post process. (default: 0)
  105775. * @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)
  105776. */
  105777. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  105778. /** Weight of the bloom to be added to the original input. */
  105779. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105780. }
  105781. }
  105782. declare module BABYLON {
  105783. /**
  105784. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  105785. */
  105786. export class BloomEffect extends PostProcessRenderEffect {
  105787. private bloomScale;
  105788. /**
  105789. * @hidden Internal
  105790. */
  105791. _effects: Array<PostProcess>;
  105792. /**
  105793. * @hidden Internal
  105794. */
  105795. _downscale: ExtractHighlightsPostProcess;
  105796. private _blurX;
  105797. private _blurY;
  105798. private _merge;
  105799. /**
  105800. * The luminance threshold to find bright areas of the image to bloom.
  105801. */
  105802. threshold: number;
  105803. /**
  105804. * The strength of the bloom.
  105805. */
  105806. weight: number;
  105807. /**
  105808. * Specifies the size of the bloom blur kernel, relative to the final output size
  105809. */
  105810. kernel: number;
  105811. /**
  105812. * Creates a new instance of @see BloomEffect
  105813. * @param scene The scene the effect belongs to.
  105814. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105815. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105816. * @param bloomWeight The the strength of bloom.
  105817. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105818. * @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)
  105819. */
  105820. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  105821. /**
  105822. * Disposes each of the internal effects for a given camera.
  105823. * @param camera The camera to dispose the effect on.
  105824. */
  105825. disposeEffects(camera: Camera): void;
  105826. /**
  105827. * @hidden Internal
  105828. */
  105829. _updateEffects(): void;
  105830. /**
  105831. * Internal
  105832. * @returns if all the contained post processes are ready.
  105833. * @hidden
  105834. */
  105835. _isReady(): boolean;
  105836. }
  105837. }
  105838. declare module BABYLON {
  105839. /** @hidden */
  105840. export var chromaticAberrationPixelShader: {
  105841. name: string;
  105842. shader: string;
  105843. };
  105844. }
  105845. declare module BABYLON {
  105846. /**
  105847. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  105848. */
  105849. export class ChromaticAberrationPostProcess extends PostProcess {
  105850. /**
  105851. * The amount of seperation of rgb channels (default: 30)
  105852. */
  105853. aberrationAmount: number;
  105854. /**
  105855. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  105856. */
  105857. radialIntensity: number;
  105858. /**
  105859. * 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))
  105860. */
  105861. direction: Vector2;
  105862. /**
  105863. * 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))
  105864. */
  105865. centerPosition: Vector2;
  105866. /**
  105867. * Creates a new instance ChromaticAberrationPostProcess
  105868. * @param name The name of the effect.
  105869. * @param screenWidth The width of the screen to apply the effect on.
  105870. * @param screenHeight The height of the screen to apply the effect on.
  105871. * @param options The required width/height ratio to downsize to before computing the render pass.
  105872. * @param camera The camera to apply the render pass to.
  105873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105874. * @param engine The engine which the post process will be applied. (default: current engine)
  105875. * @param reusable If the post process can be reused on the same frame. (default: false)
  105876. * @param textureType Type of textures used when performing the post process. (default: 0)
  105877. * @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)
  105878. */
  105879. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /** @hidden */
  105884. export var circleOfConfusionPixelShader: {
  105885. name: string;
  105886. shader: string;
  105887. };
  105888. }
  105889. declare module BABYLON {
  105890. /**
  105891. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  105892. */
  105893. export class CircleOfConfusionPostProcess extends PostProcess {
  105894. /**
  105895. * 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.
  105896. */
  105897. lensSize: number;
  105898. /**
  105899. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  105900. */
  105901. fStop: number;
  105902. /**
  105903. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  105904. */
  105905. focusDistance: number;
  105906. /**
  105907. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  105908. */
  105909. focalLength: number;
  105910. private _depthTexture;
  105911. /**
  105912. * Creates a new instance CircleOfConfusionPostProcess
  105913. * @param name The name of the effect.
  105914. * @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.
  105915. * @param options The required width/height ratio to downsize to before computing the render pass.
  105916. * @param camera The camera to apply the render pass to.
  105917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105918. * @param engine The engine which the post process will be applied. (default: current engine)
  105919. * @param reusable If the post process can be reused on the same frame. (default: false)
  105920. * @param textureType Type of textures used when performing the post process. (default: 0)
  105921. * @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)
  105922. */
  105923. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105924. /**
  105925. * 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.
  105926. */
  105927. depthTexture: RenderTargetTexture;
  105928. }
  105929. }
  105930. declare module BABYLON {
  105931. /** @hidden */
  105932. export var colorCorrectionPixelShader: {
  105933. name: string;
  105934. shader: string;
  105935. };
  105936. }
  105937. declare module BABYLON {
  105938. /**
  105939. *
  105940. * This post-process allows the modification of rendered colors by using
  105941. * a 'look-up table' (LUT). This effect is also called Color Grading.
  105942. *
  105943. * The object needs to be provided an url to a texture containing the color
  105944. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  105945. * Use an image editing software to tweak the LUT to match your needs.
  105946. *
  105947. * For an example of a color LUT, see here:
  105948. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  105949. * For explanations on color grading, see here:
  105950. * @see http://udn.epicgames.com/Three/ColorGrading.html
  105951. *
  105952. */
  105953. export class ColorCorrectionPostProcess extends PostProcess {
  105954. private _colorTableTexture;
  105955. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /** @hidden */
  105960. export var convolutionPixelShader: {
  105961. name: string;
  105962. shader: string;
  105963. };
  105964. }
  105965. declare module BABYLON {
  105966. /**
  105967. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  105968. * input texture to perform effects such as edge detection or sharpening
  105969. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  105970. */
  105971. export class ConvolutionPostProcess extends PostProcess {
  105972. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  105973. kernel: number[];
  105974. /**
  105975. * Creates a new instance ConvolutionPostProcess
  105976. * @param name The name of the effect.
  105977. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  105978. * @param options The required width/height ratio to downsize to before computing the render pass.
  105979. * @param camera The camera to apply the render pass to.
  105980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105981. * @param engine The engine which the post process will be applied. (default: current engine)
  105982. * @param reusable If the post process can be reused on the same frame. (default: false)
  105983. * @param textureType Type of textures used when performing the post process. (default: 0)
  105984. */
  105985. constructor(name: string,
  105986. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  105987. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  105988. /**
  105989. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105990. */
  105991. static EdgeDetect0Kernel: number[];
  105992. /**
  105993. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105994. */
  105995. static EdgeDetect1Kernel: number[];
  105996. /**
  105997. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105998. */
  105999. static EdgeDetect2Kernel: number[];
  106000. /**
  106001. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106002. */
  106003. static SharpenKernel: number[];
  106004. /**
  106005. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106006. */
  106007. static EmbossKernel: number[];
  106008. /**
  106009. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106010. */
  106011. static GaussianKernel: number[];
  106012. }
  106013. }
  106014. declare module BABYLON {
  106015. /**
  106016. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106017. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106018. * based on samples that have a large difference in distance than the center pixel.
  106019. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106020. */
  106021. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106022. direction: Vector2;
  106023. /**
  106024. * Creates a new instance CircleOfConfusionPostProcess
  106025. * @param name The name of the effect.
  106026. * @param scene The scene the effect belongs to.
  106027. * @param direction The direction the blur should be applied.
  106028. * @param kernel The size of the kernel used to blur.
  106029. * @param options The required width/height ratio to downsize to before computing the render pass.
  106030. * @param camera The camera to apply the render pass to.
  106031. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106032. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106034. * @param engine The engine which the post process will be applied. (default: current engine)
  106035. * @param reusable If the post process can be reused on the same frame. (default: false)
  106036. * @param textureType Type of textures used when performing the post process. (default: 0)
  106037. * @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)
  106038. */
  106039. 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);
  106040. }
  106041. }
  106042. declare module BABYLON {
  106043. /** @hidden */
  106044. export var depthOfFieldMergePixelShader: {
  106045. name: string;
  106046. shader: string;
  106047. };
  106048. }
  106049. declare module BABYLON {
  106050. /**
  106051. * Options to be set when merging outputs from the default pipeline.
  106052. */
  106053. export class DepthOfFieldMergePostProcessOptions {
  106054. /**
  106055. * The original image to merge on top of
  106056. */
  106057. originalFromInput: PostProcess;
  106058. /**
  106059. * Parameters to perform the merge of the depth of field effect
  106060. */
  106061. depthOfField?: {
  106062. circleOfConfusion: PostProcess;
  106063. blurSteps: Array<PostProcess>;
  106064. };
  106065. /**
  106066. * Parameters to perform the merge of bloom effect
  106067. */
  106068. bloom?: {
  106069. blurred: PostProcess;
  106070. weight: number;
  106071. };
  106072. }
  106073. /**
  106074. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106075. */
  106076. export class DepthOfFieldMergePostProcess extends PostProcess {
  106077. private blurSteps;
  106078. /**
  106079. * Creates a new instance of DepthOfFieldMergePostProcess
  106080. * @param name The name of the effect.
  106081. * @param originalFromInput Post process which's input will be used for the merge.
  106082. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106083. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106084. * @param options The required width/height ratio to downsize to before computing the render pass.
  106085. * @param camera The camera to apply the render pass to.
  106086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106087. * @param engine The engine which the post process will be applied. (default: current engine)
  106088. * @param reusable If the post process can be reused on the same frame. (default: false)
  106089. * @param textureType Type of textures used when performing the post process. (default: 0)
  106090. * @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)
  106091. */
  106092. 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);
  106093. /**
  106094. * Updates the effect with the current post process compile time values and recompiles the shader.
  106095. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106096. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106097. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106098. * @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
  106099. * @param onCompiled Called when the shader has been compiled.
  106100. * @param onError Called if there is an error when compiling a shader.
  106101. */
  106102. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106103. }
  106104. }
  106105. declare module BABYLON {
  106106. /**
  106107. * Specifies the level of max blur that should be applied when using the depth of field effect
  106108. */
  106109. export enum DepthOfFieldEffectBlurLevel {
  106110. /**
  106111. * Subtle blur
  106112. */
  106113. Low = 0,
  106114. /**
  106115. * Medium blur
  106116. */
  106117. Medium = 1,
  106118. /**
  106119. * Large blur
  106120. */
  106121. High = 2
  106122. }
  106123. /**
  106124. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106125. */
  106126. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106127. private _circleOfConfusion;
  106128. /**
  106129. * @hidden Internal, blurs from high to low
  106130. */
  106131. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106132. private _depthOfFieldBlurY;
  106133. private _dofMerge;
  106134. /**
  106135. * @hidden Internal post processes in depth of field effect
  106136. */
  106137. _effects: Array<PostProcess>;
  106138. /**
  106139. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106140. */
  106141. focalLength: number;
  106142. /**
  106143. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106144. */
  106145. fStop: number;
  106146. /**
  106147. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106148. */
  106149. focusDistance: number;
  106150. /**
  106151. * 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.
  106152. */
  106153. lensSize: number;
  106154. /**
  106155. * Creates a new instance DepthOfFieldEffect
  106156. * @param scene The scene the effect belongs to.
  106157. * @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.
  106158. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106159. * @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)
  106160. */
  106161. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106162. /**
  106163. * 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.
  106164. */
  106165. depthTexture: RenderTargetTexture;
  106166. /**
  106167. * Disposes each of the internal effects for a given camera.
  106168. * @param camera The camera to dispose the effect on.
  106169. */
  106170. disposeEffects(camera: Camera): void;
  106171. /**
  106172. * @hidden Internal
  106173. */
  106174. _updateEffects(): void;
  106175. /**
  106176. * Internal
  106177. * @returns if all the contained post processes are ready.
  106178. * @hidden
  106179. */
  106180. _isReady(): boolean;
  106181. }
  106182. }
  106183. declare module BABYLON {
  106184. /** @hidden */
  106185. export var displayPassPixelShader: {
  106186. name: string;
  106187. shader: string;
  106188. };
  106189. }
  106190. declare module BABYLON {
  106191. /**
  106192. * DisplayPassPostProcess which produces an output the same as it's input
  106193. */
  106194. export class DisplayPassPostProcess extends PostProcess {
  106195. /**
  106196. * Creates the DisplayPassPostProcess
  106197. * @param name The name of the effect.
  106198. * @param options The required width/height ratio to downsize to before computing the render pass.
  106199. * @param camera The camera to apply the render pass to.
  106200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106201. * @param engine The engine which the post process will be applied. (default: current engine)
  106202. * @param reusable If the post process can be reused on the same frame. (default: false)
  106203. */
  106204. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106205. }
  106206. }
  106207. declare module BABYLON {
  106208. /** @hidden */
  106209. export var filterPixelShader: {
  106210. name: string;
  106211. shader: string;
  106212. };
  106213. }
  106214. declare module BABYLON {
  106215. /**
  106216. * Applies a kernel filter to the image
  106217. */
  106218. export class FilterPostProcess extends PostProcess {
  106219. /** The matrix to be applied to the image */
  106220. kernelMatrix: Matrix;
  106221. /**
  106222. *
  106223. * @param name The name of the effect.
  106224. * @param kernelMatrix The matrix to be applied to the image
  106225. * @param options The required width/height ratio to downsize to before computing the render pass.
  106226. * @param camera The camera to apply the render pass to.
  106227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106228. * @param engine The engine which the post process will be applied. (default: current engine)
  106229. * @param reusable If the post process can be reused on the same frame. (default: false)
  106230. */
  106231. constructor(name: string,
  106232. /** The matrix to be applied to the image */
  106233. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106234. }
  106235. }
  106236. declare module BABYLON {
  106237. /** @hidden */
  106238. export var fxaaPixelShader: {
  106239. name: string;
  106240. shader: string;
  106241. };
  106242. }
  106243. declare module BABYLON {
  106244. /** @hidden */
  106245. export var fxaaVertexShader: {
  106246. name: string;
  106247. shader: string;
  106248. };
  106249. }
  106250. declare module BABYLON {
  106251. /**
  106252. * Fxaa post process
  106253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106254. */
  106255. export class FxaaPostProcess extends PostProcess {
  106256. /** @hidden */
  106257. texelWidth: number;
  106258. /** @hidden */
  106259. texelHeight: number;
  106260. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106261. private _getDefines;
  106262. }
  106263. }
  106264. declare module BABYLON {
  106265. /** @hidden */
  106266. export var grainPixelShader: {
  106267. name: string;
  106268. shader: string;
  106269. };
  106270. }
  106271. declare module BABYLON {
  106272. /**
  106273. * The GrainPostProcess adds noise to the image at mid luminance levels
  106274. */
  106275. export class GrainPostProcess extends PostProcess {
  106276. /**
  106277. * The intensity of the grain added (default: 30)
  106278. */
  106279. intensity: number;
  106280. /**
  106281. * If the grain should be randomized on every frame
  106282. */
  106283. animated: boolean;
  106284. /**
  106285. * Creates a new instance of @see GrainPostProcess
  106286. * @param name The name of the effect.
  106287. * @param options The required width/height ratio to downsize to before computing the render pass.
  106288. * @param camera The camera to apply the render pass to.
  106289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106290. * @param engine The engine which the post process will be applied. (default: current engine)
  106291. * @param reusable If the post process can be reused on the same frame. (default: false)
  106292. * @param textureType Type of textures used when performing the post process. (default: 0)
  106293. * @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)
  106294. */
  106295. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106296. }
  106297. }
  106298. declare module BABYLON {
  106299. /** @hidden */
  106300. export var highlightsPixelShader: {
  106301. name: string;
  106302. shader: string;
  106303. };
  106304. }
  106305. declare module BABYLON {
  106306. /**
  106307. * Extracts highlights from the image
  106308. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106309. */
  106310. export class HighlightsPostProcess extends PostProcess {
  106311. /**
  106312. * Extracts highlights from the image
  106313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106314. * @param name The name of the effect.
  106315. * @param options The required width/height ratio to downsize to before computing the render pass.
  106316. * @param camera The camera to apply the render pass to.
  106317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106318. * @param engine The engine which the post process will be applied. (default: current engine)
  106319. * @param reusable If the post process can be reused on the same frame. (default: false)
  106320. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  106321. */
  106322. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106323. }
  106324. }
  106325. declare module BABYLON {
  106326. /** @hidden */
  106327. export var mrtFragmentDeclaration: {
  106328. name: string;
  106329. shader: string;
  106330. };
  106331. }
  106332. declare module BABYLON {
  106333. /** @hidden */
  106334. export var geometryPixelShader: {
  106335. name: string;
  106336. shader: string;
  106337. };
  106338. }
  106339. declare module BABYLON {
  106340. /** @hidden */
  106341. export var geometryVertexShader: {
  106342. name: string;
  106343. shader: string;
  106344. };
  106345. }
  106346. declare module BABYLON {
  106347. /**
  106348. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  106349. */
  106350. export class GeometryBufferRenderer {
  106351. /**
  106352. * Constant used to retrieve the position texture index in the G-Buffer textures array
  106353. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  106354. */
  106355. static readonly POSITION_TEXTURE_TYPE: number;
  106356. /**
  106357. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  106358. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  106359. */
  106360. static readonly VELOCITY_TEXTURE_TYPE: number;
  106361. /**
  106362. * Dictionary used to store the previous transformation matrices of each rendered mesh
  106363. * in order to compute objects velocities when enableVelocity is set to "true"
  106364. * @hidden
  106365. */
  106366. _previousTransformationMatrices: {
  106367. [index: number]: Matrix;
  106368. };
  106369. private _scene;
  106370. private _multiRenderTarget;
  106371. private _ratio;
  106372. private _enablePosition;
  106373. private _enableVelocity;
  106374. private _positionIndex;
  106375. private _velocityIndex;
  106376. protected _effect: Effect;
  106377. protected _cachedDefines: string;
  106378. /**
  106379. * Set the render list (meshes to be rendered) used in the G buffer.
  106380. */
  106381. renderList: Mesh[];
  106382. /**
  106383. * Gets wether or not G buffer are supported by the running hardware.
  106384. * This requires draw buffer supports
  106385. */
  106386. readonly isSupported: boolean;
  106387. /**
  106388. * Returns the index of the given texture type in the G-Buffer textures array
  106389. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  106390. * @returns the index of the given texture type in the G-Buffer textures array
  106391. */
  106392. getTextureIndex(textureType: number): number;
  106393. /**
  106394. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  106395. */
  106396. /**
  106397. * Sets whether or not objects positions are enabled for the G buffer.
  106398. */
  106399. enablePosition: boolean;
  106400. /**
  106401. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  106402. */
  106403. /**
  106404. * Sets wether or not objects velocities are enabled for the G buffer.
  106405. */
  106406. enableVelocity: boolean;
  106407. /**
  106408. * Gets the scene associated with the buffer.
  106409. */
  106410. readonly scene: Scene;
  106411. /**
  106412. * Gets the ratio used by the buffer during its creation.
  106413. * How big is the buffer related to the main canvas.
  106414. */
  106415. readonly ratio: number;
  106416. /** @hidden */
  106417. static _SceneComponentInitialization: (scene: Scene) => void;
  106418. /**
  106419. * Creates a new G Buffer for the scene
  106420. * @param scene The scene the buffer belongs to
  106421. * @param ratio How big is the buffer related to the main canvas.
  106422. */
  106423. constructor(scene: Scene, ratio?: number);
  106424. /**
  106425. * Checks wether everything is ready to render a submesh to the G buffer.
  106426. * @param subMesh the submesh to check readiness for
  106427. * @param useInstances is the mesh drawn using instance or not
  106428. * @returns true if ready otherwise false
  106429. */
  106430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106431. /**
  106432. * Gets the current underlying G Buffer.
  106433. * @returns the buffer
  106434. */
  106435. getGBuffer(): MultiRenderTarget;
  106436. /**
  106437. * Gets the number of samples used to render the buffer (anti aliasing).
  106438. */
  106439. /**
  106440. * Sets the number of samples used to render the buffer (anti aliasing).
  106441. */
  106442. samples: number;
  106443. /**
  106444. * Disposes the renderer and frees up associated resources.
  106445. */
  106446. dispose(): void;
  106447. protected _createRenderTargets(): void;
  106448. }
  106449. }
  106450. declare module BABYLON {
  106451. /** @hidden */
  106452. export var motionBlurPixelShader: {
  106453. name: string;
  106454. shader: string;
  106455. };
  106456. }
  106457. declare module BABYLON {
  106458. /**
  106459. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  106460. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  106461. * As an example, all you have to do is to create the post-process:
  106462. * var mb = new BABYLON.MotionBlurPostProcess(
  106463. * 'mb', // The name of the effect.
  106464. * scene, // The scene containing the objects to blur according to their velocity.
  106465. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  106466. * camera // The camera to apply the render pass to.
  106467. * );
  106468. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  106469. */
  106470. export class MotionBlurPostProcess extends PostProcess {
  106471. /**
  106472. * Defines how much the image is blurred by the movement. Default value is equal to 1
  106473. */
  106474. motionStrength: number;
  106475. /**
  106476. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  106477. */
  106478. /**
  106479. * Sets the number of iterations to be used for motion blur quality
  106480. */
  106481. motionBlurSamples: number;
  106482. private _motionBlurSamples;
  106483. private _geometryBufferRenderer;
  106484. /**
  106485. * Creates a new instance MotionBlurPostProcess
  106486. * @param name The name of the effect.
  106487. * @param scene The scene containing the objects to blur according to their velocity.
  106488. * @param options The required width/height ratio to downsize to before computing the render pass.
  106489. * @param camera The camera to apply the render pass to.
  106490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106491. * @param engine The engine which the post process will be applied. (default: current engine)
  106492. * @param reusable If the post process can be reused on the same frame. (default: false)
  106493. * @param textureType Type of textures used when performing the post process. (default: 0)
  106494. * @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)
  106495. */
  106496. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106497. /**
  106498. * Disposes the post process.
  106499. * @param camera The camera to dispose the post process on.
  106500. */
  106501. dispose(camera?: Camera): void;
  106502. }
  106503. }
  106504. declare module BABYLON {
  106505. /** @hidden */
  106506. export var refractionPixelShader: {
  106507. name: string;
  106508. shader: string;
  106509. };
  106510. }
  106511. declare module BABYLON {
  106512. /**
  106513. * Post process which applies a refractin texture
  106514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106515. */
  106516. export class RefractionPostProcess extends PostProcess {
  106517. /** the base color of the refraction (used to taint the rendering) */
  106518. color: Color3;
  106519. /** simulated refraction depth */
  106520. depth: number;
  106521. /** the coefficient of the base color (0 to remove base color tainting) */
  106522. colorLevel: number;
  106523. private _refTexture;
  106524. private _ownRefractionTexture;
  106525. /**
  106526. * Gets or sets the refraction texture
  106527. * Please note that you are responsible for disposing the texture if you set it manually
  106528. */
  106529. refractionTexture: Texture;
  106530. /**
  106531. * Initializes the RefractionPostProcess
  106532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106533. * @param name The name of the effect.
  106534. * @param refractionTextureUrl Url of the refraction texture to use
  106535. * @param color the base color of the refraction (used to taint the rendering)
  106536. * @param depth simulated refraction depth
  106537. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  106538. * @param camera The camera to apply the render pass to.
  106539. * @param options The required width/height ratio to downsize to before computing the render pass.
  106540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106541. * @param engine The engine which the post process will be applied. (default: current engine)
  106542. * @param reusable If the post process can be reused on the same frame. (default: false)
  106543. */
  106544. constructor(name: string, refractionTextureUrl: string,
  106545. /** the base color of the refraction (used to taint the rendering) */
  106546. color: Color3,
  106547. /** simulated refraction depth */
  106548. depth: number,
  106549. /** the coefficient of the base color (0 to remove base color tainting) */
  106550. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106551. /**
  106552. * Disposes of the post process
  106553. * @param camera Camera to dispose post process on
  106554. */
  106555. dispose(camera: Camera): void;
  106556. }
  106557. }
  106558. declare module BABYLON {
  106559. /** @hidden */
  106560. export var sharpenPixelShader: {
  106561. name: string;
  106562. shader: string;
  106563. };
  106564. }
  106565. declare module BABYLON {
  106566. /**
  106567. * The SharpenPostProcess applies a sharpen kernel to every pixel
  106568. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106569. */
  106570. export class SharpenPostProcess extends PostProcess {
  106571. /**
  106572. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  106573. */
  106574. colorAmount: number;
  106575. /**
  106576. * How much sharpness should be applied (default: 0.3)
  106577. */
  106578. edgeAmount: number;
  106579. /**
  106580. * Creates a new instance ConvolutionPostProcess
  106581. * @param name The name of the effect.
  106582. * @param options The required width/height ratio to downsize to before computing the render pass.
  106583. * @param camera The camera to apply the render pass to.
  106584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106585. * @param engine The engine which the post process will be applied. (default: current engine)
  106586. * @param reusable If the post process can be reused on the same frame. (default: false)
  106587. * @param textureType Type of textures used when performing the post process. (default: 0)
  106588. * @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)
  106589. */
  106590. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106591. }
  106592. }
  106593. declare module BABYLON {
  106594. /**
  106595. * PostProcessRenderPipeline
  106596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106597. */
  106598. export class PostProcessRenderPipeline {
  106599. private engine;
  106600. private _renderEffects;
  106601. private _renderEffectsForIsolatedPass;
  106602. /**
  106603. * @hidden
  106604. */
  106605. protected _cameras: Camera[];
  106606. /** @hidden */
  106607. _name: string;
  106608. /**
  106609. * Initializes a PostProcessRenderPipeline
  106610. * @param engine engine to add the pipeline to
  106611. * @param name name of the pipeline
  106612. */
  106613. constructor(engine: Engine, name: string);
  106614. /**
  106615. * "PostProcessRenderPipeline"
  106616. * @returns "PostProcessRenderPipeline"
  106617. */
  106618. getClassName(): string;
  106619. /**
  106620. * If all the render effects in the pipeline are support
  106621. */
  106622. readonly isSupported: boolean;
  106623. /**
  106624. * Adds an effect to the pipeline
  106625. * @param renderEffect the effect to add
  106626. */
  106627. addEffect(renderEffect: PostProcessRenderEffect): void;
  106628. /** @hidden */
  106629. _rebuild(): void;
  106630. /** @hidden */
  106631. _enableEffect(renderEffectName: string, cameras: Camera): void;
  106632. /** @hidden */
  106633. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  106634. /** @hidden */
  106635. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106636. /** @hidden */
  106637. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106638. /** @hidden */
  106639. _attachCameras(cameras: Camera, unique: boolean): void;
  106640. /** @hidden */
  106641. _attachCameras(cameras: Camera[], unique: boolean): void;
  106642. /** @hidden */
  106643. _detachCameras(cameras: Camera): void;
  106644. /** @hidden */
  106645. _detachCameras(cameras: Nullable<Camera[]>): void;
  106646. /** @hidden */
  106647. _update(): void;
  106648. /** @hidden */
  106649. _reset(): void;
  106650. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  106651. /**
  106652. * Disposes of the pipeline
  106653. */
  106654. dispose(): void;
  106655. }
  106656. }
  106657. declare module BABYLON {
  106658. /**
  106659. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  106660. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106661. */
  106662. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106663. private _scene;
  106664. private _camerasToBeAttached;
  106665. /**
  106666. * ID of the sharpen post process,
  106667. */
  106668. private readonly SharpenPostProcessId;
  106669. /**
  106670. * @ignore
  106671. * ID of the image processing post process;
  106672. */
  106673. readonly ImageProcessingPostProcessId: string;
  106674. /**
  106675. * @ignore
  106676. * ID of the Fast Approximate Anti-Aliasing post process;
  106677. */
  106678. readonly FxaaPostProcessId: string;
  106679. /**
  106680. * ID of the chromatic aberration post process,
  106681. */
  106682. private readonly ChromaticAberrationPostProcessId;
  106683. /**
  106684. * ID of the grain post process
  106685. */
  106686. private readonly GrainPostProcessId;
  106687. /**
  106688. * Sharpen post process which will apply a sharpen convolution to enhance edges
  106689. */
  106690. sharpen: SharpenPostProcess;
  106691. private _sharpenEffect;
  106692. private bloom;
  106693. /**
  106694. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  106695. */
  106696. depthOfField: DepthOfFieldEffect;
  106697. /**
  106698. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106699. */
  106700. fxaa: FxaaPostProcess;
  106701. /**
  106702. * Image post processing pass used to perform operations such as tone mapping or color grading.
  106703. */
  106704. imageProcessing: ImageProcessingPostProcess;
  106705. /**
  106706. * Chromatic aberration post process which will shift rgb colors in the image
  106707. */
  106708. chromaticAberration: ChromaticAberrationPostProcess;
  106709. private _chromaticAberrationEffect;
  106710. /**
  106711. * Grain post process which add noise to the image
  106712. */
  106713. grain: GrainPostProcess;
  106714. private _grainEffect;
  106715. /**
  106716. * Glow post process which adds a glow to emmisive areas of the image
  106717. */
  106718. private _glowLayer;
  106719. /**
  106720. * Animations which can be used to tweak settings over a period of time
  106721. */
  106722. animations: Animation[];
  106723. private _imageProcessingConfigurationObserver;
  106724. private _sharpenEnabled;
  106725. private _bloomEnabled;
  106726. private _depthOfFieldEnabled;
  106727. private _depthOfFieldBlurLevel;
  106728. private _fxaaEnabled;
  106729. private _imageProcessingEnabled;
  106730. private _defaultPipelineTextureType;
  106731. private _bloomScale;
  106732. private _chromaticAberrationEnabled;
  106733. private _grainEnabled;
  106734. private _buildAllowed;
  106735. /**
  106736. * Enable or disable the sharpen process from the pipeline
  106737. */
  106738. sharpenEnabled: boolean;
  106739. private _resizeObserver;
  106740. private _hardwareScaleLevel;
  106741. private _bloomKernel;
  106742. /**
  106743. * Specifies the size of the bloom blur kernel, relative to the final output size
  106744. */
  106745. bloomKernel: number;
  106746. /**
  106747. * Specifies the weight of the bloom in the final rendering
  106748. */
  106749. private _bloomWeight;
  106750. /**
  106751. * Specifies the luma threshold for the area that will be blurred by the bloom
  106752. */
  106753. private _bloomThreshold;
  106754. private _hdr;
  106755. /**
  106756. * The strength of the bloom.
  106757. */
  106758. bloomWeight: number;
  106759. /**
  106760. * The strength of the bloom.
  106761. */
  106762. bloomThreshold: number;
  106763. /**
  106764. * The scale of the bloom, lower value will provide better performance.
  106765. */
  106766. bloomScale: number;
  106767. /**
  106768. * Enable or disable the bloom from the pipeline
  106769. */
  106770. bloomEnabled: boolean;
  106771. private _rebuildBloom;
  106772. /**
  106773. * If the depth of field is enabled.
  106774. */
  106775. depthOfFieldEnabled: boolean;
  106776. /**
  106777. * Blur level of the depth of field effect. (Higher blur will effect performance)
  106778. */
  106779. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  106780. /**
  106781. * If the anti aliasing is enabled.
  106782. */
  106783. fxaaEnabled: boolean;
  106784. private _samples;
  106785. /**
  106786. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106787. */
  106788. samples: number;
  106789. /**
  106790. * If image processing is enabled.
  106791. */
  106792. imageProcessingEnabled: boolean;
  106793. /**
  106794. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  106795. */
  106796. glowLayerEnabled: boolean;
  106797. /**
  106798. * Enable or disable the chromaticAberration process from the pipeline
  106799. */
  106800. chromaticAberrationEnabled: boolean;
  106801. /**
  106802. * Enable or disable the grain process from the pipeline
  106803. */
  106804. grainEnabled: boolean;
  106805. /**
  106806. * @constructor
  106807. * @param name - The rendering pipeline name (default: "")
  106808. * @param hdr - If high dynamic range textures should be used (default: true)
  106809. * @param scene - The scene linked to this pipeline (default: the last created scene)
  106810. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  106811. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  106812. */
  106813. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  106814. /**
  106815. * Force the compilation of the entire pipeline.
  106816. */
  106817. prepare(): void;
  106818. private _hasCleared;
  106819. private _prevPostProcess;
  106820. private _prevPrevPostProcess;
  106821. private _setAutoClearAndTextureSharing;
  106822. private _depthOfFieldSceneObserver;
  106823. private _buildPipeline;
  106824. private _disposePostProcesses;
  106825. /**
  106826. * Adds a camera to the pipeline
  106827. * @param camera the camera to be added
  106828. */
  106829. addCamera(camera: Camera): void;
  106830. /**
  106831. * Removes a camera from the pipeline
  106832. * @param camera the camera to remove
  106833. */
  106834. removeCamera(camera: Camera): void;
  106835. /**
  106836. * Dispose of the pipeline and stop all post processes
  106837. */
  106838. dispose(): void;
  106839. /**
  106840. * Serialize the rendering pipeline (Used when exporting)
  106841. * @returns the serialized object
  106842. */
  106843. serialize(): any;
  106844. /**
  106845. * Parse the serialized pipeline
  106846. * @param source Source pipeline.
  106847. * @param scene The scene to load the pipeline to.
  106848. * @param rootUrl The URL of the serialized pipeline.
  106849. * @returns An instantiated pipeline from the serialized object.
  106850. */
  106851. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  106852. }
  106853. }
  106854. declare module BABYLON {
  106855. /** @hidden */
  106856. export var lensHighlightsPixelShader: {
  106857. name: string;
  106858. shader: string;
  106859. };
  106860. }
  106861. declare module BABYLON {
  106862. /** @hidden */
  106863. export var depthOfFieldPixelShader: {
  106864. name: string;
  106865. shader: string;
  106866. };
  106867. }
  106868. declare module BABYLON {
  106869. /**
  106870. * BABYLON.JS Chromatic Aberration GLSL Shader
  106871. * Author: Olivier Guyot
  106872. * Separates very slightly R, G and B colors on the edges of the screen
  106873. * Inspired by Francois Tarlier & Martins Upitis
  106874. */
  106875. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  106876. /**
  106877. * @ignore
  106878. * The chromatic aberration PostProcess id in the pipeline
  106879. */
  106880. LensChromaticAberrationEffect: string;
  106881. /**
  106882. * @ignore
  106883. * The highlights enhancing PostProcess id in the pipeline
  106884. */
  106885. HighlightsEnhancingEffect: string;
  106886. /**
  106887. * @ignore
  106888. * The depth-of-field PostProcess id in the pipeline
  106889. */
  106890. LensDepthOfFieldEffect: string;
  106891. private _scene;
  106892. private _depthTexture;
  106893. private _grainTexture;
  106894. private _chromaticAberrationPostProcess;
  106895. private _highlightsPostProcess;
  106896. private _depthOfFieldPostProcess;
  106897. private _edgeBlur;
  106898. private _grainAmount;
  106899. private _chromaticAberration;
  106900. private _distortion;
  106901. private _highlightsGain;
  106902. private _highlightsThreshold;
  106903. private _dofDistance;
  106904. private _dofAperture;
  106905. private _dofDarken;
  106906. private _dofPentagon;
  106907. private _blurNoise;
  106908. /**
  106909. * @constructor
  106910. *
  106911. * Effect parameters are as follow:
  106912. * {
  106913. * chromatic_aberration: number; // from 0 to x (1 for realism)
  106914. * edge_blur: number; // from 0 to x (1 for realism)
  106915. * distortion: number; // from 0 to x (1 for realism)
  106916. * grain_amount: number; // from 0 to 1
  106917. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  106918. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  106919. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  106920. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  106921. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  106922. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  106923. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  106924. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  106925. * }
  106926. * Note: if an effect parameter is unset, effect is disabled
  106927. *
  106928. * @param name The rendering pipeline name
  106929. * @param parameters - An object containing all parameters (see above)
  106930. * @param scene The scene linked to this pipeline
  106931. * @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)
  106932. * @param cameras The array of cameras that the rendering pipeline will be attached to
  106933. */
  106934. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  106935. /**
  106936. * Sets the amount of blur at the edges
  106937. * @param amount blur amount
  106938. */
  106939. setEdgeBlur(amount: number): void;
  106940. /**
  106941. * Sets edge blur to 0
  106942. */
  106943. disableEdgeBlur(): void;
  106944. /**
  106945. * Sets the amout of grain
  106946. * @param amount Amount of grain
  106947. */
  106948. setGrainAmount(amount: number): void;
  106949. /**
  106950. * Set grain amount to 0
  106951. */
  106952. disableGrain(): void;
  106953. /**
  106954. * Sets the chromatic aberration amount
  106955. * @param amount amount of chromatic aberration
  106956. */
  106957. setChromaticAberration(amount: number): void;
  106958. /**
  106959. * Sets chromatic aberration amount to 0
  106960. */
  106961. disableChromaticAberration(): void;
  106962. /**
  106963. * Sets the EdgeDistortion amount
  106964. * @param amount amount of EdgeDistortion
  106965. */
  106966. setEdgeDistortion(amount: number): void;
  106967. /**
  106968. * Sets edge distortion to 0
  106969. */
  106970. disableEdgeDistortion(): void;
  106971. /**
  106972. * Sets the FocusDistance amount
  106973. * @param amount amount of FocusDistance
  106974. */
  106975. setFocusDistance(amount: number): void;
  106976. /**
  106977. * Disables depth of field
  106978. */
  106979. disableDepthOfField(): void;
  106980. /**
  106981. * Sets the Aperture amount
  106982. * @param amount amount of Aperture
  106983. */
  106984. setAperture(amount: number): void;
  106985. /**
  106986. * Sets the DarkenOutOfFocus amount
  106987. * @param amount amount of DarkenOutOfFocus
  106988. */
  106989. setDarkenOutOfFocus(amount: number): void;
  106990. /**
  106991. * Creates a pentagon bokeh effect
  106992. */
  106993. enablePentagonBokeh(): void;
  106994. /**
  106995. * Disables the pentagon bokeh effect
  106996. */
  106997. disablePentagonBokeh(): void;
  106998. /**
  106999. * Enables noise blur
  107000. */
  107001. enableNoiseBlur(): void;
  107002. /**
  107003. * Disables noise blur
  107004. */
  107005. disableNoiseBlur(): void;
  107006. /**
  107007. * Sets the HighlightsGain amount
  107008. * @param amount amount of HighlightsGain
  107009. */
  107010. setHighlightsGain(amount: number): void;
  107011. /**
  107012. * Sets the HighlightsThreshold amount
  107013. * @param amount amount of HighlightsThreshold
  107014. */
  107015. setHighlightsThreshold(amount: number): void;
  107016. /**
  107017. * Disables highlights
  107018. */
  107019. disableHighlights(): void;
  107020. /**
  107021. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107022. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107023. */
  107024. dispose(disableDepthRender?: boolean): void;
  107025. private _createChromaticAberrationPostProcess;
  107026. private _createHighlightsPostProcess;
  107027. private _createDepthOfFieldPostProcess;
  107028. private _createGrainTexture;
  107029. }
  107030. }
  107031. declare module BABYLON {
  107032. /** @hidden */
  107033. export var ssao2PixelShader: {
  107034. name: string;
  107035. shader: string;
  107036. };
  107037. }
  107038. declare module BABYLON {
  107039. /** @hidden */
  107040. export var ssaoCombinePixelShader: {
  107041. name: string;
  107042. shader: string;
  107043. };
  107044. }
  107045. declare module BABYLON {
  107046. /**
  107047. * Render pipeline to produce ssao effect
  107048. */
  107049. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107050. /**
  107051. * @ignore
  107052. * The PassPostProcess id in the pipeline that contains the original scene color
  107053. */
  107054. SSAOOriginalSceneColorEffect: string;
  107055. /**
  107056. * @ignore
  107057. * The SSAO PostProcess id in the pipeline
  107058. */
  107059. SSAORenderEffect: string;
  107060. /**
  107061. * @ignore
  107062. * The horizontal blur PostProcess id in the pipeline
  107063. */
  107064. SSAOBlurHRenderEffect: string;
  107065. /**
  107066. * @ignore
  107067. * The vertical blur PostProcess id in the pipeline
  107068. */
  107069. SSAOBlurVRenderEffect: string;
  107070. /**
  107071. * @ignore
  107072. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107073. */
  107074. SSAOCombineRenderEffect: string;
  107075. /**
  107076. * The output strength of the SSAO post-process. Default value is 1.0.
  107077. */
  107078. totalStrength: number;
  107079. /**
  107080. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107081. */
  107082. maxZ: number;
  107083. /**
  107084. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107085. */
  107086. minZAspect: number;
  107087. private _samples;
  107088. /**
  107089. * Number of samples used for the SSAO calculations. Default value is 8
  107090. */
  107091. samples: number;
  107092. private _textureSamples;
  107093. /**
  107094. * Number of samples to use for antialiasing
  107095. */
  107096. textureSamples: number;
  107097. /**
  107098. * Ratio object used for SSAO ratio and blur ratio
  107099. */
  107100. private _ratio;
  107101. /**
  107102. * Dynamically generated sphere sampler.
  107103. */
  107104. private _sampleSphere;
  107105. /**
  107106. * Blur filter offsets
  107107. */
  107108. private _samplerOffsets;
  107109. private _expensiveBlur;
  107110. /**
  107111. * If bilateral blur should be used
  107112. */
  107113. expensiveBlur: boolean;
  107114. /**
  107115. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107116. */
  107117. radius: number;
  107118. /**
  107119. * The base color of the SSAO post-process
  107120. * The final result is "base + ssao" between [0, 1]
  107121. */
  107122. base: number;
  107123. /**
  107124. * Support test.
  107125. */
  107126. static readonly IsSupported: boolean;
  107127. private _scene;
  107128. private _depthTexture;
  107129. private _normalTexture;
  107130. private _randomTexture;
  107131. private _originalColorPostProcess;
  107132. private _ssaoPostProcess;
  107133. private _blurHPostProcess;
  107134. private _blurVPostProcess;
  107135. private _ssaoCombinePostProcess;
  107136. private _firstUpdate;
  107137. /**
  107138. * @constructor
  107139. * @param name The rendering pipeline name
  107140. * @param scene The scene linked to this pipeline
  107141. * @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 }
  107142. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107143. */
  107144. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107145. /**
  107146. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107147. */
  107148. dispose(disableGeometryBufferRenderer?: boolean): void;
  107149. private _createBlurPostProcess;
  107150. /** @hidden */
  107151. _rebuild(): void;
  107152. private _bits;
  107153. private _radicalInverse_VdC;
  107154. private _hammersley;
  107155. private _hemisphereSample_uniform;
  107156. private _generateHemisphere;
  107157. private _createSSAOPostProcess;
  107158. private _createSSAOCombinePostProcess;
  107159. private _createRandomTexture;
  107160. /**
  107161. * Serialize the rendering pipeline (Used when exporting)
  107162. * @returns the serialized object
  107163. */
  107164. serialize(): any;
  107165. /**
  107166. * Parse the serialized pipeline
  107167. * @param source Source pipeline.
  107168. * @param scene The scene to load the pipeline to.
  107169. * @param rootUrl The URL of the serialized pipeline.
  107170. * @returns An instantiated pipeline from the serialized object.
  107171. */
  107172. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107173. }
  107174. }
  107175. declare module BABYLON {
  107176. /** @hidden */
  107177. export var ssaoPixelShader: {
  107178. name: string;
  107179. shader: string;
  107180. };
  107181. }
  107182. declare module BABYLON {
  107183. /**
  107184. * Render pipeline to produce ssao effect
  107185. */
  107186. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107187. /**
  107188. * @ignore
  107189. * The PassPostProcess id in the pipeline that contains the original scene color
  107190. */
  107191. SSAOOriginalSceneColorEffect: string;
  107192. /**
  107193. * @ignore
  107194. * The SSAO PostProcess id in the pipeline
  107195. */
  107196. SSAORenderEffect: string;
  107197. /**
  107198. * @ignore
  107199. * The horizontal blur PostProcess id in the pipeline
  107200. */
  107201. SSAOBlurHRenderEffect: string;
  107202. /**
  107203. * @ignore
  107204. * The vertical blur PostProcess id in the pipeline
  107205. */
  107206. SSAOBlurVRenderEffect: string;
  107207. /**
  107208. * @ignore
  107209. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107210. */
  107211. SSAOCombineRenderEffect: string;
  107212. /**
  107213. * The output strength of the SSAO post-process. Default value is 1.0.
  107214. */
  107215. totalStrength: number;
  107216. /**
  107217. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107218. */
  107219. radius: number;
  107220. /**
  107221. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107222. * Must not be equal to fallOff and superior to fallOff.
  107223. * Default value is 0.975
  107224. */
  107225. area: number;
  107226. /**
  107227. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107228. * Must not be equal to area and inferior to area.
  107229. * Default value is 0.0
  107230. */
  107231. fallOff: number;
  107232. /**
  107233. * The base color of the SSAO post-process
  107234. * The final result is "base + ssao" between [0, 1]
  107235. */
  107236. base: number;
  107237. private _scene;
  107238. private _depthTexture;
  107239. private _randomTexture;
  107240. private _originalColorPostProcess;
  107241. private _ssaoPostProcess;
  107242. private _blurHPostProcess;
  107243. private _blurVPostProcess;
  107244. private _ssaoCombinePostProcess;
  107245. private _firstUpdate;
  107246. /**
  107247. * @constructor
  107248. * @param name - The rendering pipeline name
  107249. * @param scene - The scene linked to this pipeline
  107250. * @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 }
  107251. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107252. */
  107253. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107254. /**
  107255. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107256. */
  107257. dispose(disableDepthRender?: boolean): void;
  107258. private _createBlurPostProcess;
  107259. /** @hidden */
  107260. _rebuild(): void;
  107261. private _createSSAOPostProcess;
  107262. private _createSSAOCombinePostProcess;
  107263. private _createRandomTexture;
  107264. }
  107265. }
  107266. declare module BABYLON {
  107267. /** @hidden */
  107268. export var standardPixelShader: {
  107269. name: string;
  107270. shader: string;
  107271. };
  107272. }
  107273. declare module BABYLON {
  107274. /**
  107275. * Standard rendering pipeline
  107276. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107277. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  107278. */
  107279. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107280. /**
  107281. * Public members
  107282. */
  107283. /**
  107284. * Post-process which contains the original scene color before the pipeline applies all the effects
  107285. */
  107286. originalPostProcess: Nullable<PostProcess>;
  107287. /**
  107288. * Post-process used to down scale an image x4
  107289. */
  107290. downSampleX4PostProcess: Nullable<PostProcess>;
  107291. /**
  107292. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  107293. */
  107294. brightPassPostProcess: Nullable<PostProcess>;
  107295. /**
  107296. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  107297. */
  107298. blurHPostProcesses: PostProcess[];
  107299. /**
  107300. * Post-process array storing all the vertical blur post-processes used by the pipeline
  107301. */
  107302. blurVPostProcesses: PostProcess[];
  107303. /**
  107304. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  107305. */
  107306. textureAdderPostProcess: Nullable<PostProcess>;
  107307. /**
  107308. * Post-process used to create volumetric lighting effect
  107309. */
  107310. volumetricLightPostProcess: Nullable<PostProcess>;
  107311. /**
  107312. * Post-process used to smooth the previous volumetric light post-process on the X axis
  107313. */
  107314. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  107315. /**
  107316. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  107317. */
  107318. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  107319. /**
  107320. * Post-process used to merge the volumetric light effect and the real scene color
  107321. */
  107322. volumetricLightMergePostProces: Nullable<PostProcess>;
  107323. /**
  107324. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  107325. */
  107326. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  107327. /**
  107328. * Base post-process used to calculate the average luminance of the final image for HDR
  107329. */
  107330. luminancePostProcess: Nullable<PostProcess>;
  107331. /**
  107332. * Post-processes used to create down sample post-processes in order to get
  107333. * the average luminance of the final image for HDR
  107334. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  107335. */
  107336. luminanceDownSamplePostProcesses: PostProcess[];
  107337. /**
  107338. * Post-process used to create a HDR effect (light adaptation)
  107339. */
  107340. hdrPostProcess: Nullable<PostProcess>;
  107341. /**
  107342. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  107343. */
  107344. textureAdderFinalPostProcess: Nullable<PostProcess>;
  107345. /**
  107346. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  107347. */
  107348. lensFlareFinalPostProcess: Nullable<PostProcess>;
  107349. /**
  107350. * Post-process used to merge the final HDR post-process and the real scene color
  107351. */
  107352. hdrFinalPostProcess: Nullable<PostProcess>;
  107353. /**
  107354. * Post-process used to create a lens flare effect
  107355. */
  107356. lensFlarePostProcess: Nullable<PostProcess>;
  107357. /**
  107358. * Post-process that merges the result of the lens flare post-process and the real scene color
  107359. */
  107360. lensFlareComposePostProcess: Nullable<PostProcess>;
  107361. /**
  107362. * Post-process used to create a motion blur effect
  107363. */
  107364. motionBlurPostProcess: Nullable<PostProcess>;
  107365. /**
  107366. * Post-process used to create a depth of field effect
  107367. */
  107368. depthOfFieldPostProcess: Nullable<PostProcess>;
  107369. /**
  107370. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107371. */
  107372. fxaaPostProcess: Nullable<FxaaPostProcess>;
  107373. /**
  107374. * Represents the brightness threshold in order to configure the illuminated surfaces
  107375. */
  107376. brightThreshold: number;
  107377. /**
  107378. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  107379. */
  107380. blurWidth: number;
  107381. /**
  107382. * Sets if the blur for highlighted surfaces must be only horizontal
  107383. */
  107384. horizontalBlur: boolean;
  107385. /**
  107386. * Sets the overall exposure used by the pipeline
  107387. */
  107388. exposure: number;
  107389. /**
  107390. * Texture used typically to simulate "dirty" on camera lens
  107391. */
  107392. lensTexture: Nullable<Texture>;
  107393. /**
  107394. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  107395. */
  107396. volumetricLightCoefficient: number;
  107397. /**
  107398. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  107399. */
  107400. volumetricLightPower: number;
  107401. /**
  107402. * Used the set the blur intensity to smooth the volumetric lights
  107403. */
  107404. volumetricLightBlurScale: number;
  107405. /**
  107406. * Light (spot or directional) used to generate the volumetric lights rays
  107407. * The source light must have a shadow generate so the pipeline can get its
  107408. * depth map
  107409. */
  107410. sourceLight: Nullable<SpotLight | DirectionalLight>;
  107411. /**
  107412. * For eye adaptation, represents the minimum luminance the eye can see
  107413. */
  107414. hdrMinimumLuminance: number;
  107415. /**
  107416. * For eye adaptation, represents the decrease luminance speed
  107417. */
  107418. hdrDecreaseRate: number;
  107419. /**
  107420. * For eye adaptation, represents the increase luminance speed
  107421. */
  107422. hdrIncreaseRate: number;
  107423. /**
  107424. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  107425. */
  107426. lensColorTexture: Nullable<Texture>;
  107427. /**
  107428. * The overall strengh for the lens flare effect
  107429. */
  107430. lensFlareStrength: number;
  107431. /**
  107432. * Dispersion coefficient for lens flare ghosts
  107433. */
  107434. lensFlareGhostDispersal: number;
  107435. /**
  107436. * Main lens flare halo width
  107437. */
  107438. lensFlareHaloWidth: number;
  107439. /**
  107440. * Based on the lens distortion effect, defines how much the lens flare result
  107441. * is distorted
  107442. */
  107443. lensFlareDistortionStrength: number;
  107444. /**
  107445. * Lens star texture must be used to simulate rays on the flares and is available
  107446. * in the documentation
  107447. */
  107448. lensStarTexture: Nullable<Texture>;
  107449. /**
  107450. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  107451. * flare effect by taking account of the dirt texture
  107452. */
  107453. lensFlareDirtTexture: Nullable<Texture>;
  107454. /**
  107455. * Represents the focal length for the depth of field effect
  107456. */
  107457. depthOfFieldDistance: number;
  107458. /**
  107459. * Represents the blur intensity for the blurred part of the depth of field effect
  107460. */
  107461. depthOfFieldBlurWidth: number;
  107462. /**
  107463. * For motion blur, defines how much the image is blurred by the movement
  107464. */
  107465. motionStrength: number;
  107466. /**
  107467. * List of animations for the pipeline (IAnimatable implementation)
  107468. */
  107469. animations: Animation[];
  107470. /**
  107471. * Private members
  107472. */
  107473. private _scene;
  107474. private _currentDepthOfFieldSource;
  107475. private _basePostProcess;
  107476. private _hdrCurrentLuminance;
  107477. private _floatTextureType;
  107478. private _ratio;
  107479. private _bloomEnabled;
  107480. private _depthOfFieldEnabled;
  107481. private _vlsEnabled;
  107482. private _lensFlareEnabled;
  107483. private _hdrEnabled;
  107484. private _motionBlurEnabled;
  107485. private _fxaaEnabled;
  107486. private _motionBlurSamples;
  107487. private _volumetricLightStepsCount;
  107488. private _samples;
  107489. /**
  107490. * @ignore
  107491. * Specifies if the bloom pipeline is enabled
  107492. */
  107493. BloomEnabled: boolean;
  107494. /**
  107495. * @ignore
  107496. * Specifies if the depth of field pipeline is enabed
  107497. */
  107498. DepthOfFieldEnabled: boolean;
  107499. /**
  107500. * @ignore
  107501. * Specifies if the lens flare pipeline is enabed
  107502. */
  107503. LensFlareEnabled: boolean;
  107504. /**
  107505. * @ignore
  107506. * Specifies if the HDR pipeline is enabled
  107507. */
  107508. HDREnabled: boolean;
  107509. /**
  107510. * @ignore
  107511. * Specifies if the volumetric lights scattering effect is enabled
  107512. */
  107513. VLSEnabled: boolean;
  107514. /**
  107515. * @ignore
  107516. * Specifies if the motion blur effect is enabled
  107517. */
  107518. MotionBlurEnabled: boolean;
  107519. /**
  107520. * Specifies if anti-aliasing is enabled
  107521. */
  107522. fxaaEnabled: boolean;
  107523. /**
  107524. * Specifies the number of steps used to calculate the volumetric lights
  107525. * Typically in interval [50, 200]
  107526. */
  107527. volumetricLightStepsCount: number;
  107528. /**
  107529. * Specifies the number of samples used for the motion blur effect
  107530. * Typically in interval [16, 64]
  107531. */
  107532. motionBlurSamples: number;
  107533. /**
  107534. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107535. */
  107536. samples: number;
  107537. /**
  107538. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107539. * @constructor
  107540. * @param name The rendering pipeline name
  107541. * @param scene The scene linked to this pipeline
  107542. * @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)
  107543. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  107544. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107545. */
  107546. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  107547. private _buildPipeline;
  107548. private _createDownSampleX4PostProcess;
  107549. private _createBrightPassPostProcess;
  107550. private _createBlurPostProcesses;
  107551. private _createTextureAdderPostProcess;
  107552. private _createVolumetricLightPostProcess;
  107553. private _createLuminancePostProcesses;
  107554. private _createHdrPostProcess;
  107555. private _createLensFlarePostProcess;
  107556. private _createDepthOfFieldPostProcess;
  107557. private _createMotionBlurPostProcess;
  107558. private _getDepthTexture;
  107559. private _disposePostProcesses;
  107560. /**
  107561. * Dispose of the pipeline and stop all post processes
  107562. */
  107563. dispose(): void;
  107564. /**
  107565. * Serialize the rendering pipeline (Used when exporting)
  107566. * @returns the serialized object
  107567. */
  107568. serialize(): any;
  107569. /**
  107570. * Parse the serialized pipeline
  107571. * @param source Source pipeline.
  107572. * @param scene The scene to load the pipeline to.
  107573. * @param rootUrl The URL of the serialized pipeline.
  107574. * @returns An instantiated pipeline from the serialized object.
  107575. */
  107576. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  107577. /**
  107578. * Luminance steps
  107579. */
  107580. static LuminanceSteps: number;
  107581. }
  107582. }
  107583. declare module BABYLON {
  107584. /**
  107585. * PostProcessRenderPipelineManager class
  107586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107587. */
  107588. export class PostProcessRenderPipelineManager {
  107589. private _renderPipelines;
  107590. /**
  107591. * Initializes a PostProcessRenderPipelineManager
  107592. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107593. */
  107594. constructor();
  107595. /**
  107596. * Adds a pipeline to the manager
  107597. * @param renderPipeline The pipeline to add
  107598. */
  107599. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  107600. /**
  107601. * Attaches a camera to the pipeline
  107602. * @param renderPipelineName The name of the pipeline to attach to
  107603. * @param cameras the camera to attach
  107604. * @param unique if the camera can be attached multiple times to the pipeline
  107605. */
  107606. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  107607. /**
  107608. * Detaches a camera from the pipeline
  107609. * @param renderPipelineName The name of the pipeline to detach from
  107610. * @param cameras the camera to detach
  107611. */
  107612. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  107613. /**
  107614. * Enables an effect by name on a pipeline
  107615. * @param renderPipelineName the name of the pipeline to enable the effect in
  107616. * @param renderEffectName the name of the effect to enable
  107617. * @param cameras the cameras that the effect should be enabled on
  107618. */
  107619. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107620. /**
  107621. * Disables an effect by name on a pipeline
  107622. * @param renderPipelineName the name of the pipeline to disable the effect in
  107623. * @param renderEffectName the name of the effect to disable
  107624. * @param cameras the cameras that the effect should be disabled on
  107625. */
  107626. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107627. /**
  107628. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  107629. */
  107630. update(): void;
  107631. /** @hidden */
  107632. _rebuild(): void;
  107633. /**
  107634. * Disposes of the manager and pipelines
  107635. */
  107636. dispose(): void;
  107637. }
  107638. }
  107639. declare module BABYLON {
  107640. interface Scene {
  107641. /** @hidden (Backing field) */
  107642. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107643. /**
  107644. * Gets the postprocess render pipeline manager
  107645. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107646. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107647. */
  107648. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107649. }
  107650. /**
  107651. * Defines the Render Pipeline scene component responsible to rendering pipelines
  107652. */
  107653. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  107654. /**
  107655. * The component name helpfull to identify the component in the list of scene components.
  107656. */
  107657. readonly name: string;
  107658. /**
  107659. * The scene the component belongs to.
  107660. */
  107661. scene: Scene;
  107662. /**
  107663. * Creates a new instance of the component for the given scene
  107664. * @param scene Defines the scene to register the component in
  107665. */
  107666. constructor(scene: Scene);
  107667. /**
  107668. * Registers the component in a given scene
  107669. */
  107670. register(): void;
  107671. /**
  107672. * Rebuilds the elements related to this component in case of
  107673. * context lost for instance.
  107674. */
  107675. rebuild(): void;
  107676. /**
  107677. * Disposes the component and the associated ressources
  107678. */
  107679. dispose(): void;
  107680. private _gatherRenderTargets;
  107681. }
  107682. }
  107683. declare module BABYLON {
  107684. /** @hidden */
  107685. export var tonemapPixelShader: {
  107686. name: string;
  107687. shader: string;
  107688. };
  107689. }
  107690. declare module BABYLON {
  107691. /** Defines operator used for tonemapping */
  107692. export enum TonemappingOperator {
  107693. /** Hable */
  107694. Hable = 0,
  107695. /** Reinhard */
  107696. Reinhard = 1,
  107697. /** HejiDawson */
  107698. HejiDawson = 2,
  107699. /** Photographic */
  107700. Photographic = 3
  107701. }
  107702. /**
  107703. * Defines a post process to apply tone mapping
  107704. */
  107705. export class TonemapPostProcess extends PostProcess {
  107706. private _operator;
  107707. /** Defines the required exposure adjustement */
  107708. exposureAdjustment: number;
  107709. /**
  107710. * Creates a new TonemapPostProcess
  107711. * @param name defines the name of the postprocess
  107712. * @param _operator defines the operator to use
  107713. * @param exposureAdjustment defines the required exposure adjustement
  107714. * @param camera defines the camera to use (can be null)
  107715. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  107716. * @param engine defines the hosting engine (can be ignore if camera is set)
  107717. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107718. */
  107719. constructor(name: string, _operator: TonemappingOperator,
  107720. /** Defines the required exposure adjustement */
  107721. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  107722. }
  107723. }
  107724. declare module BABYLON {
  107725. /** @hidden */
  107726. export var depthVertexShader: {
  107727. name: string;
  107728. shader: string;
  107729. };
  107730. }
  107731. declare module BABYLON {
  107732. /** @hidden */
  107733. export var volumetricLightScatteringPixelShader: {
  107734. name: string;
  107735. shader: string;
  107736. };
  107737. }
  107738. declare module BABYLON {
  107739. /** @hidden */
  107740. export var volumetricLightScatteringPassPixelShader: {
  107741. name: string;
  107742. shader: string;
  107743. };
  107744. }
  107745. declare module BABYLON {
  107746. /**
  107747. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  107748. */
  107749. export class VolumetricLightScatteringPostProcess extends PostProcess {
  107750. private _volumetricLightScatteringPass;
  107751. private _volumetricLightScatteringRTT;
  107752. private _viewPort;
  107753. private _screenCoordinates;
  107754. private _cachedDefines;
  107755. /**
  107756. * If not undefined, the mesh position is computed from the attached node position
  107757. */
  107758. attachedNode: {
  107759. position: Vector3;
  107760. };
  107761. /**
  107762. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  107763. */
  107764. customMeshPosition: Vector3;
  107765. /**
  107766. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  107767. */
  107768. useCustomMeshPosition: boolean;
  107769. /**
  107770. * If the post-process should inverse the light scattering direction
  107771. */
  107772. invert: boolean;
  107773. /**
  107774. * The internal mesh used by the post-process
  107775. */
  107776. mesh: Mesh;
  107777. /**
  107778. * @hidden
  107779. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  107780. */
  107781. useDiffuseColor: boolean;
  107782. /**
  107783. * Array containing the excluded meshes not rendered in the internal pass
  107784. */
  107785. excludedMeshes: AbstractMesh[];
  107786. /**
  107787. * Controls the overall intensity of the post-process
  107788. */
  107789. exposure: number;
  107790. /**
  107791. * Dissipates each sample's contribution in range [0, 1]
  107792. */
  107793. decay: number;
  107794. /**
  107795. * Controls the overall intensity of each sample
  107796. */
  107797. weight: number;
  107798. /**
  107799. * Controls the density of each sample
  107800. */
  107801. density: number;
  107802. /**
  107803. * @constructor
  107804. * @param name The post-process name
  107805. * @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)
  107806. * @param camera The camera that the post-process will be attached to
  107807. * @param mesh The mesh used to create the light scattering
  107808. * @param samples The post-process quality, default 100
  107809. * @param samplingModeThe post-process filtering mode
  107810. * @param engine The babylon engine
  107811. * @param reusable If the post-process is reusable
  107812. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  107813. */
  107814. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  107815. /**
  107816. * Returns the string "VolumetricLightScatteringPostProcess"
  107817. * @returns "VolumetricLightScatteringPostProcess"
  107818. */
  107819. getClassName(): string;
  107820. private _isReady;
  107821. /**
  107822. * Sets the new light position for light scattering effect
  107823. * @param position The new custom light position
  107824. */
  107825. setCustomMeshPosition(position: Vector3): void;
  107826. /**
  107827. * Returns the light position for light scattering effect
  107828. * @return Vector3 The custom light position
  107829. */
  107830. getCustomMeshPosition(): Vector3;
  107831. /**
  107832. * Disposes the internal assets and detaches the post-process from the camera
  107833. */
  107834. dispose(camera: Camera): void;
  107835. /**
  107836. * Returns the render target texture used by the post-process
  107837. * @return the render target texture used by the post-process
  107838. */
  107839. getPass(): RenderTargetTexture;
  107840. private _meshExcluded;
  107841. private _createPass;
  107842. private _updateMeshScreenCoordinates;
  107843. /**
  107844. * Creates a default mesh for the Volumeric Light Scattering post-process
  107845. * @param name The mesh name
  107846. * @param scene The scene where to create the mesh
  107847. * @return the default mesh
  107848. */
  107849. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  107850. }
  107851. }
  107852. declare module BABYLON {
  107853. interface Scene {
  107854. /** @hidden (Backing field) */
  107855. _boundingBoxRenderer: BoundingBoxRenderer;
  107856. /** @hidden (Backing field) */
  107857. _forceShowBoundingBoxes: boolean;
  107858. /**
  107859. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  107860. */
  107861. forceShowBoundingBoxes: boolean;
  107862. /**
  107863. * Gets the bounding box renderer associated with the scene
  107864. * @returns a BoundingBoxRenderer
  107865. */
  107866. getBoundingBoxRenderer(): BoundingBoxRenderer;
  107867. }
  107868. interface AbstractMesh {
  107869. /** @hidden (Backing field) */
  107870. _showBoundingBox: boolean;
  107871. /**
  107872. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  107873. */
  107874. showBoundingBox: boolean;
  107875. }
  107876. /**
  107877. * Component responsible of rendering the bounding box of the meshes in a scene.
  107878. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  107879. */
  107880. export class BoundingBoxRenderer implements ISceneComponent {
  107881. /**
  107882. * The component name helpfull to identify the component in the list of scene components.
  107883. */
  107884. readonly name: string;
  107885. /**
  107886. * The scene the component belongs to.
  107887. */
  107888. scene: Scene;
  107889. /**
  107890. * Color of the bounding box lines placed in front of an object
  107891. */
  107892. frontColor: Color3;
  107893. /**
  107894. * Color of the bounding box lines placed behind an object
  107895. */
  107896. backColor: Color3;
  107897. /**
  107898. * Defines if the renderer should show the back lines or not
  107899. */
  107900. showBackLines: boolean;
  107901. /**
  107902. * @hidden
  107903. */
  107904. renderList: SmartArray<BoundingBox>;
  107905. private _colorShader;
  107906. private _vertexBuffers;
  107907. private _indexBuffer;
  107908. /**
  107909. * Instantiates a new bounding box renderer in a scene.
  107910. * @param scene the scene the renderer renders in
  107911. */
  107912. constructor(scene: Scene);
  107913. /**
  107914. * Registers the component in a given scene
  107915. */
  107916. register(): void;
  107917. private _evaluateSubMesh;
  107918. private _activeMesh;
  107919. private _prepareRessources;
  107920. private _createIndexBuffer;
  107921. /**
  107922. * Rebuilds the elements related to this component in case of
  107923. * context lost for instance.
  107924. */
  107925. rebuild(): void;
  107926. /**
  107927. * @hidden
  107928. */
  107929. reset(): void;
  107930. /**
  107931. * Render the bounding boxes of a specific rendering group
  107932. * @param renderingGroupId defines the rendering group to render
  107933. */
  107934. render(renderingGroupId: number): void;
  107935. /**
  107936. * In case of occlusion queries, we can render the occlusion bounding box through this method
  107937. * @param mesh Define the mesh to render the occlusion bounding box for
  107938. */
  107939. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  107940. /**
  107941. * Dispose and release the resources attached to this renderer.
  107942. */
  107943. dispose(): void;
  107944. }
  107945. }
  107946. declare module BABYLON {
  107947. /** @hidden */
  107948. export var depthPixelShader: {
  107949. name: string;
  107950. shader: string;
  107951. };
  107952. }
  107953. declare module BABYLON {
  107954. /**
  107955. * This represents a depth renderer in Babylon.
  107956. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  107957. */
  107958. export class DepthRenderer {
  107959. private _scene;
  107960. private _depthMap;
  107961. private _effect;
  107962. private _cachedDefines;
  107963. private _camera;
  107964. /**
  107965. * Specifiess that the depth renderer will only be used within
  107966. * the camera it is created for.
  107967. * This can help forcing its rendering during the camera processing.
  107968. */
  107969. useOnlyInActiveCamera: boolean;
  107970. /** @hidden */
  107971. static _SceneComponentInitialization: (scene: Scene) => void;
  107972. /**
  107973. * Instantiates a depth renderer
  107974. * @param scene The scene the renderer belongs to
  107975. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  107976. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  107977. */
  107978. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  107979. /**
  107980. * Creates the depth rendering effect and checks if the effect is ready.
  107981. * @param subMesh The submesh to be used to render the depth map of
  107982. * @param useInstances If multiple world instances should be used
  107983. * @returns if the depth renderer is ready to render the depth map
  107984. */
  107985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107986. /**
  107987. * Gets the texture which the depth map will be written to.
  107988. * @returns The depth map texture
  107989. */
  107990. getDepthMap(): RenderTargetTexture;
  107991. /**
  107992. * Disposes of the depth renderer.
  107993. */
  107994. dispose(): void;
  107995. }
  107996. }
  107997. declare module BABYLON {
  107998. interface Scene {
  107999. /** @hidden (Backing field) */
  108000. _depthRenderer: {
  108001. [id: string]: DepthRenderer;
  108002. };
  108003. /**
  108004. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108005. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108006. * @returns the created depth renderer
  108007. */
  108008. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108009. /**
  108010. * Disables a depth renderer for a given camera
  108011. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108012. */
  108013. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108014. }
  108015. /**
  108016. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108017. * in several rendering techniques.
  108018. */
  108019. export class DepthRendererSceneComponent implements ISceneComponent {
  108020. /**
  108021. * The component name helpfull to identify the component in the list of scene components.
  108022. */
  108023. readonly name: string;
  108024. /**
  108025. * The scene the component belongs to.
  108026. */
  108027. scene: Scene;
  108028. /**
  108029. * Creates a new instance of the component for the given scene
  108030. * @param scene Defines the scene to register the component in
  108031. */
  108032. constructor(scene: Scene);
  108033. /**
  108034. * Registers the component in a given scene
  108035. */
  108036. register(): void;
  108037. /**
  108038. * Rebuilds the elements related to this component in case of
  108039. * context lost for instance.
  108040. */
  108041. rebuild(): void;
  108042. /**
  108043. * Disposes the component and the associated ressources
  108044. */
  108045. dispose(): void;
  108046. private _gatherRenderTargets;
  108047. private _gatherActiveCameraRenderTargets;
  108048. }
  108049. }
  108050. declare module BABYLON {
  108051. interface Scene {
  108052. /** @hidden (Backing field) */
  108053. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108054. /**
  108055. * Gets or Sets the current geometry buffer associated to the scene.
  108056. */
  108057. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108058. /**
  108059. * Enables a GeometryBufferRender and associates it with the scene
  108060. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108061. * @returns the GeometryBufferRenderer
  108062. */
  108063. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108064. /**
  108065. * Disables the GeometryBufferRender associated with the scene
  108066. */
  108067. disableGeometryBufferRenderer(): void;
  108068. }
  108069. /**
  108070. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108071. * in several rendering techniques.
  108072. */
  108073. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108074. /**
  108075. * The component name helpful to identify the component in the list of scene components.
  108076. */
  108077. readonly name: string;
  108078. /**
  108079. * The scene the component belongs to.
  108080. */
  108081. scene: Scene;
  108082. /**
  108083. * Creates a new instance of the component for the given scene
  108084. * @param scene Defines the scene to register the component in
  108085. */
  108086. constructor(scene: Scene);
  108087. /**
  108088. * Registers the component in a given scene
  108089. */
  108090. register(): void;
  108091. /**
  108092. * Rebuilds the elements related to this component in case of
  108093. * context lost for instance.
  108094. */
  108095. rebuild(): void;
  108096. /**
  108097. * Disposes the component and the associated ressources
  108098. */
  108099. dispose(): void;
  108100. private _gatherRenderTargets;
  108101. }
  108102. }
  108103. declare module BABYLON {
  108104. /** @hidden */
  108105. export var outlinePixelShader: {
  108106. name: string;
  108107. shader: string;
  108108. };
  108109. }
  108110. declare module BABYLON {
  108111. /** @hidden */
  108112. export var outlineVertexShader: {
  108113. name: string;
  108114. shader: string;
  108115. };
  108116. }
  108117. declare module BABYLON {
  108118. interface Scene {
  108119. /** @hidden */
  108120. _outlineRenderer: OutlineRenderer;
  108121. /**
  108122. * Gets the outline renderer associated with the scene
  108123. * @returns a OutlineRenderer
  108124. */
  108125. getOutlineRenderer(): OutlineRenderer;
  108126. }
  108127. interface AbstractMesh {
  108128. /** @hidden (Backing field) */
  108129. _renderOutline: boolean;
  108130. /**
  108131. * Gets or sets a boolean indicating if the outline must be rendered as well
  108132. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108133. */
  108134. renderOutline: boolean;
  108135. /** @hidden (Backing field) */
  108136. _renderOverlay: boolean;
  108137. /**
  108138. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108139. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108140. */
  108141. renderOverlay: boolean;
  108142. }
  108143. /**
  108144. * This class is responsible to draw bothe outline/overlay of meshes.
  108145. * It should not be used directly but through the available method on mesh.
  108146. */
  108147. export class OutlineRenderer implements ISceneComponent {
  108148. /**
  108149. * The name of the component. Each component must have a unique name.
  108150. */
  108151. name: string;
  108152. /**
  108153. * The scene the component belongs to.
  108154. */
  108155. scene: Scene;
  108156. /**
  108157. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108158. */
  108159. zOffset: number;
  108160. private _engine;
  108161. private _effect;
  108162. private _cachedDefines;
  108163. private _savedDepthWrite;
  108164. /**
  108165. * Instantiates a new outline renderer. (There could be only one per scene).
  108166. * @param scene Defines the scene it belongs to
  108167. */
  108168. constructor(scene: Scene);
  108169. /**
  108170. * Register the component to one instance of a scene.
  108171. */
  108172. register(): void;
  108173. /**
  108174. * Rebuilds the elements related to this component in case of
  108175. * context lost for instance.
  108176. */
  108177. rebuild(): void;
  108178. /**
  108179. * Disposes the component and the associated ressources.
  108180. */
  108181. dispose(): void;
  108182. /**
  108183. * Renders the outline in the canvas.
  108184. * @param subMesh Defines the sumesh to render
  108185. * @param batch Defines the batch of meshes in case of instances
  108186. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108187. */
  108188. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108189. /**
  108190. * Returns whether or not the outline renderer is ready for a given submesh.
  108191. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108192. * @param subMesh Defines the submesh to check readyness for
  108193. * @param useInstances Defines wheter wee are trying to render instances or not
  108194. * @returns true if ready otherwise false
  108195. */
  108196. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108197. private _beforeRenderingMesh;
  108198. private _afterRenderingMesh;
  108199. }
  108200. }
  108201. declare module BABYLON {
  108202. /**
  108203. * Defines the list of states available for a task inside a AssetsManager
  108204. */
  108205. export enum AssetTaskState {
  108206. /**
  108207. * Initialization
  108208. */
  108209. INIT = 0,
  108210. /**
  108211. * Running
  108212. */
  108213. RUNNING = 1,
  108214. /**
  108215. * Done
  108216. */
  108217. DONE = 2,
  108218. /**
  108219. * Error
  108220. */
  108221. ERROR = 3
  108222. }
  108223. /**
  108224. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108225. */
  108226. export abstract class AbstractAssetTask {
  108227. /**
  108228. * Task name
  108229. */ name: string;
  108230. /**
  108231. * Callback called when the task is successful
  108232. */
  108233. onSuccess: (task: any) => void;
  108234. /**
  108235. * Callback called when the task is not successful
  108236. */
  108237. onError: (task: any, message?: string, exception?: any) => void;
  108238. /**
  108239. * Creates a new AssetsManager
  108240. * @param name defines the name of the task
  108241. */
  108242. constructor(
  108243. /**
  108244. * Task name
  108245. */ name: string);
  108246. private _isCompleted;
  108247. private _taskState;
  108248. private _errorObject;
  108249. /**
  108250. * Get if the task is completed
  108251. */
  108252. readonly isCompleted: boolean;
  108253. /**
  108254. * Gets the current state of the task
  108255. */
  108256. readonly taskState: AssetTaskState;
  108257. /**
  108258. * Gets the current error object (if task is in error)
  108259. */
  108260. readonly errorObject: {
  108261. message?: string;
  108262. exception?: any;
  108263. };
  108264. /**
  108265. * Internal only
  108266. * @hidden
  108267. */
  108268. _setErrorObject(message?: string, exception?: any): void;
  108269. /**
  108270. * Execute the current task
  108271. * @param scene defines the scene where you want your assets to be loaded
  108272. * @param onSuccess is a callback called when the task is successfully executed
  108273. * @param onError is a callback called if an error occurs
  108274. */
  108275. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108276. /**
  108277. * Execute the current task
  108278. * @param scene defines the scene where you want your assets to be loaded
  108279. * @param onSuccess is a callback called when the task is successfully executed
  108280. * @param onError is a callback called if an error occurs
  108281. */
  108282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108283. /**
  108284. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  108285. * This can be used with failed tasks that have the reason for failure fixed.
  108286. */
  108287. reset(): void;
  108288. private onErrorCallback;
  108289. private onDoneCallback;
  108290. }
  108291. /**
  108292. * Define the interface used by progress events raised during assets loading
  108293. */
  108294. export interface IAssetsProgressEvent {
  108295. /**
  108296. * Defines the number of remaining tasks to process
  108297. */
  108298. remainingCount: number;
  108299. /**
  108300. * Defines the total number of tasks
  108301. */
  108302. totalCount: number;
  108303. /**
  108304. * Defines the task that was just processed
  108305. */
  108306. task: AbstractAssetTask;
  108307. }
  108308. /**
  108309. * Class used to share progress information about assets loading
  108310. */
  108311. export class AssetsProgressEvent implements IAssetsProgressEvent {
  108312. /**
  108313. * Defines the number of remaining tasks to process
  108314. */
  108315. remainingCount: number;
  108316. /**
  108317. * Defines the total number of tasks
  108318. */
  108319. totalCount: number;
  108320. /**
  108321. * Defines the task that was just processed
  108322. */
  108323. task: AbstractAssetTask;
  108324. /**
  108325. * Creates a AssetsProgressEvent
  108326. * @param remainingCount defines the number of remaining tasks to process
  108327. * @param totalCount defines the total number of tasks
  108328. * @param task defines the task that was just processed
  108329. */
  108330. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  108331. }
  108332. /**
  108333. * Define a task used by AssetsManager to load meshes
  108334. */
  108335. export class MeshAssetTask extends AbstractAssetTask {
  108336. /**
  108337. * Defines the name of the task
  108338. */
  108339. name: string;
  108340. /**
  108341. * Defines the list of mesh's names you want to load
  108342. */
  108343. meshesNames: any;
  108344. /**
  108345. * Defines the root url to use as a base to load your meshes and associated resources
  108346. */
  108347. rootUrl: string;
  108348. /**
  108349. * Defines the filename of the scene to load from
  108350. */
  108351. sceneFilename: string;
  108352. /**
  108353. * Gets the list of loaded meshes
  108354. */
  108355. loadedMeshes: Array<AbstractMesh>;
  108356. /**
  108357. * Gets the list of loaded particle systems
  108358. */
  108359. loadedParticleSystems: Array<IParticleSystem>;
  108360. /**
  108361. * Gets the list of loaded skeletons
  108362. */
  108363. loadedSkeletons: Array<Skeleton>;
  108364. /**
  108365. * Gets the list of loaded animation groups
  108366. */
  108367. loadedAnimationGroups: Array<AnimationGroup>;
  108368. /**
  108369. * Callback called when the task is successful
  108370. */
  108371. onSuccess: (task: MeshAssetTask) => void;
  108372. /**
  108373. * Callback called when the task is successful
  108374. */
  108375. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  108376. /**
  108377. * Creates a new MeshAssetTask
  108378. * @param name defines the name of the task
  108379. * @param meshesNames defines the list of mesh's names you want to load
  108380. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  108381. * @param sceneFilename defines the filename of the scene to load from
  108382. */
  108383. constructor(
  108384. /**
  108385. * Defines the name of the task
  108386. */
  108387. name: string,
  108388. /**
  108389. * Defines the list of mesh's names you want to load
  108390. */
  108391. meshesNames: any,
  108392. /**
  108393. * Defines the root url to use as a base to load your meshes and associated resources
  108394. */
  108395. rootUrl: string,
  108396. /**
  108397. * Defines the filename of the scene to load from
  108398. */
  108399. sceneFilename: string);
  108400. /**
  108401. * Execute the current task
  108402. * @param scene defines the scene where you want your assets to be loaded
  108403. * @param onSuccess is a callback called when the task is successfully executed
  108404. * @param onError is a callback called if an error occurs
  108405. */
  108406. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108407. }
  108408. /**
  108409. * Define a task used by AssetsManager to load text content
  108410. */
  108411. export class TextFileAssetTask extends AbstractAssetTask {
  108412. /**
  108413. * Defines the name of the task
  108414. */
  108415. name: string;
  108416. /**
  108417. * Defines the location of the file to load
  108418. */
  108419. url: string;
  108420. /**
  108421. * Gets the loaded text string
  108422. */
  108423. text: string;
  108424. /**
  108425. * Callback called when the task is successful
  108426. */
  108427. onSuccess: (task: TextFileAssetTask) => void;
  108428. /**
  108429. * Callback called when the task is successful
  108430. */
  108431. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  108432. /**
  108433. * Creates a new TextFileAssetTask object
  108434. * @param name defines the name of the task
  108435. * @param url defines the location of the file to load
  108436. */
  108437. constructor(
  108438. /**
  108439. * Defines the name of the task
  108440. */
  108441. name: string,
  108442. /**
  108443. * Defines the location of the file to load
  108444. */
  108445. url: string);
  108446. /**
  108447. * Execute the current task
  108448. * @param scene defines the scene where you want your assets to be loaded
  108449. * @param onSuccess is a callback called when the task is successfully executed
  108450. * @param onError is a callback called if an error occurs
  108451. */
  108452. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108453. }
  108454. /**
  108455. * Define a task used by AssetsManager to load binary data
  108456. */
  108457. export class BinaryFileAssetTask extends AbstractAssetTask {
  108458. /**
  108459. * Defines the name of the task
  108460. */
  108461. name: string;
  108462. /**
  108463. * Defines the location of the file to load
  108464. */
  108465. url: string;
  108466. /**
  108467. * Gets the lodaded data (as an array buffer)
  108468. */
  108469. data: ArrayBuffer;
  108470. /**
  108471. * Callback called when the task is successful
  108472. */
  108473. onSuccess: (task: BinaryFileAssetTask) => void;
  108474. /**
  108475. * Callback called when the task is successful
  108476. */
  108477. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  108478. /**
  108479. * Creates a new BinaryFileAssetTask object
  108480. * @param name defines the name of the new task
  108481. * @param url defines the location of the file to load
  108482. */
  108483. constructor(
  108484. /**
  108485. * Defines the name of the task
  108486. */
  108487. name: string,
  108488. /**
  108489. * Defines the location of the file to load
  108490. */
  108491. url: string);
  108492. /**
  108493. * Execute the current task
  108494. * @param scene defines the scene where you want your assets to be loaded
  108495. * @param onSuccess is a callback called when the task is successfully executed
  108496. * @param onError is a callback called if an error occurs
  108497. */
  108498. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108499. }
  108500. /**
  108501. * Define a task used by AssetsManager to load images
  108502. */
  108503. export class ImageAssetTask extends AbstractAssetTask {
  108504. /**
  108505. * Defines the name of the task
  108506. */
  108507. name: string;
  108508. /**
  108509. * Defines the location of the image to load
  108510. */
  108511. url: string;
  108512. /**
  108513. * Gets the loaded images
  108514. */
  108515. image: HTMLImageElement;
  108516. /**
  108517. * Callback called when the task is successful
  108518. */
  108519. onSuccess: (task: ImageAssetTask) => void;
  108520. /**
  108521. * Callback called when the task is successful
  108522. */
  108523. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  108524. /**
  108525. * Creates a new ImageAssetTask
  108526. * @param name defines the name of the task
  108527. * @param url defines the location of the image to load
  108528. */
  108529. constructor(
  108530. /**
  108531. * Defines the name of the task
  108532. */
  108533. name: string,
  108534. /**
  108535. * Defines the location of the image to load
  108536. */
  108537. url: string);
  108538. /**
  108539. * Execute the current task
  108540. * @param scene defines the scene where you want your assets to be loaded
  108541. * @param onSuccess is a callback called when the task is successfully executed
  108542. * @param onError is a callback called if an error occurs
  108543. */
  108544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108545. }
  108546. /**
  108547. * Defines the interface used by texture loading tasks
  108548. */
  108549. export interface ITextureAssetTask<TEX extends BaseTexture> {
  108550. /**
  108551. * Gets the loaded texture
  108552. */
  108553. texture: TEX;
  108554. }
  108555. /**
  108556. * Define a task used by AssetsManager to load 2D textures
  108557. */
  108558. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  108559. /**
  108560. * Defines the name of the task
  108561. */
  108562. name: string;
  108563. /**
  108564. * Defines the location of the file to load
  108565. */
  108566. url: string;
  108567. /**
  108568. * Defines if mipmap should not be generated (default is false)
  108569. */
  108570. noMipmap?: boolean | undefined;
  108571. /**
  108572. * Defines if texture must be inverted on Y axis (default is false)
  108573. */
  108574. invertY?: boolean | undefined;
  108575. /**
  108576. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108577. */
  108578. samplingMode: number;
  108579. /**
  108580. * Gets the loaded texture
  108581. */
  108582. texture: Texture;
  108583. /**
  108584. * Callback called when the task is successful
  108585. */
  108586. onSuccess: (task: TextureAssetTask) => void;
  108587. /**
  108588. * Callback called when the task is successful
  108589. */
  108590. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  108591. /**
  108592. * Creates a new TextureAssetTask object
  108593. * @param name defines the name of the task
  108594. * @param url defines the location of the file to load
  108595. * @param noMipmap defines if mipmap should not be generated (default is false)
  108596. * @param invertY defines if texture must be inverted on Y axis (default is false)
  108597. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108598. */
  108599. constructor(
  108600. /**
  108601. * Defines the name of the task
  108602. */
  108603. name: string,
  108604. /**
  108605. * Defines the location of the file to load
  108606. */
  108607. url: string,
  108608. /**
  108609. * Defines if mipmap should not be generated (default is false)
  108610. */
  108611. noMipmap?: boolean | undefined,
  108612. /**
  108613. * Defines if texture must be inverted on Y axis (default is false)
  108614. */
  108615. invertY?: boolean | undefined,
  108616. /**
  108617. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108618. */
  108619. samplingMode?: number);
  108620. /**
  108621. * Execute the current task
  108622. * @param scene defines the scene where you want your assets to be loaded
  108623. * @param onSuccess is a callback called when the task is successfully executed
  108624. * @param onError is a callback called if an error occurs
  108625. */
  108626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108627. }
  108628. /**
  108629. * Define a task used by AssetsManager to load cube textures
  108630. */
  108631. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  108632. /**
  108633. * Defines the name of the task
  108634. */
  108635. name: string;
  108636. /**
  108637. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108638. */
  108639. url: string;
  108640. /**
  108641. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108642. */
  108643. extensions?: string[] | undefined;
  108644. /**
  108645. * Defines if mipmaps should not be generated (default is false)
  108646. */
  108647. noMipmap?: boolean | undefined;
  108648. /**
  108649. * Defines the explicit list of files (undefined by default)
  108650. */
  108651. files?: string[] | undefined;
  108652. /**
  108653. * Gets the loaded texture
  108654. */
  108655. texture: CubeTexture;
  108656. /**
  108657. * Callback called when the task is successful
  108658. */
  108659. onSuccess: (task: CubeTextureAssetTask) => void;
  108660. /**
  108661. * Callback called when the task is successful
  108662. */
  108663. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  108664. /**
  108665. * Creates a new CubeTextureAssetTask
  108666. * @param name defines the name of the task
  108667. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108668. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108669. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108670. * @param files defines the explicit list of files (undefined by default)
  108671. */
  108672. constructor(
  108673. /**
  108674. * Defines the name of the task
  108675. */
  108676. name: string,
  108677. /**
  108678. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108679. */
  108680. url: string,
  108681. /**
  108682. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108683. */
  108684. extensions?: string[] | undefined,
  108685. /**
  108686. * Defines if mipmaps should not be generated (default is false)
  108687. */
  108688. noMipmap?: boolean | undefined,
  108689. /**
  108690. * Defines the explicit list of files (undefined by default)
  108691. */
  108692. files?: string[] | undefined);
  108693. /**
  108694. * Execute the current task
  108695. * @param scene defines the scene where you want your assets to be loaded
  108696. * @param onSuccess is a callback called when the task is successfully executed
  108697. * @param onError is a callback called if an error occurs
  108698. */
  108699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108700. }
  108701. /**
  108702. * Define a task used by AssetsManager to load HDR cube textures
  108703. */
  108704. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  108705. /**
  108706. * Defines the name of the task
  108707. */
  108708. name: string;
  108709. /**
  108710. * Defines the location of the file to load
  108711. */
  108712. url: string;
  108713. /**
  108714. * Defines the desired size (the more it increases the longer the generation will be)
  108715. */
  108716. size: number;
  108717. /**
  108718. * Defines if mipmaps should not be generated (default is false)
  108719. */
  108720. noMipmap: boolean;
  108721. /**
  108722. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108723. */
  108724. generateHarmonics: boolean;
  108725. /**
  108726. * 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)
  108727. */
  108728. gammaSpace: boolean;
  108729. /**
  108730. * Internal Use Only
  108731. */
  108732. reserved: boolean;
  108733. /**
  108734. * Gets the loaded texture
  108735. */
  108736. texture: HDRCubeTexture;
  108737. /**
  108738. * Callback called when the task is successful
  108739. */
  108740. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  108741. /**
  108742. * Callback called when the task is successful
  108743. */
  108744. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  108745. /**
  108746. * Creates a new HDRCubeTextureAssetTask object
  108747. * @param name defines the name of the task
  108748. * @param url defines the location of the file to load
  108749. * @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.
  108750. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108751. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108752. * @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)
  108753. * @param reserved Internal use only
  108754. */
  108755. constructor(
  108756. /**
  108757. * Defines the name of the task
  108758. */
  108759. name: string,
  108760. /**
  108761. * Defines the location of the file to load
  108762. */
  108763. url: string,
  108764. /**
  108765. * Defines the desired size (the more it increases the longer the generation will be)
  108766. */
  108767. size: number,
  108768. /**
  108769. * Defines if mipmaps should not be generated (default is false)
  108770. */
  108771. noMipmap?: boolean,
  108772. /**
  108773. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108774. */
  108775. generateHarmonics?: boolean,
  108776. /**
  108777. * 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)
  108778. */
  108779. gammaSpace?: boolean,
  108780. /**
  108781. * Internal Use Only
  108782. */
  108783. reserved?: boolean);
  108784. /**
  108785. * Execute the current task
  108786. * @param scene defines the scene where you want your assets to be loaded
  108787. * @param onSuccess is a callback called when the task is successfully executed
  108788. * @param onError is a callback called if an error occurs
  108789. */
  108790. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108791. }
  108792. /**
  108793. * This class can be used to easily import assets into a scene
  108794. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  108795. */
  108796. export class AssetsManager {
  108797. private _scene;
  108798. private _isLoading;
  108799. protected _tasks: AbstractAssetTask[];
  108800. protected _waitingTasksCount: number;
  108801. protected _totalTasksCount: number;
  108802. /**
  108803. * Callback called when all tasks are processed
  108804. */
  108805. onFinish: (tasks: AbstractAssetTask[]) => void;
  108806. /**
  108807. * Callback called when a task is successful
  108808. */
  108809. onTaskSuccess: (task: AbstractAssetTask) => void;
  108810. /**
  108811. * Callback called when a task had an error
  108812. */
  108813. onTaskError: (task: AbstractAssetTask) => void;
  108814. /**
  108815. * Callback called when a task is done (whatever the result is)
  108816. */
  108817. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  108818. /**
  108819. * Observable called when all tasks are processed
  108820. */
  108821. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  108822. /**
  108823. * Observable called when a task had an error
  108824. */
  108825. onTaskErrorObservable: Observable<AbstractAssetTask>;
  108826. /**
  108827. * Observable called when a task is successful
  108828. */
  108829. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  108830. /**
  108831. * Observable called when a task is done (whatever the result is)
  108832. */
  108833. onProgressObservable: Observable<IAssetsProgressEvent>;
  108834. /**
  108835. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  108836. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108837. */
  108838. useDefaultLoadingScreen: boolean;
  108839. /**
  108840. * Creates a new AssetsManager
  108841. * @param scene defines the scene to work on
  108842. */
  108843. constructor(scene: Scene);
  108844. /**
  108845. * Add a MeshAssetTask to the list of active tasks
  108846. * @param taskName defines the name of the new task
  108847. * @param meshesNames defines the name of meshes to load
  108848. * @param rootUrl defines the root url to use to locate files
  108849. * @param sceneFilename defines the filename of the scene file
  108850. * @returns a new MeshAssetTask object
  108851. */
  108852. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  108853. /**
  108854. * Add a TextFileAssetTask to the list of active tasks
  108855. * @param taskName defines the name of the new task
  108856. * @param url defines the url of the file to load
  108857. * @returns a new TextFileAssetTask object
  108858. */
  108859. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  108860. /**
  108861. * Add a BinaryFileAssetTask to the list of active tasks
  108862. * @param taskName defines the name of the new task
  108863. * @param url defines the url of the file to load
  108864. * @returns a new BinaryFileAssetTask object
  108865. */
  108866. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  108867. /**
  108868. * Add a ImageAssetTask to the list of active tasks
  108869. * @param taskName defines the name of the new task
  108870. * @param url defines the url of the file to load
  108871. * @returns a new ImageAssetTask object
  108872. */
  108873. addImageTask(taskName: string, url: string): ImageAssetTask;
  108874. /**
  108875. * Add a TextureAssetTask to the list of active tasks
  108876. * @param taskName defines the name of the new task
  108877. * @param url defines the url of the file to load
  108878. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108879. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  108880. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108881. * @returns a new TextureAssetTask object
  108882. */
  108883. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  108884. /**
  108885. * Add a CubeTextureAssetTask to the list of active tasks
  108886. * @param taskName defines the name of the new task
  108887. * @param url defines the url of the file to load
  108888. * @param extensions defines the extension to use to load the cube map (can be null)
  108889. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108890. * @param files defines the list of files to load (can be null)
  108891. * @returns a new CubeTextureAssetTask object
  108892. */
  108893. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  108894. /**
  108895. *
  108896. * Add a HDRCubeTextureAssetTask to the list of active tasks
  108897. * @param taskName defines the name of the new task
  108898. * @param url defines the url of the file to load
  108899. * @param size defines the size you want for the cubemap (can be null)
  108900. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108901. * @param generateHarmonics defines if you want to automatically generate (true by default)
  108902. * @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)
  108903. * @param reserved Internal use only
  108904. * @returns a new HDRCubeTextureAssetTask object
  108905. */
  108906. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  108907. /**
  108908. * Remove a task from the assets manager.
  108909. * @param task the task to remove
  108910. */
  108911. removeTask(task: AbstractAssetTask): void;
  108912. private _decreaseWaitingTasksCount;
  108913. private _runTask;
  108914. /**
  108915. * Reset the AssetsManager and remove all tasks
  108916. * @return the current instance of the AssetsManager
  108917. */
  108918. reset(): AssetsManager;
  108919. /**
  108920. * Start the loading process
  108921. * @return the current instance of the AssetsManager
  108922. */
  108923. load(): AssetsManager;
  108924. }
  108925. }
  108926. declare module BABYLON {
  108927. /**
  108928. * Wrapper class for promise with external resolve and reject.
  108929. */
  108930. export class Deferred<T> {
  108931. /**
  108932. * The promise associated with this deferred object.
  108933. */
  108934. readonly promise: Promise<T>;
  108935. private _resolve;
  108936. private _reject;
  108937. /**
  108938. * The resolve method of the promise associated with this deferred object.
  108939. */
  108940. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  108941. /**
  108942. * The reject method of the promise associated with this deferred object.
  108943. */
  108944. readonly reject: (reason?: any) => void;
  108945. /**
  108946. * Constructor for this deferred object.
  108947. */
  108948. constructor();
  108949. }
  108950. }
  108951. declare module BABYLON {
  108952. /**
  108953. * Class used to help managing file picking and drag'n'drop
  108954. */
  108955. export class FilesInput {
  108956. /**
  108957. * List of files ready to be loaded
  108958. */
  108959. static readonly FilesToLoad: {
  108960. [key: string]: File;
  108961. };
  108962. /**
  108963. * Callback called when a file is processed
  108964. */
  108965. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  108966. private _engine;
  108967. private _currentScene;
  108968. private _sceneLoadedCallback;
  108969. private _progressCallback;
  108970. private _additionalRenderLoopLogicCallback;
  108971. private _textureLoadingCallback;
  108972. private _startingProcessingFilesCallback;
  108973. private _onReloadCallback;
  108974. private _errorCallback;
  108975. private _elementToMonitor;
  108976. private _sceneFileToLoad;
  108977. private _filesToLoad;
  108978. /**
  108979. * Creates a new FilesInput
  108980. * @param engine defines the rendering engine
  108981. * @param scene defines the hosting scene
  108982. * @param sceneLoadedCallback callback called when scene is loaded
  108983. * @param progressCallback callback called to track progress
  108984. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  108985. * @param textureLoadingCallback callback called when a texture is loading
  108986. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  108987. * @param onReloadCallback callback called when a reload is requested
  108988. * @param errorCallback callback call if an error occurs
  108989. */
  108990. 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);
  108991. private _dragEnterHandler;
  108992. private _dragOverHandler;
  108993. private _dropHandler;
  108994. /**
  108995. * Calls this function to listen to drag'n'drop events on a specific DOM element
  108996. * @param elementToMonitor defines the DOM element to track
  108997. */
  108998. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  108999. /**
  109000. * Release all associated resources
  109001. */
  109002. dispose(): void;
  109003. private renderFunction;
  109004. private drag;
  109005. private drop;
  109006. private _traverseFolder;
  109007. private _processFiles;
  109008. /**
  109009. * Load files from a drop event
  109010. * @param event defines the drop event to use as source
  109011. */
  109012. loadFiles(event: any): void;
  109013. private _processReload;
  109014. /**
  109015. * Reload the current scene from the loaded files
  109016. */
  109017. reload(): void;
  109018. }
  109019. }
  109020. declare module BABYLON {
  109021. /**
  109022. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109024. */
  109025. export class SceneOptimization {
  109026. /**
  109027. * Defines the priority of this optimization (0 by default which means first in the list)
  109028. */
  109029. priority: number;
  109030. /**
  109031. * Gets a string describing the action executed by the current optimization
  109032. * @returns description string
  109033. */
  109034. getDescription(): string;
  109035. /**
  109036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109037. * @param scene defines the current scene where to apply this optimization
  109038. * @param optimizer defines the current optimizer
  109039. * @returns true if everything that can be done was applied
  109040. */
  109041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109042. /**
  109043. * Creates the SceneOptimization object
  109044. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109045. * @param desc defines the description associated with the optimization
  109046. */
  109047. constructor(
  109048. /**
  109049. * Defines the priority of this optimization (0 by default which means first in the list)
  109050. */
  109051. priority?: number);
  109052. }
  109053. /**
  109054. * Defines an optimization used to reduce the size of render target textures
  109055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109056. */
  109057. export class TextureOptimization extends SceneOptimization {
  109058. /**
  109059. * Defines the priority of this optimization (0 by default which means first in the list)
  109060. */
  109061. priority: number;
  109062. /**
  109063. * 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
  109064. */
  109065. maximumSize: number;
  109066. /**
  109067. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109068. */
  109069. step: number;
  109070. /**
  109071. * Gets a string describing the action executed by the current optimization
  109072. * @returns description string
  109073. */
  109074. getDescription(): string;
  109075. /**
  109076. * Creates the TextureOptimization object
  109077. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109078. * @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
  109079. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109080. */
  109081. constructor(
  109082. /**
  109083. * Defines the priority of this optimization (0 by default which means first in the list)
  109084. */
  109085. priority?: number,
  109086. /**
  109087. * 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
  109088. */
  109089. maximumSize?: number,
  109090. /**
  109091. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109092. */
  109093. step?: number);
  109094. /**
  109095. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109096. * @param scene defines the current scene where to apply this optimization
  109097. * @param optimizer defines the current optimizer
  109098. * @returns true if everything that can be done was applied
  109099. */
  109100. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109101. }
  109102. /**
  109103. * Defines an optimization used to increase or decrease the rendering resolution
  109104. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109105. */
  109106. export class HardwareScalingOptimization extends SceneOptimization {
  109107. /**
  109108. * Defines the priority of this optimization (0 by default which means first in the list)
  109109. */
  109110. priority: number;
  109111. /**
  109112. * Defines the maximum scale to use (2 by default)
  109113. */
  109114. maximumScale: number;
  109115. /**
  109116. * Defines the step to use between two passes (0.5 by default)
  109117. */
  109118. step: number;
  109119. private _currentScale;
  109120. private _directionOffset;
  109121. /**
  109122. * Gets a string describing the action executed by the current optimization
  109123. * @return description string
  109124. */
  109125. getDescription(): string;
  109126. /**
  109127. * Creates the HardwareScalingOptimization object
  109128. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109129. * @param maximumScale defines the maximum scale to use (2 by default)
  109130. * @param step defines the step to use between two passes (0.5 by default)
  109131. */
  109132. constructor(
  109133. /**
  109134. * Defines the priority of this optimization (0 by default which means first in the list)
  109135. */
  109136. priority?: number,
  109137. /**
  109138. * Defines the maximum scale to use (2 by default)
  109139. */
  109140. maximumScale?: number,
  109141. /**
  109142. * Defines the step to use between two passes (0.5 by default)
  109143. */
  109144. step?: number);
  109145. /**
  109146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109147. * @param scene defines the current scene where to apply this optimization
  109148. * @param optimizer defines the current optimizer
  109149. * @returns true if everything that can be done was applied
  109150. */
  109151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109152. }
  109153. /**
  109154. * Defines an optimization used to remove shadows
  109155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109156. */
  109157. export class ShadowsOptimization extends SceneOptimization {
  109158. /**
  109159. * Gets a string describing the action executed by the current optimization
  109160. * @return description string
  109161. */
  109162. getDescription(): string;
  109163. /**
  109164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109165. * @param scene defines the current scene where to apply this optimization
  109166. * @param optimizer defines the current optimizer
  109167. * @returns true if everything that can be done was applied
  109168. */
  109169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109170. }
  109171. /**
  109172. * Defines an optimization used to turn post-processes off
  109173. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109174. */
  109175. export class PostProcessesOptimization extends SceneOptimization {
  109176. /**
  109177. * Gets a string describing the action executed by the current optimization
  109178. * @return description string
  109179. */
  109180. getDescription(): string;
  109181. /**
  109182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109183. * @param scene defines the current scene where to apply this optimization
  109184. * @param optimizer defines the current optimizer
  109185. * @returns true if everything that can be done was applied
  109186. */
  109187. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109188. }
  109189. /**
  109190. * Defines an optimization used to turn lens flares off
  109191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109192. */
  109193. export class LensFlaresOptimization extends SceneOptimization {
  109194. /**
  109195. * Gets a string describing the action executed by the current optimization
  109196. * @return description string
  109197. */
  109198. getDescription(): string;
  109199. /**
  109200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109201. * @param scene defines the current scene where to apply this optimization
  109202. * @param optimizer defines the current optimizer
  109203. * @returns true if everything that can be done was applied
  109204. */
  109205. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109206. }
  109207. /**
  109208. * Defines an optimization based on user defined callback.
  109209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109210. */
  109211. export class CustomOptimization extends SceneOptimization {
  109212. /**
  109213. * Callback called to apply the custom optimization.
  109214. */
  109215. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109216. /**
  109217. * Callback called to get custom description
  109218. */
  109219. onGetDescription: () => string;
  109220. /**
  109221. * Gets a string describing the action executed by the current optimization
  109222. * @returns description string
  109223. */
  109224. getDescription(): string;
  109225. /**
  109226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109227. * @param scene defines the current scene where to apply this optimization
  109228. * @param optimizer defines the current optimizer
  109229. * @returns true if everything that can be done was applied
  109230. */
  109231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109232. }
  109233. /**
  109234. * Defines an optimization used to turn particles off
  109235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109236. */
  109237. export class ParticlesOptimization extends SceneOptimization {
  109238. /**
  109239. * Gets a string describing the action executed by the current optimization
  109240. * @return description string
  109241. */
  109242. getDescription(): string;
  109243. /**
  109244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109245. * @param scene defines the current scene where to apply this optimization
  109246. * @param optimizer defines the current optimizer
  109247. * @returns true if everything that can be done was applied
  109248. */
  109249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109250. }
  109251. /**
  109252. * Defines an optimization used to turn render targets off
  109253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109254. */
  109255. export class RenderTargetsOptimization extends SceneOptimization {
  109256. /**
  109257. * Gets a string describing the action executed by the current optimization
  109258. * @return description string
  109259. */
  109260. getDescription(): string;
  109261. /**
  109262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109263. * @param scene defines the current scene where to apply this optimization
  109264. * @param optimizer defines the current optimizer
  109265. * @returns true if everything that can be done was applied
  109266. */
  109267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109268. }
  109269. /**
  109270. * Defines an optimization used to merge meshes with compatible materials
  109271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109272. */
  109273. export class MergeMeshesOptimization extends SceneOptimization {
  109274. private static _UpdateSelectionTree;
  109275. /**
  109276. * Gets or sets a boolean which defines if optimization octree has to be updated
  109277. */
  109278. /**
  109279. * Gets or sets a boolean which defines if optimization octree has to be updated
  109280. */
  109281. static UpdateSelectionTree: boolean;
  109282. /**
  109283. * Gets a string describing the action executed by the current optimization
  109284. * @return description string
  109285. */
  109286. getDescription(): string;
  109287. private _canBeMerged;
  109288. /**
  109289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109290. * @param scene defines the current scene where to apply this optimization
  109291. * @param optimizer defines the current optimizer
  109292. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  109293. * @returns true if everything that can be done was applied
  109294. */
  109295. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  109296. }
  109297. /**
  109298. * Defines a list of options used by SceneOptimizer
  109299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109300. */
  109301. export class SceneOptimizerOptions {
  109302. /**
  109303. * Defines the target frame rate to reach (60 by default)
  109304. */
  109305. targetFrameRate: number;
  109306. /**
  109307. * Defines the interval between two checkes (2000ms by default)
  109308. */
  109309. trackerDuration: number;
  109310. /**
  109311. * Gets the list of optimizations to apply
  109312. */
  109313. optimizations: SceneOptimization[];
  109314. /**
  109315. * Creates a new list of options used by SceneOptimizer
  109316. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  109317. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  109318. */
  109319. constructor(
  109320. /**
  109321. * Defines the target frame rate to reach (60 by default)
  109322. */
  109323. targetFrameRate?: number,
  109324. /**
  109325. * Defines the interval between two checkes (2000ms by default)
  109326. */
  109327. trackerDuration?: number);
  109328. /**
  109329. * Add a new optimization
  109330. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  109331. * @returns the current SceneOptimizerOptions
  109332. */
  109333. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  109334. /**
  109335. * Add a new custom optimization
  109336. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  109337. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  109338. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109339. * @returns the current SceneOptimizerOptions
  109340. */
  109341. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  109342. /**
  109343. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  109344. * @param targetFrameRate defines the target frame rate (60 by default)
  109345. * @returns a SceneOptimizerOptions object
  109346. */
  109347. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109348. /**
  109349. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  109350. * @param targetFrameRate defines the target frame rate (60 by default)
  109351. * @returns a SceneOptimizerOptions object
  109352. */
  109353. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109354. /**
  109355. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  109356. * @param targetFrameRate defines the target frame rate (60 by default)
  109357. * @returns a SceneOptimizerOptions object
  109358. */
  109359. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109360. }
  109361. /**
  109362. * Class used to run optimizations in order to reach a target frame rate
  109363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109364. */
  109365. export class SceneOptimizer implements IDisposable {
  109366. private _isRunning;
  109367. private _options;
  109368. private _scene;
  109369. private _currentPriorityLevel;
  109370. private _targetFrameRate;
  109371. private _trackerDuration;
  109372. private _currentFrameRate;
  109373. private _sceneDisposeObserver;
  109374. private _improvementMode;
  109375. /**
  109376. * Defines an observable called when the optimizer reaches the target frame rate
  109377. */
  109378. onSuccessObservable: Observable<SceneOptimizer>;
  109379. /**
  109380. * Defines an observable called when the optimizer enables an optimization
  109381. */
  109382. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  109383. /**
  109384. * Defines an observable called when the optimizer is not able to reach the target frame rate
  109385. */
  109386. onFailureObservable: Observable<SceneOptimizer>;
  109387. /**
  109388. * Gets a boolean indicating if the optimizer is in improvement mode
  109389. */
  109390. readonly isInImprovementMode: boolean;
  109391. /**
  109392. * Gets the current priority level (0 at start)
  109393. */
  109394. readonly currentPriorityLevel: number;
  109395. /**
  109396. * Gets the current frame rate checked by the SceneOptimizer
  109397. */
  109398. readonly currentFrameRate: number;
  109399. /**
  109400. * Gets or sets the current target frame rate (60 by default)
  109401. */
  109402. /**
  109403. * Gets or sets the current target frame rate (60 by default)
  109404. */
  109405. targetFrameRate: number;
  109406. /**
  109407. * Gets or sets the current interval between two checks (every 2000ms by default)
  109408. */
  109409. /**
  109410. * Gets or sets the current interval between two checks (every 2000ms by default)
  109411. */
  109412. trackerDuration: number;
  109413. /**
  109414. * Gets the list of active optimizations
  109415. */
  109416. readonly optimizations: SceneOptimization[];
  109417. /**
  109418. * Creates a new SceneOptimizer
  109419. * @param scene defines the scene to work on
  109420. * @param options defines the options to use with the SceneOptimizer
  109421. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  109422. * @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)
  109423. */
  109424. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  109425. /**
  109426. * Stops the current optimizer
  109427. */
  109428. stop(): void;
  109429. /**
  109430. * Reset the optimizer to initial step (current priority level = 0)
  109431. */
  109432. reset(): void;
  109433. /**
  109434. * Start the optimizer. By default it will try to reach a specific framerate
  109435. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  109436. */
  109437. start(): void;
  109438. private _checkCurrentState;
  109439. /**
  109440. * Release all resources
  109441. */
  109442. dispose(): void;
  109443. /**
  109444. * Helper function to create a SceneOptimizer with one single line of code
  109445. * @param scene defines the scene to work on
  109446. * @param options defines the options to use with the SceneOptimizer
  109447. * @param onSuccess defines a callback to call on success
  109448. * @param onFailure defines a callback to call on failure
  109449. * @returns the new SceneOptimizer object
  109450. */
  109451. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  109452. }
  109453. }
  109454. declare module BABYLON {
  109455. /**
  109456. * Class used to serialize a scene into a string
  109457. */
  109458. export class SceneSerializer {
  109459. /**
  109460. * Clear cache used by a previous serialization
  109461. */
  109462. static ClearCache(): void;
  109463. /**
  109464. * Serialize a scene into a JSON compatible object
  109465. * @param scene defines the scene to serialize
  109466. * @returns a JSON compatible object
  109467. */
  109468. static Serialize(scene: Scene): any;
  109469. /**
  109470. * Serialize a mesh into a JSON compatible object
  109471. * @param toSerialize defines the mesh to serialize
  109472. * @param withParents defines if parents must be serialized as well
  109473. * @param withChildren defines if children must be serialized as well
  109474. * @returns a JSON compatible object
  109475. */
  109476. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  109477. }
  109478. }
  109479. declare module BABYLON {
  109480. /**
  109481. * This represents the different options avilable for the video capture.
  109482. */
  109483. export interface VideoRecorderOptions {
  109484. /** Defines the mime type of the video */
  109485. mimeType: string;
  109486. /** Defines the video the video should be recorded at */
  109487. fps: number;
  109488. /** Defines the chunk size for the recording data */
  109489. recordChunckSize: number;
  109490. }
  109491. /**
  109492. * This can helps recording videos from BabylonJS.
  109493. * This is based on the available WebRTC functionalities of the browser.
  109494. *
  109495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  109496. */
  109497. export class VideoRecorder {
  109498. private static readonly _defaultOptions;
  109499. /**
  109500. * Returns wehther or not the VideoRecorder is available in your browser.
  109501. * @param engine Defines the Babylon Engine to check the support for
  109502. * @returns true if supported otherwise false
  109503. */
  109504. static IsSupported(engine: Engine): boolean;
  109505. private readonly _options;
  109506. private _canvas;
  109507. private _mediaRecorder;
  109508. private _recordedChunks;
  109509. private _fileName;
  109510. private _resolve;
  109511. private _reject;
  109512. /**
  109513. * True wether a recording is already in progress.
  109514. */
  109515. readonly isRecording: boolean;
  109516. /**
  109517. * Create a new VideoCapture object which can help converting what you see in Babylon to
  109518. * a video file.
  109519. * @param engine Defines the BabylonJS Engine you wish to record
  109520. * @param options Defines options that can be used to customized the capture
  109521. */
  109522. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  109523. /**
  109524. * Stops the current recording before the default capture timeout passed in the startRecording
  109525. * functions.
  109526. */
  109527. stopRecording(): void;
  109528. /**
  109529. * Starts recording the canvas for a max duration specified in parameters.
  109530. * @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.
  109531. * @param maxDuration Defines the maximum recording time in seconds.
  109532. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  109533. * @return a promise callback at the end of the recording with the video data in Blob.
  109534. */
  109535. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  109536. /**
  109537. * Releases internal resources used during the recording.
  109538. */
  109539. dispose(): void;
  109540. private _handleDataAvailable;
  109541. private _handleError;
  109542. private _handleStop;
  109543. }
  109544. }
  109545. declare module BABYLON {
  109546. /**
  109547. * Helper class to push actions to a pool of workers.
  109548. */
  109549. export class WorkerPool implements IDisposable {
  109550. private _workerInfos;
  109551. private _pendingActions;
  109552. /**
  109553. * Constructor
  109554. * @param workers Array of workers to use for actions
  109555. */
  109556. constructor(workers: Array<Worker>);
  109557. /**
  109558. * Terminates all workers and clears any pending actions.
  109559. */
  109560. dispose(): void;
  109561. /**
  109562. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109563. * pended until a worker has completed its action.
  109564. * @param action The action to perform. Call onComplete when the action is complete.
  109565. */
  109566. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109567. private _execute;
  109568. }
  109569. }
  109570. declare module BABYLON {
  109571. /**
  109572. * Class containing a set of static utilities functions for screenshots
  109573. */
  109574. export class ScreenshotTools {
  109575. /**
  109576. * Captures a screenshot of the current rendering
  109577. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109578. * @param engine defines the rendering engine
  109579. * @param camera defines the source camera
  109580. * @param size This parameter can be set to a single number or to an object with the
  109581. * following (optional) properties: precision, width, height. If a single number is passed,
  109582. * it will be used for both width and height. If an object is passed, the screenshot size
  109583. * will be derived from the parameters. The precision property is a multiplier allowing
  109584. * rendering at a higher or lower resolution
  109585. * @param successCallback defines the callback receives a single parameter which contains the
  109586. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109587. * src parameter of an <img> to display it
  109588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109589. * Check your browser for supported MIME types
  109590. */
  109591. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  109592. /**
  109593. * Generates an image screenshot from the specified camera.
  109594. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109595. * @param engine The engine to use for rendering
  109596. * @param camera The camera to use for rendering
  109597. * @param size This parameter can be set to a single number or to an object with the
  109598. * following (optional) properties: precision, width, height. If a single number is passed,
  109599. * it will be used for both width and height. If an object is passed, the screenshot size
  109600. * will be derived from the parameters. The precision property is a multiplier allowing
  109601. * rendering at a higher or lower resolution
  109602. * @param successCallback The callback receives a single parameter which contains the
  109603. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109604. * src parameter of an <img> to display it
  109605. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109606. * Check your browser for supported MIME types
  109607. * @param samples Texture samples (default: 1)
  109608. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109609. * @param fileName A name for for the downloaded file.
  109610. */
  109611. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109612. }
  109613. }
  109614. declare module BABYLON {
  109615. /** @hidden */
  109616. export var blurPixelShader: {
  109617. name: string;
  109618. shader: string;
  109619. };
  109620. }
  109621. declare module BABYLON {
  109622. /** @hidden */
  109623. export var bones300Declaration: {
  109624. name: string;
  109625. shader: string;
  109626. };
  109627. }
  109628. declare module BABYLON {
  109629. /** @hidden */
  109630. export var instances300Declaration: {
  109631. name: string;
  109632. shader: string;
  109633. };
  109634. }
  109635. declare module BABYLON {
  109636. /** @hidden */
  109637. export var pointCloudVertexDeclaration: {
  109638. name: string;
  109639. shader: string;
  109640. };
  109641. }
  109642. // Mixins
  109643. interface Window {
  109644. mozIndexedDB: IDBFactory;
  109645. webkitIndexedDB: IDBFactory;
  109646. msIndexedDB: IDBFactory;
  109647. webkitURL: typeof URL;
  109648. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  109649. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  109650. WebGLRenderingContext: WebGLRenderingContext;
  109651. MSGesture: MSGesture;
  109652. CANNON: any;
  109653. AudioContext: AudioContext;
  109654. webkitAudioContext: AudioContext;
  109655. PointerEvent: any;
  109656. Math: Math;
  109657. Uint8Array: Uint8ArrayConstructor;
  109658. Float32Array: Float32ArrayConstructor;
  109659. mozURL: typeof URL;
  109660. msURL: typeof URL;
  109661. VRFrameData: any; // WebVR, from specs 1.1
  109662. DracoDecoderModule: any;
  109663. setImmediate(handler: (...args: any[]) => void): number;
  109664. }
  109665. interface Document {
  109666. mozCancelFullScreen(): void;
  109667. msCancelFullScreen(): void;
  109668. webkitCancelFullScreen(): void;
  109669. requestPointerLock(): void;
  109670. exitPointerLock(): void;
  109671. mozFullScreen: boolean;
  109672. msIsFullScreen: boolean;
  109673. readonly webkitIsFullScreen: boolean;
  109674. readonly pointerLockElement: Element;
  109675. mozPointerLockElement: HTMLElement;
  109676. msPointerLockElement: HTMLElement;
  109677. webkitPointerLockElement: HTMLElement;
  109678. }
  109679. interface HTMLCanvasElement {
  109680. requestPointerLock(): void;
  109681. msRequestPointerLock?(): void;
  109682. mozRequestPointerLock?(): void;
  109683. webkitRequestPointerLock?(): void;
  109684. /** Track wether a record is in progress */
  109685. isRecording: boolean;
  109686. /** Capture Stream method defined by some browsers */
  109687. captureStream(fps?: number): MediaStream;
  109688. }
  109689. interface CanvasRenderingContext2D {
  109690. msImageSmoothingEnabled: boolean;
  109691. }
  109692. interface MouseEvent {
  109693. mozMovementX: number;
  109694. mozMovementY: number;
  109695. webkitMovementX: number;
  109696. webkitMovementY: number;
  109697. msMovementX: number;
  109698. msMovementY: number;
  109699. }
  109700. interface Navigator {
  109701. mozGetVRDevices: (any: any) => any;
  109702. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109703. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109704. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109705. webkitGetGamepads(): Gamepad[];
  109706. msGetGamepads(): Gamepad[];
  109707. webkitGamepads(): Gamepad[];
  109708. }
  109709. interface HTMLVideoElement {
  109710. mozSrcObject: any;
  109711. }
  109712. interface Math {
  109713. fround(x: number): number;
  109714. imul(a: number, b: number): number;
  109715. }
  109716. interface WebGLProgram {
  109717. context?: WebGLRenderingContext;
  109718. vertexShader?: WebGLShader;
  109719. fragmentShader?: WebGLShader;
  109720. isParallelCompiled: boolean;
  109721. onCompiled?: () => void;
  109722. }
  109723. interface WebGLRenderingContext {
  109724. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  109725. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  109726. vertexAttribDivisor(index: number, divisor: number): void;
  109727. createVertexArray(): any;
  109728. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  109729. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  109730. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  109731. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  109732. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  109733. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  109734. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  109735. // Queries
  109736. createQuery(): WebGLQuery;
  109737. deleteQuery(query: WebGLQuery): void;
  109738. beginQuery(target: number, query: WebGLQuery): void;
  109739. endQuery(target: number): void;
  109740. getQueryParameter(query: WebGLQuery, pname: number): any;
  109741. getQuery(target: number, pname: number): any;
  109742. MAX_SAMPLES: number;
  109743. RGBA8: number;
  109744. READ_FRAMEBUFFER: number;
  109745. DRAW_FRAMEBUFFER: number;
  109746. UNIFORM_BUFFER: number;
  109747. HALF_FLOAT_OES: number;
  109748. RGBA16F: number;
  109749. RGBA32F: number;
  109750. R32F: number;
  109751. RG32F: number;
  109752. RGB32F: number;
  109753. R16F: number;
  109754. RG16F: number;
  109755. RGB16F: number;
  109756. RED: number;
  109757. RG: number;
  109758. R8: number;
  109759. RG8: number;
  109760. UNSIGNED_INT_24_8: number;
  109761. DEPTH24_STENCIL8: number;
  109762. /* Multiple Render Targets */
  109763. drawBuffers(buffers: number[]): void;
  109764. readBuffer(src: number): void;
  109765. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  109766. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  109767. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  109768. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  109769. // Occlusion Query
  109770. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  109771. ANY_SAMPLES_PASSED: number;
  109772. QUERY_RESULT_AVAILABLE: number;
  109773. QUERY_RESULT: number;
  109774. }
  109775. interface WebGLBuffer {
  109776. references: number;
  109777. capacity: number;
  109778. is32Bits: boolean;
  109779. }
  109780. interface WebGLProgram {
  109781. transformFeedback?: WebGLTransformFeedback | null;
  109782. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  109783. }
  109784. interface EXT_disjoint_timer_query {
  109785. QUERY_COUNTER_BITS_EXT: number;
  109786. TIME_ELAPSED_EXT: number;
  109787. TIMESTAMP_EXT: number;
  109788. GPU_DISJOINT_EXT: number;
  109789. QUERY_RESULT_EXT: number;
  109790. QUERY_RESULT_AVAILABLE_EXT: number;
  109791. queryCounterEXT(query: WebGLQuery, target: number): void;
  109792. createQueryEXT(): WebGLQuery;
  109793. beginQueryEXT(target: number, query: WebGLQuery): void;
  109794. endQueryEXT(target: number): void;
  109795. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  109796. deleteQueryEXT(query: WebGLQuery): void;
  109797. }
  109798. interface WebGLUniformLocation {
  109799. _currentState: any;
  109800. }
  109801. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  109802. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  109803. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  109804. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109805. interface WebGLRenderingContext {
  109806. readonly RASTERIZER_DISCARD: number;
  109807. readonly DEPTH_COMPONENT24: number;
  109808. readonly TEXTURE_3D: number;
  109809. readonly TEXTURE_2D_ARRAY: number;
  109810. readonly TEXTURE_COMPARE_FUNC: number;
  109811. readonly TEXTURE_COMPARE_MODE: number;
  109812. readonly COMPARE_REF_TO_TEXTURE: number;
  109813. readonly TEXTURE_WRAP_R: number;
  109814. readonly HALF_FLOAT: number;
  109815. readonly RGB8: number;
  109816. readonly RED_INTEGER: number;
  109817. readonly RG_INTEGER: number;
  109818. readonly RGB_INTEGER: number;
  109819. readonly RGBA_INTEGER: number;
  109820. readonly R8_SNORM: number;
  109821. readonly RG8_SNORM: number;
  109822. readonly RGB8_SNORM: number;
  109823. readonly RGBA8_SNORM: number;
  109824. readonly R8I: number;
  109825. readonly RG8I: number;
  109826. readonly RGB8I: number;
  109827. readonly RGBA8I: number;
  109828. readonly R8UI: number;
  109829. readonly RG8UI: number;
  109830. readonly RGB8UI: number;
  109831. readonly RGBA8UI: number;
  109832. readonly R16I: number;
  109833. readonly RG16I: number;
  109834. readonly RGB16I: number;
  109835. readonly RGBA16I: number;
  109836. readonly R16UI: number;
  109837. readonly RG16UI: number;
  109838. readonly RGB16UI: number;
  109839. readonly RGBA16UI: number;
  109840. readonly R32I: number;
  109841. readonly RG32I: number;
  109842. readonly RGB32I: number;
  109843. readonly RGBA32I: number;
  109844. readonly R32UI: number;
  109845. readonly RG32UI: number;
  109846. readonly RGB32UI: number;
  109847. readonly RGBA32UI: number;
  109848. readonly RGB10_A2UI: number;
  109849. readonly R11F_G11F_B10F: number;
  109850. readonly RGB9_E5: number;
  109851. readonly RGB10_A2: number;
  109852. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  109853. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  109854. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  109855. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109856. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  109857. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  109858. 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;
  109859. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  109860. readonly TRANSFORM_FEEDBACK: number;
  109861. readonly INTERLEAVED_ATTRIBS: number;
  109862. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  109863. createTransformFeedback(): WebGLTransformFeedback;
  109864. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  109865. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  109866. beginTransformFeedback(primitiveMode: number): void;
  109867. endTransformFeedback(): void;
  109868. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  109869. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109870. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109871. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109872. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  109873. }
  109874. interface ImageBitmap {
  109875. readonly width: number;
  109876. readonly height: number;
  109877. close(): void;
  109878. }
  109879. interface WebGLQuery extends WebGLObject {
  109880. }
  109881. declare var WebGLQuery: {
  109882. prototype: WebGLQuery;
  109883. new(): WebGLQuery;
  109884. };
  109885. interface WebGLSampler extends WebGLObject {
  109886. }
  109887. declare var WebGLSampler: {
  109888. prototype: WebGLSampler;
  109889. new(): WebGLSampler;
  109890. };
  109891. interface WebGLSync extends WebGLObject {
  109892. }
  109893. declare var WebGLSync: {
  109894. prototype: WebGLSync;
  109895. new(): WebGLSync;
  109896. };
  109897. interface WebGLTransformFeedback extends WebGLObject {
  109898. }
  109899. declare var WebGLTransformFeedback: {
  109900. prototype: WebGLTransformFeedback;
  109901. new(): WebGLTransformFeedback;
  109902. };
  109903. interface WebGLVertexArrayObject extends WebGLObject {
  109904. }
  109905. declare var WebGLVertexArrayObject: {
  109906. prototype: WebGLVertexArrayObject;
  109907. new(): WebGLVertexArrayObject;
  109908. };
  109909. // Type definitions for WebVR API
  109910. // Project: https://w3c.github.io/webvr/
  109911. // Definitions by: six a <https://github.com/lostfictions>
  109912. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109913. interface VRDisplay extends EventTarget {
  109914. /**
  109915. * Dictionary of capabilities describing the VRDisplay.
  109916. */
  109917. readonly capabilities: VRDisplayCapabilities;
  109918. /**
  109919. * z-depth defining the far plane of the eye view frustum
  109920. * enables mapping of values in the render target depth
  109921. * attachment to scene coordinates. Initially set to 10000.0.
  109922. */
  109923. depthFar: number;
  109924. /**
  109925. * z-depth defining the near plane of the eye view frustum
  109926. * enables mapping of values in the render target depth
  109927. * attachment to scene coordinates. Initially set to 0.01.
  109928. */
  109929. depthNear: number;
  109930. /**
  109931. * An identifier for this distinct VRDisplay. Used as an
  109932. * association point in the Gamepad API.
  109933. */
  109934. readonly displayId: number;
  109935. /**
  109936. * A display name, a user-readable name identifying it.
  109937. */
  109938. readonly displayName: string;
  109939. readonly isConnected: boolean;
  109940. readonly isPresenting: boolean;
  109941. /**
  109942. * If this VRDisplay supports room-scale experiences, the optional
  109943. * stage attribute contains details on the room-scale parameters.
  109944. */
  109945. readonly stageParameters: VRStageParameters | null;
  109946. /**
  109947. * Passing the value returned by `requestAnimationFrame` to
  109948. * `cancelAnimationFrame` will unregister the callback.
  109949. * @param handle Define the hanle of the request to cancel
  109950. */
  109951. cancelAnimationFrame(handle: number): void;
  109952. /**
  109953. * Stops presenting to the VRDisplay.
  109954. * @returns a promise to know when it stopped
  109955. */
  109956. exitPresent(): Promise<void>;
  109957. /**
  109958. * Return the current VREyeParameters for the given eye.
  109959. * @param whichEye Define the eye we want the parameter for
  109960. * @returns the eye parameters
  109961. */
  109962. getEyeParameters(whichEye: string): VREyeParameters;
  109963. /**
  109964. * Populates the passed VRFrameData with the information required to render
  109965. * the current frame.
  109966. * @param frameData Define the data structure to populate
  109967. * @returns true if ok otherwise false
  109968. */
  109969. getFrameData(frameData: VRFrameData): boolean;
  109970. /**
  109971. * Get the layers currently being presented.
  109972. * @returns the list of VR layers
  109973. */
  109974. getLayers(): VRLayer[];
  109975. /**
  109976. * Return a VRPose containing the future predicted pose of the VRDisplay
  109977. * when the current frame will be presented. The value returned will not
  109978. * change until JavaScript has returned control to the browser.
  109979. *
  109980. * The VRPose will contain the position, orientation, velocity,
  109981. * and acceleration of each of these properties.
  109982. * @returns the pose object
  109983. */
  109984. getPose(): VRPose;
  109985. /**
  109986. * Return the current instantaneous pose of the VRDisplay, with no
  109987. * prediction applied.
  109988. * @returns the current instantaneous pose
  109989. */
  109990. getImmediatePose(): VRPose;
  109991. /**
  109992. * The callback passed to `requestAnimationFrame` will be called
  109993. * any time a new frame should be rendered. When the VRDisplay is
  109994. * presenting the callback will be called at the native refresh
  109995. * rate of the HMD. When not presenting this function acts
  109996. * identically to how window.requestAnimationFrame acts. Content should
  109997. * make no assumptions of frame rate or vsync behavior as the HMD runs
  109998. * asynchronously from other displays and at differing refresh rates.
  109999. * @param callback Define the eaction to run next frame
  110000. * @returns the request handle it
  110001. */
  110002. requestAnimationFrame(callback: FrameRequestCallback): number;
  110003. /**
  110004. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110005. * Repeat calls while already presenting will update the VRLayers being displayed.
  110006. * @param layers Define the list of layer to present
  110007. * @returns a promise to know when the request has been fulfilled
  110008. */
  110009. requestPresent(layers: VRLayer[]): Promise<void>;
  110010. /**
  110011. * Reset the pose for this display, treating its current position and
  110012. * orientation as the "origin/zero" values. VRPose.position,
  110013. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110014. * updated when calling resetPose(). This should be called in only
  110015. * sitting-space experiences.
  110016. */
  110017. resetPose(): void;
  110018. /**
  110019. * The VRLayer provided to the VRDisplay will be captured and presented
  110020. * in the HMD. Calling this function has the same effect on the source
  110021. * canvas as any other operation that uses its source image, and canvases
  110022. * created without preserveDrawingBuffer set to true will be cleared.
  110023. * @param pose Define the pose to submit
  110024. */
  110025. submitFrame(pose?: VRPose): void;
  110026. }
  110027. declare var VRDisplay: {
  110028. prototype: VRDisplay;
  110029. new(): VRDisplay;
  110030. };
  110031. interface VRLayer {
  110032. leftBounds?: number[] | Float32Array | null;
  110033. rightBounds?: number[] | Float32Array | null;
  110034. source?: HTMLCanvasElement | null;
  110035. }
  110036. interface VRDisplayCapabilities {
  110037. readonly canPresent: boolean;
  110038. readonly hasExternalDisplay: boolean;
  110039. readonly hasOrientation: boolean;
  110040. readonly hasPosition: boolean;
  110041. readonly maxLayers: number;
  110042. }
  110043. interface VREyeParameters {
  110044. /** @deprecated */
  110045. readonly fieldOfView: VRFieldOfView;
  110046. readonly offset: Float32Array;
  110047. readonly renderHeight: number;
  110048. readonly renderWidth: number;
  110049. }
  110050. interface VRFieldOfView {
  110051. readonly downDegrees: number;
  110052. readonly leftDegrees: number;
  110053. readonly rightDegrees: number;
  110054. readonly upDegrees: number;
  110055. }
  110056. interface VRFrameData {
  110057. readonly leftProjectionMatrix: Float32Array;
  110058. readonly leftViewMatrix: Float32Array;
  110059. readonly pose: VRPose;
  110060. readonly rightProjectionMatrix: Float32Array;
  110061. readonly rightViewMatrix: Float32Array;
  110062. readonly timestamp: number;
  110063. }
  110064. interface VRPose {
  110065. readonly angularAcceleration: Float32Array | null;
  110066. readonly angularVelocity: Float32Array | null;
  110067. readonly linearAcceleration: Float32Array | null;
  110068. readonly linearVelocity: Float32Array | null;
  110069. readonly orientation: Float32Array | null;
  110070. readonly position: Float32Array | null;
  110071. readonly timestamp: number;
  110072. }
  110073. interface VRStageParameters {
  110074. sittingToStandingTransform?: Float32Array;
  110075. sizeX?: number;
  110076. sizeY?: number;
  110077. }
  110078. interface Navigator {
  110079. getVRDisplays(): Promise<VRDisplay[]>;
  110080. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110081. }
  110082. interface Window {
  110083. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110084. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110085. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110086. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110087. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110088. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110089. }
  110090. interface Gamepad {
  110091. readonly displayId: number;
  110092. }
  110093. interface XRDevice {
  110094. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110095. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110096. }
  110097. interface XRSession {
  110098. getInputSources(): Array<any>;
  110099. baseLayer: XRWebGLLayer;
  110100. requestFrameOfReference(type: string): Promise<void>;
  110101. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110102. end(): Promise<void>;
  110103. requestAnimationFrame: Function;
  110104. addEventListener: Function;
  110105. }
  110106. interface XRSessionCreationOptions {
  110107. outputContext?: WebGLRenderingContext | null;
  110108. immersive?: boolean;
  110109. environmentIntegration?: boolean;
  110110. }
  110111. interface XRLayer {
  110112. getViewport: Function;
  110113. framebufferWidth: number;
  110114. framebufferHeight: number;
  110115. }
  110116. interface XRView {
  110117. projectionMatrix: Float32Array;
  110118. }
  110119. interface XRFrame {
  110120. getDevicePose: Function;
  110121. getInputPose: Function;
  110122. views: Array<XRView>;
  110123. baseLayer: XRLayer;
  110124. }
  110125. interface XRFrameOfReference {
  110126. }
  110127. interface XRWebGLLayer extends XRLayer {
  110128. framebuffer: WebGLFramebuffer;
  110129. }
  110130. declare var XRWebGLLayer: {
  110131. prototype: XRWebGLLayer;
  110132. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110133. };